diff options
author | Christoph Hellwig <hch@lst.de> | 2015-10-03 09:32:49 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2015-10-14 01:15:34 -0400 |
commit | 495702bcc12fb2c51997088befe37145a34e5e3a (patch) | |
tree | 5281f3a791dcd02f1089d0213dcea3dd908960a1 | |
parent | c6f89f1cca1cfd81cc27307595ebddee29cc84d3 (diff) |
usb-gadget/f_uac2: 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>
-rw-r--r-- | drivers/usb/gadget/function/f_uac2.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c index f8de7ea2a0c1..0a5a1e1aac28 100644 --- a/drivers/usb/gadget/function/f_uac2.c +++ b/drivers/usb/gadget/function/f_uac2.c | |||
@@ -1445,9 +1445,6 @@ static inline struct f_uac2_opts *to_f_uac2_opts(struct config_item *item) | |||
1445 | func_inst.group); | 1445 | func_inst.group); |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | CONFIGFS_ATTR_STRUCT(f_uac2_opts); | ||
1449 | CONFIGFS_ATTR_OPS(f_uac2_opts); | ||
1450 | |||
1451 | static void f_uac2_attr_release(struct config_item *item) | 1448 | static void f_uac2_attr_release(struct config_item *item) |
1452 | { | 1449 | { |
1453 | struct f_uac2_opts *opts = to_f_uac2_opts(item); | 1450 | struct f_uac2_opts *opts = to_f_uac2_opts(item); |
@@ -1457,14 +1454,13 @@ static void f_uac2_attr_release(struct config_item *item) | |||
1457 | 1454 | ||
1458 | static struct configfs_item_operations f_uac2_item_ops = { | 1455 | static struct configfs_item_operations f_uac2_item_ops = { |
1459 | .release = f_uac2_attr_release, | 1456 | .release = f_uac2_attr_release, |
1460 | .show_attribute = f_uac2_opts_attr_show, | ||
1461 | .store_attribute = f_uac2_opts_attr_store, | ||
1462 | }; | 1457 | }; |
1463 | 1458 | ||
1464 | #define UAC2_ATTRIBUTE(name) \ | 1459 | #define UAC2_ATTRIBUTE(name) \ |
1465 | static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \ | 1460 | static ssize_t f_uac2_opts_##name##_show(struct config_item *item, \ |
1466 | char *page) \ | 1461 | char *page) \ |
1467 | { \ | 1462 | { \ |
1463 | struct f_uac2_opts *opts = to_f_uac2_opts(item); \ | ||
1468 | int result; \ | 1464 | int result; \ |
1469 | \ | 1465 | \ |
1470 | mutex_lock(&opts->lock); \ | 1466 | mutex_lock(&opts->lock); \ |
@@ -1474,9 +1470,10 @@ static ssize_t f_uac2_opts_##name##_show(struct f_uac2_opts *opts, \ | |||
1474 | return result; \ | 1470 | return result; \ |
1475 | } \ | 1471 | } \ |
1476 | \ | 1472 | \ |
1477 | static ssize_t f_uac2_opts_##name##_store(struct f_uac2_opts *opts, \ | 1473 | static ssize_t f_uac2_opts_##name##_store(struct config_item *item, \ |
1478 | const char *page, size_t len) \ | 1474 | const char *page, size_t len) \ |
1479 | { \ | 1475 | { \ |
1476 | struct f_uac2_opts *opts = to_f_uac2_opts(item); \ | ||
1480 | int ret; \ | 1477 | int ret; \ |
1481 | u32 num; \ | 1478 | u32 num; \ |
1482 | \ | 1479 | \ |
@@ -1498,10 +1495,7 @@ end: \ | |||
1498 | return ret; \ | 1495 | return ret; \ |
1499 | } \ | 1496 | } \ |
1500 | \ | 1497 | \ |
1501 | static struct f_uac2_opts_attribute f_uac2_opts_##name = \ | 1498 | CONFIGFS_ATTR(f_uac2_opts_, name) |
1502 | __CONFIGFS_ATTR(name, S_IRUGO | S_IWUSR, \ | ||
1503 | f_uac2_opts_##name##_show, \ | ||
1504 | f_uac2_opts_##name##_store) | ||
1505 | 1499 | ||
1506 | UAC2_ATTRIBUTE(p_chmask); | 1500 | UAC2_ATTRIBUTE(p_chmask); |
1507 | UAC2_ATTRIBUTE(p_srate); | 1501 | UAC2_ATTRIBUTE(p_srate); |
@@ -1511,12 +1505,12 @@ UAC2_ATTRIBUTE(c_srate); | |||
1511 | UAC2_ATTRIBUTE(c_ssize); | 1505 | UAC2_ATTRIBUTE(c_ssize); |
1512 | 1506 | ||
1513 | static struct configfs_attribute *f_uac2_attrs[] = { | 1507 | static struct configfs_attribute *f_uac2_attrs[] = { |
1514 | &f_uac2_opts_p_chmask.attr, | 1508 | &f_uac2_opts_attr_p_chmask, |
1515 | &f_uac2_opts_p_srate.attr, | 1509 | &f_uac2_opts_attr_p_srate, |
1516 | &f_uac2_opts_p_ssize.attr, | 1510 | &f_uac2_opts_attr_p_ssize, |
1517 | &f_uac2_opts_c_chmask.attr, | 1511 | &f_uac2_opts_attr_c_chmask, |
1518 | &f_uac2_opts_c_srate.attr, | 1512 | &f_uac2_opts_attr_c_srate, |
1519 | &f_uac2_opts_c_ssize.attr, | 1513 | &f_uac2_opts_attr_c_ssize, |
1520 | NULL, | 1514 | NULL, |
1521 | }; | 1515 | }; |
1522 | 1516 | ||