mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-04-21 22:03:58 +00:00
usb-gadget/f_acm: use per-attribute show and store methods
To simplify the configfs interface and remove boilerplate code that also causes binary bloat. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
da4e527cd8
commit
ea6bd6b14e
1 changed files with 4 additions and 22 deletions
|
@ -776,21 +776,6 @@ static inline struct f_serial_opts *to_f_serial_opts(struct config_item *item)
|
||||||
func_inst.group);
|
func_inst.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIGFS_ATTR_STRUCT(f_serial_opts);
|
|
||||||
static ssize_t f_acm_attr_show(struct config_item *item,
|
|
||||||
struct configfs_attribute *attr,
|
|
||||||
char *page)
|
|
||||||
{
|
|
||||||
struct f_serial_opts *opts = to_f_serial_opts(item);
|
|
||||||
struct f_serial_opts_attribute *f_serial_opts_attr =
|
|
||||||
container_of(attr, struct f_serial_opts_attribute, attr);
|
|
||||||
ssize_t ret = 0;
|
|
||||||
|
|
||||||
if (f_serial_opts_attr->show)
|
|
||||||
ret = f_serial_opts_attr->show(opts, page);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void acm_attr_release(struct config_item *item)
|
static void acm_attr_release(struct config_item *item)
|
||||||
{
|
{
|
||||||
struct f_serial_opts *opts = to_f_serial_opts(item);
|
struct f_serial_opts *opts = to_f_serial_opts(item);
|
||||||
|
@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)
|
||||||
|
|
||||||
static struct configfs_item_operations acm_item_ops = {
|
static struct configfs_item_operations acm_item_ops = {
|
||||||
.release = acm_attr_release,
|
.release = acm_attr_release,
|
||||||
.show_attribute = f_acm_attr_show,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
|
static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
|
||||||
{
|
{
|
||||||
return sprintf(page, "%u\n", opts->port_num);
|
return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct f_serial_opts_attribute f_acm_port_num =
|
CONFIGFS_ATTR_RO(f_acm_port_, num);
|
||||||
__CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
|
|
||||||
|
|
||||||
|
|
||||||
static struct configfs_attribute *acm_attrs[] = {
|
static struct configfs_attribute *acm_attrs[] = {
|
||||||
&f_acm_port_num.attr,
|
&f_acm_port_attr_num,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue