[PATCH 15/23] usb-gadget/f_phonet: use per-attribute show and store methods

2015-10-03 Thread Christoph Hellwig
To simplify the configfs interface and remove boilerplate code that also
causes binary bloat.

Signed-off-by: Christoph Hellwig 
Reviewed-by: Andrzej Pietrasiewicz 
---
 drivers/usb/gadget/function/f_phonet.c | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index c0c3ef2..c029ef6 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -589,21 +589,6 @@ static inline struct f_phonet_opts 
*to_f_phonet_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_phonet_opts);
-static ssize_t f_phonet_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_phonet_opts *opts = to_f_phonet_opts(item);
-   struct f_phonet_opts_attribute *f_phonet_opts_attr =
-   container_of(attr, struct f_phonet_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_phonet_opts_attr->show)
-   ret = f_phonet_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void phonet_attr_release(struct config_item *item)
 {
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@@ -613,19 +598,17 @@ static void phonet_attr_release(struct config_item *item)
 
 static struct configfs_item_operations phonet_item_ops = {
.release= phonet_attr_release,
-   .show_attribute = f_phonet_attr_show,
 };
 
-static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
 {
-   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+   return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
 }
 
-static struct f_phonet_opts_attribute f_phonet_ifname =
-   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+CONFIGFS_ATTR_RO(f_phonet_, ifname);
 
 static struct configfs_attribute *phonet_attrs[] = {
-   _phonet_ifname.attr,
+   _phonet_attr_ifname,
NULL,
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 15/23] usb-gadget/f_phonet: use per-attribute show and store methods

2015-09-28 Thread Andrzej Pietrasiewicz

W dniu 25.09.2015 o 15:49, Christoph Hellwig pisze:

Signed-off-by: Christoph Hellwig 


Reviewed-by: Andrzej Pietrasiewicz 


---
  drivers/usb/gadget/function/f_phonet.c | 25 -
  1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index c0c3ef2..c029ef6 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -589,21 +589,6 @@ static inline struct f_phonet_opts 
*to_f_phonet_opts(struct config_item *item)
func_inst.group);
  }

-CONFIGFS_ATTR_STRUCT(f_phonet_opts);
-static ssize_t f_phonet_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_phonet_opts *opts = to_f_phonet_opts(item);
-   struct f_phonet_opts_attribute *f_phonet_opts_attr =
-   container_of(attr, struct f_phonet_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_phonet_opts_attr->show)
-   ret = f_phonet_opts_attr->show(opts, page);
-   return ret;
-}
-
  static void phonet_attr_release(struct config_item *item)
  {
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@@ -613,19 +598,17 @@ static void phonet_attr_release(struct config_item *item)

  static struct configfs_item_operations phonet_item_ops = {
.release= phonet_attr_release,
-   .show_attribute = f_phonet_attr_show,
  };

-static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
  {
-   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+   return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
  }

-static struct f_phonet_opts_attribute f_phonet_ifname =
-   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+CONFIGFS_ATTR_RO(f_phonet_, ifname);

  static struct configfs_attribute *phonet_attrs[] = {
-   _phonet_ifname.attr,
+   _phonet_attr_ifname,
NULL,
  };




--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/23] usb-gadget/f_phonet: use per-attribute show and store methods

2015-09-25 Thread Christoph Hellwig
Signed-off-by: Christoph Hellwig 
---
 drivers/usb/gadget/function/f_phonet.c | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/function/f_phonet.c 
b/drivers/usb/gadget/function/f_phonet.c
index c0c3ef2..c029ef6 100644
--- a/drivers/usb/gadget/function/f_phonet.c
+++ b/drivers/usb/gadget/function/f_phonet.c
@@ -589,21 +589,6 @@ static inline struct f_phonet_opts 
*to_f_phonet_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_phonet_opts);
-static ssize_t f_phonet_attr_show(struct config_item *item,
-   struct configfs_attribute *attr,
-   char *page)
-{
-   struct f_phonet_opts *opts = to_f_phonet_opts(item);
-   struct f_phonet_opts_attribute *f_phonet_opts_attr =
-   container_of(attr, struct f_phonet_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_phonet_opts_attr->show)
-   ret = f_phonet_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void phonet_attr_release(struct config_item *item)
 {
struct f_phonet_opts *opts = to_f_phonet_opts(item);
@@ -613,19 +598,17 @@ static void phonet_attr_release(struct config_item *item)
 
 static struct configfs_item_operations phonet_item_ops = {
.release= phonet_attr_release,
-   .show_attribute = f_phonet_attr_show,
 };
 
-static ssize_t f_phonet_ifname_show(struct f_phonet_opts *opts, char *page)
+static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
 {
-   return gether_get_ifname(opts->net, page, PAGE_SIZE);
+   return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);
 }
 
-static struct f_phonet_opts_attribute f_phonet_ifname =
-   __CONFIGFS_ATTR_RO(ifname, f_phonet_ifname_show);
+CONFIGFS_ATTR_RO(f_phonet_, ifname);
 
 static struct configfs_attribute *phonet_attrs[] = {
-   _phonet_ifname.attr,
+   _phonet_attr_ifname,
NULL,
 };
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html