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

usb-gadget/f_hid: 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
da4e527c 76e0da34

+14 -20
+14 -20
drivers/usb/gadget/function/f_hid.c
··· 713 713 func_inst.group); 714 714 } 715 715 716 - CONFIGFS_ATTR_STRUCT(f_hid_opts); 717 - CONFIGFS_ATTR_OPS(f_hid_opts); 718 - 719 716 static void hid_attr_release(struct config_item *item) 720 717 { 721 718 struct f_hid_opts *opts = to_f_hid_opts(item); ··· 722 725 723 726 static struct configfs_item_operations hidg_item_ops = { 724 727 .release = hid_attr_release, 725 - .show_attribute = f_hid_opts_attr_show, 726 - .store_attribute = f_hid_opts_attr_store, 727 728 }; 728 729 729 730 #define F_HID_OPT(name, prec, limit) \ 730 - static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\ 731 + static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\ 731 732 { \ 733 + struct f_hid_opts *opts = to_f_hid_opts(item); \ 732 734 int result; \ 733 735 \ 734 736 mutex_lock(&opts->lock); \ ··· 737 741 return result; \ 738 742 } \ 739 743 \ 740 - static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts, \ 744 + static ssize_t f_hid_opts_##name##_store(struct config_item *item, \ 741 745 const char *page, size_t len) \ 742 746 { \ 747 + struct f_hid_opts *opts = to_f_hid_opts(item); \ 743 748 int ret; \ 744 749 u##prec num; \ 745 750 \ ··· 766 769 return ret; \ 767 770 } \ 768 771 \ 769 - static struct f_hid_opts_attribute f_hid_opts_##name = \ 770 - __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\ 771 - f_hid_opts_##name##_store) 772 + CONFIGFS_ATTR(f_hid_opts_, name) 772 773 773 774 F_HID_OPT(subclass, 8, 255); 774 775 F_HID_OPT(protocol, 8, 255); 775 776 F_HID_OPT(report_length, 16, 65535); 776 777 777 - static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page) 778 + static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char *page) 778 779 { 780 + struct f_hid_opts *opts = to_f_hid_opts(item); 779 781 int result; 780 782 781 783 mutex_lock(&opts->lock); ··· 785 789 return result; 786 790 } 787 791 788 - static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts, 792 + static ssize_t f_hid_opts_report_desc_store(struct config_item *item, 789 793 const char *page, size_t len) 790 794 { 795 + struct f_hid_opts *opts = to_f_hid_opts(item); 791 796 int ret = -EBUSY; 792 797 char *d; 793 798 ··· 815 818 return ret; 816 819 } 817 820 818 - static struct f_hid_opts_attribute f_hid_opts_report_desc = 819 - __CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR, 820 - f_hid_opts_report_desc_show, 821 - f_hid_opts_report_desc_store); 821 + CONFIGFS_ATTR(f_hid_opts_, report_desc); 822 822 823 823 static struct configfs_attribute *hid_attrs[] = { 824 - &f_hid_opts_subclass.attr, 825 - &f_hid_opts_protocol.attr, 826 - &f_hid_opts_report_length.attr, 827 - &f_hid_opts_report_desc.attr, 824 + &f_hid_opts_attr_subclass, 825 + &f_hid_opts_attr_protocol, 826 + &f_hid_opts_attr_report_length, 827 + &f_hid_opts_attr_report_desc, 828 828 NULL, 829 829 }; 830 830