Skip to content

Commit da4e527

Browse files
Christoph HellwigNicholas Bellinger
authored andcommitted
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>
1 parent 76e0da3 commit da4e527

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

drivers/usb/gadget/function/f_hid.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,6 @@ static inline struct f_hid_opts *to_f_hid_opts(struct config_item *item)
713713
func_inst.group);
714714
}
715715

716-
CONFIGFS_ATTR_STRUCT(f_hid_opts);
717-
CONFIGFS_ATTR_OPS(f_hid_opts);
718-
719716
static void hid_attr_release(struct config_item *item)
720717
{
721718
struct f_hid_opts *opts = to_f_hid_opts(item);
@@ -725,13 +722,12 @@ static void hid_attr_release(struct config_item *item)
725722

726723
static struct configfs_item_operations hidg_item_ops = {
727724
.release = hid_attr_release,
728-
.show_attribute = f_hid_opts_attr_show,
729-
.store_attribute = f_hid_opts_attr_store,
730725
};
731726

732727
#define F_HID_OPT(name, prec, limit) \
733-
static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
728+
static ssize_t f_hid_opts_##name##_show(struct config_item *item, char *page)\
734729
{ \
730+
struct f_hid_opts *opts = to_f_hid_opts(item); \
735731
int result; \
736732
\
737733
mutex_lock(&opts->lock); \
@@ -741,9 +737,10 @@ static ssize_t f_hid_opts_##name##_show(struct f_hid_opts *opts, char *page)\
741737
return result; \
742738
} \
743739
\
744-
static ssize_t f_hid_opts_##name##_store(struct f_hid_opts *opts, \
740+
static ssize_t f_hid_opts_##name##_store(struct config_item *item, \
745741
const char *page, size_t len) \
746742
{ \
743+
struct f_hid_opts *opts = to_f_hid_opts(item); \
747744
int ret; \
748745
u##prec num; \
749746
\
@@ -769,16 +766,15 @@ end: \
769766
return ret; \
770767
} \
771768
\
772-
static struct f_hid_opts_attribute f_hid_opts_##name = \
773-
__CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, f_hid_opts_##name##_show,\
774-
f_hid_opts_##name##_store)
769+
CONFIGFS_ATTR(f_hid_opts_, name)
775770

776771
F_HID_OPT(subclass, 8, 255);
777772
F_HID_OPT(protocol, 8, 255);
778773
F_HID_OPT(report_length, 16, 65535);
779774

780-
static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
775+
static ssize_t f_hid_opts_report_desc_show(struct config_item *item, char *page)
781776
{
777+
struct f_hid_opts *opts = to_f_hid_opts(item);
782778
int result;
783779

784780
mutex_lock(&opts->lock);
@@ -789,9 +785,10 @@ static ssize_t f_hid_opts_report_desc_show(struct f_hid_opts *opts, char *page)
789785
return result;
790786
}
791787

792-
static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
788+
static ssize_t f_hid_opts_report_desc_store(struct config_item *item,
793789
const char *page, size_t len)
794790
{
791+
struct f_hid_opts *opts = to_f_hid_opts(item);
795792
int ret = -EBUSY;
796793
char *d;
797794

@@ -818,16 +815,13 @@ static ssize_t f_hid_opts_report_desc_store(struct f_hid_opts *opts,
818815
return ret;
819816
}
820817

821-
static struct f_hid_opts_attribute f_hid_opts_report_desc =
822-
__CONFIGFS_ATTR(report_desc, S_IRUGO | S_IWUSR,
823-
f_hid_opts_report_desc_show,
824-
f_hid_opts_report_desc_store);
818+
CONFIGFS_ATTR(f_hid_opts_, report_desc);
825819

826820
static struct configfs_attribute *hid_attrs[] = {
827-
&f_hid_opts_subclass.attr,
828-
&f_hid_opts_protocol.attr,
829-
&f_hid_opts_report_length.attr,
830-
&f_hid_opts_report_desc.attr,
821+
&f_hid_opts_attr_subclass,
822+
&f_hid_opts_attr_protocol,
823+
&f_hid_opts_attr_report_length,
824+
&f_hid_opts_attr_report_desc,
831825
NULL,
832826
};
833827

0 commit comments

Comments
 (0)