[PATCH 05/23] usb-gadget/f_acm: 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_acm.c | 26 --
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index be9df09..68b289f 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -776,21 +776,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_acm_attr_show(struct config_item *item,
-struct configfs_attribute *attr,
-char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void acm_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)
 
 static struct configfs_item_operations acm_item_ops = {
.release= acm_attr_release,
-   .show_attribute = f_acm_attr_show,
 };
 
-static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_acm_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
-
+CONFIGFS_ATTR_RO(f_acm_port_, num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   _acm_port_num.attr,
+   _acm_port_attr_num,
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 05/23] usb-gadget/f_acm: 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_acm.c | 26 --
  1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index be9df09..68b289f 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -776,21 +776,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
  }

-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_acm_attr_show(struct config_item *item,
-struct configfs_attribute *attr,
-char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-   return ret;
-}
-
  static void acm_attr_release(struct config_item *item)
  {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)

  static struct configfs_item_operations acm_item_ops = {
.release= acm_attr_release,
-   .show_attribute = f_acm_attr_show,
  };

-static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
  {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
  }

-static struct f_serial_opts_attribute f_acm_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
-
+CONFIGFS_ATTR_RO(f_acm_port_, num);

  static struct configfs_attribute *acm_attrs[] = {
-   _acm_port_num.attr,
+   _acm_port_attr_num,
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 05/23] usb-gadget/f_acm: use per-attribute show and store methods

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

diff --git a/drivers/usb/gadget/function/f_acm.c 
b/drivers/usb/gadget/function/f_acm.c
index be9df09..68b289f 100644
--- a/drivers/usb/gadget/function/f_acm.c
+++ b/drivers/usb/gadget/function/f_acm.c
@@ -776,21 +776,6 @@ static inline struct f_serial_opts 
*to_f_serial_opts(struct config_item *item)
func_inst.group);
 }
 
-CONFIGFS_ATTR_STRUCT(f_serial_opts);
-static ssize_t f_acm_attr_show(struct config_item *item,
-struct configfs_attribute *attr,
-char *page)
-{
-   struct f_serial_opts *opts = to_f_serial_opts(item);
-   struct f_serial_opts_attribute *f_serial_opts_attr =
-   container_of(attr, struct f_serial_opts_attribute, attr);
-   ssize_t ret = 0;
-
-   if (f_serial_opts_attr->show)
-   ret = f_serial_opts_attr->show(opts, page);
-   return ret;
-}
-
 static void acm_attr_release(struct config_item *item)
 {
struct f_serial_opts *opts = to_f_serial_opts(item);
@@ -800,20 +785,17 @@ static void acm_attr_release(struct config_item *item)
 
 static struct configfs_item_operations acm_item_ops = {
.release= acm_attr_release,
-   .show_attribute = f_acm_attr_show,
 };
 
-static ssize_t f_acm_port_num_show(struct f_serial_opts *opts, char *page)
+static ssize_t f_acm_port_num_show(struct config_item *item, char *page)
 {
-   return sprintf(page, "%u\n", opts->port_num);
+   return sprintf(page, "%u\n", to_f_serial_opts(item)->port_num);
 }
 
-static struct f_serial_opts_attribute f_acm_port_num =
-   __CONFIGFS_ATTR_RO(port_num, f_acm_port_num_show);
-
+CONFIGFS_ATTR_RO(f_acm_port_, num);
 
 static struct configfs_attribute *acm_attrs[] = {
-   _acm_port_num.attr,
+   _acm_port_attr_num,
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