Commit f9a63da3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger

usb-gadget/ether: use per-attribute show and store methods

To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent ea6bd6b1
...@@ -855,10 +855,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm); ...@@ -855,10 +855,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ecm);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm); USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ecm);
static struct configfs_attribute *ecm_attrs[] = { static struct configfs_attribute *ecm_attrs[] = {
&f_ecm_opts_dev_addr.attr, &ecm_opts_attr_dev_addr,
&f_ecm_opts_host_addr.attr, &ecm_opts_attr_host_addr,
&f_ecm_opts_qmult.attr, &ecm_opts_attr_qmult,
&f_ecm_opts_ifname.attr, &ecm_opts_attr_ifname,
NULL, NULL,
}; };
......
...@@ -555,10 +555,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem); ...@@ -555,10 +555,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem); USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
static struct configfs_attribute *eem_attrs[] = { static struct configfs_attribute *eem_attrs[] = {
&f_eem_opts_dev_addr.attr, &eem_opts_attr_dev_addr,
&f_eem_opts_host_addr.attr, &eem_opts_attr_host_addr,
&f_eem_opts_qmult.attr, &eem_opts_attr_qmult,
&f_eem_opts_ifname.attr, &eem_opts_attr_ifname,
NULL, NULL,
}; };
......
...@@ -1503,10 +1503,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm); ...@@ -1503,10 +1503,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(ncm);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm); USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(ncm);
static struct configfs_attribute *ncm_attrs[] = { static struct configfs_attribute *ncm_attrs[] = {
&f_ncm_opts_dev_addr.attr, &ncm_opts_attr_dev_addr,
&f_ncm_opts_host_addr.attr, &ncm_opts_attr_host_addr,
&f_ncm_opts_qmult.attr, &ncm_opts_attr_qmult,
&f_ncm_opts_ifname.attr, &ncm_opts_attr_ifname,
NULL, NULL,
}; };
......
...@@ -878,10 +878,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis); ...@@ -878,10 +878,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(rndis);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis); USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(rndis);
static struct configfs_attribute *rndis_attrs[] = { static struct configfs_attribute *rndis_attrs[] = {
&f_rndis_opts_dev_addr.attr, &rndis_opts_attr_dev_addr,
&f_rndis_opts_host_addr.attr, &rndis_opts_attr_host_addr,
&f_rndis_opts_qmult.attr, &rndis_opts_attr_qmult,
&f_rndis_opts_ifname.attr, &rndis_opts_attr_ifname,
NULL, NULL,
}; };
......
...@@ -413,10 +413,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether); ...@@ -413,10 +413,10 @@ USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(gether);
USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether); USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(gether);
static struct configfs_attribute *gether_attrs[] = { static struct configfs_attribute *gether_attrs[] = {
&f_gether_opts_dev_addr.attr, &gether_opts_attr_dev_addr,
&f_gether_opts_host_addr.attr, &gether_opts_attr_host_addr,
&f_gether_opts_qmult.attr, &gether_opts_attr_qmult,
&f_gether_opts_ifname.attr, &gether_opts_attr_ifname,
NULL, NULL,
}; };
......
...@@ -17,9 +17,6 @@ ...@@ -17,9 +17,6 @@
#define __U_ETHER_CONFIGFS_H #define __U_ETHER_CONFIGFS_H
#define USB_ETHERNET_CONFIGFS_ITEM(_f_) \ #define USB_ETHERNET_CONFIGFS_ITEM(_f_) \
CONFIGFS_ATTR_STRUCT(f_##_f_##_opts); \
CONFIGFS_ATTR_OPS(f_##_f_##_opts); \
\
static void _f_##_attr_release(struct config_item *item) \ static void _f_##_attr_release(struct config_item *item) \
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
...@@ -29,14 +26,13 @@ ...@@ -29,14 +26,13 @@
\ \
static struct configfs_item_operations _f_##_item_ops = { \ static struct configfs_item_operations _f_##_item_ops = { \
.release = _f_##_attr_release, \ .release = _f_##_attr_release, \
.show_attribute = f_##_f_##_opts_attr_show, \
.store_attribute = f_##_f_##_opts_attr_store, \
} }
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(_f_) \ #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(_f_) \
static ssize_t _f_##_opts_dev_addr_show(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_dev_addr_show(struct config_item *item, \
char *page) \ char *page) \
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int result; \ int result; \
\ \
mutex_lock(&opts->lock); \ mutex_lock(&opts->lock); \
...@@ -46,9 +42,10 @@ ...@@ -46,9 +42,10 @@
return result; \ return result; \
} \ } \
\ \
static ssize_t _f_##_opts_dev_addr_store(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_dev_addr_store(struct config_item *item, \
const char *page, size_t len)\ const char *page, size_t len)\
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int ret; \ int ret; \
\ \
mutex_lock(&opts->lock); \ mutex_lock(&opts->lock); \
...@@ -64,15 +61,13 @@ ...@@ -64,15 +61,13 @@
return ret; \ return ret; \
} \ } \
\ \
static struct f_##_f_##_opts_attribute f_##_f_##_opts_dev_addr = \ CONFIGFS_ATTR(_f_##_opts_, dev_addr)
__CONFIGFS_ATTR(dev_addr, S_IRUGO | S_IWUSR, \
_f_##_opts_dev_addr_show, \
_f_##_opts_dev_addr_store)
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(_f_) \ #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(_f_) \
static ssize_t _f_##_opts_host_addr_show(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_host_addr_show(struct config_item *item, \
char *page) \ char *page) \
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int result; \ int result; \
\ \
mutex_lock(&opts->lock); \ mutex_lock(&opts->lock); \
...@@ -82,9 +77,10 @@ ...@@ -82,9 +77,10 @@
return result; \ return result; \
} \ } \
\ \
static ssize_t _f_##_opts_host_addr_store(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_host_addr_store(struct config_item *item, \
const char *page, size_t len)\ const char *page, size_t len)\
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int ret; \ int ret; \
\ \
mutex_lock(&opts->lock); \ mutex_lock(&opts->lock); \
...@@ -100,15 +96,13 @@ ...@@ -100,15 +96,13 @@
return ret; \ return ret; \
} \ } \
\ \
static struct f_##_f_##_opts_attribute f_##_f_##_opts_host_addr = \ CONFIGFS_ATTR(_f_##_opts_, host_addr)
__CONFIGFS_ATTR(host_addr, S_IRUGO | S_IWUSR, \
_f_##_opts_host_addr_show, \
_f_##_opts_host_addr_store)
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(_f_) \ #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(_f_) \
static ssize_t _f_##_opts_qmult_show(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_qmult_show(struct config_item *item, \
char *page) \ char *page) \
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
unsigned qmult; \ unsigned qmult; \
\ \
mutex_lock(&opts->lock); \ mutex_lock(&opts->lock); \
...@@ -117,9 +111,10 @@ ...@@ -117,9 +111,10 @@
return sprintf(page, "%d", qmult); \ return sprintf(page, "%d", qmult); \
} \ } \
\ \
static ssize_t _f_##_opts_qmult_store(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_qmult_store(struct config_item *item, \
const char *page, size_t len)\ const char *page, size_t len)\
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
u8 val; \ u8 val; \
int ret; \ int ret; \
\ \
...@@ -140,15 +135,13 @@ out: \ ...@@ -140,15 +135,13 @@ out: \
return ret; \ return ret; \
} \ } \
\ \
static struct f_##_f_##_opts_attribute f_##_f_##_opts_qmult = \ CONFIGFS_ATTR(_f_##_opts_, qmult)
__CONFIGFS_ATTR(qmult, S_IRUGO | S_IWUSR, \
_f_##_opts_qmult_show, \
_f_##_opts_qmult_store)
#define USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(_f_) \ #define USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(_f_) \
static ssize_t _f_##_opts_ifname_show(struct f_##_f_##_opts *opts, \ static ssize_t _f_##_opts_ifname_show(struct config_item *item, \
char *page) \ char *page) \
{ \ { \
struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \
int ret; \ int ret; \
\ \
mutex_lock(&opts->lock); \ mutex_lock(&opts->lock); \
...@@ -158,7 +151,6 @@ out: \ ...@@ -158,7 +151,6 @@ out: \
return ret; \ return ret; \
} \ } \
\ \
static struct f_##_f_##_opts_attribute f_##_f_##_opts_ifname = \ CONFIGFS_ATTR_RO(_f_##_opts_, ifname)
__CONFIGFS_ATTR_RO(ifname, _f_##_opts_ifname_show)
#endif /* __U_ETHER_CONFIGFS_H */ #endif /* __U_ETHER_CONFIGFS_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment