Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Christoph Hellwig and committed by
Nicholas Bellinger
ea6bd6b1 da4e527c

+4 -22
+4 -22
drivers/usb/gadget/function/f_acm.c
··· 776 776 func_inst.group); 777 777 } 778 778 779 - CONFIGFS_ATTR_STRUCT(f_serial_opts); 780 - static ssize_t f_acm_attr_show(struct config_item *item, 781 - struct configfs_attribute *attr, 782 - char *page) 783 - { 784 - struct f_serial_opts *opts = to_f_serial_opts(item); 785 - struct f_serial_opts_attribute *f_serial_opts_attr = 786 - container_of(attr, struct f_serial_opts_attribute, attr); 787 - ssize_t ret = 0; 788 - 789 - if (f_serial_opts_attr->show) 790 - ret = f_serial_opts_attr->show(opts, page); 791 - return ret; 792 - } 793 - 794 779 static void acm_attr_release(struct config_item *item) 795 780 { 796 781 struct f_serial_opts *opts = to_f_serial_opts(item); ··· 785 800 786 801 static struct configfs_item_operations acm_item_ops = { 787 802 .release = acm_attr_release, 788 - .show_attribute = f_acm_attr_show, 789 803 }; 790 804 791 - static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page) 805 + static ssize_t f_acm_port_num_show(struct config_item *item, char *page) 792 806 { 793 - return sprintf(page, "%u\n", opts->port_num); 807 + return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num); 794 808 } 795 809 796 - static struct f_serial_opts_attribute f_acm_port_num = 797 - __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show); 798 - 810 + CONFIGFS_ATTR_RO(f_acm_port_, num); 799 811 800 812 static struct configfs_attribute *acm_attrs[] = { 801 - &f_acm_port_num.attr, 813 + &f_acm_port_attr_num, 802 814 NULL, 803 815 }; 804 816