Patchwork [U-Boot,v4,RESEND,3/3] usb:udc:samsung Add functions for storing private gadget data in UDC driver

login
register
mail settings
Submitter Łukasz Majewski
Date April 30, 2012, 2:51 p.m.
Message ID <1335797479-1091-1-git-send-email-l.majewski@samsung.com>
Download mbox | patch
Permalink /patch/155885/
State Changes Requested
Delegated to: Marek Vasut
Headers show

Comments

Łukasz Majewski - April 30, 2012, 2:51 p.m.
This commit adds support for storing private data to Samsung's UDC
driver. This data is afterward used by usb gadget.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Vasut <marex@denx.de>
---
 drivers/usb/gadget/s3c_udc_otg.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
Marek Vasut - April 30, 2012, 3:22 p.m.
Dear Lukasz Majewski,

> This commit adds support for storing private data to Samsung's UDC
> driver. This data is afterward used by usb gadget.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
>  drivers/usb/gadget/s3c_udc_otg.c |   14 +++++++++++++-
>  1 files changed, 13 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/gadget/s3c_udc_otg.c
> b/drivers/usb/gadget/s3c_udc_otg.c index f7f7b54..1b589b2 100644
> --- a/drivers/usb/gadget/s3c_udc_otg.c
> +++ b/drivers/usb/gadget/s3c_udc_otg.c
> @@ -30,7 +30,7 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 
> USA *
>   */
> -
> +#undef DEBUG

You don't need to undef it :)

>  #include <common.h>
>  #include <asm/errno.h>
>  #include <linux/list.h>
> @@ -133,6 +133,18 @@ static void nuke(struct s3c_ep *ep, int status);
>  static int s3c_udc_set_halt(struct usb_ep *_ep, int value);
>  static void s3c_udc_set_nak(struct s3c_ep *ep);
> 
> +void set_udc_gadget_private_data(void *p)
> +{
> +	debug("%s: the_controller: 0x%p, p: 0x%p\n", __func__,
> +	       the_controller, p);
> +	the_controller->gadget.dev.device_data = p;
> +}
> +
> +void *get_udc_gadget_private_data(struct usb_gadget *gadget)
> +{
> +	return gadget->dev.device_data;
> +}
> +
>  static struct usb_ep_ops s3c_ep_ops = {
>  	.enable = s3c_ep_enable,
>  	.disable = s3c_ep_disable,

Best regards,
Marek Vasut
Wolfgang Denk - April 30, 2012, 3:23 p.m.
Dear Lukasz Majewski,

In message <1335797479-1091-1-git-send-email-l.majewski@samsung.com> you wrote:
> This commit adds support for storing private data to Samsung's UDC
> driver. This data is afterward used by usb gadget.
> 
> Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> Cc: Marek Vasut <marex@denx.de>
...
> --- a/drivers/usb/gadget/s3c_udc_otg.c
> +++ b/drivers/usb/gadget/s3c_udc_otg.c
> @@ -30,7 +30,7 @@
>   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
>   *
>   */
> -
> +#undef DEBUG

Sorry, but please do not define what is not defined anyway.

> +void set_udc_gadget_private_data(void *p)
> +{
> +	debug("%s: the_controller: 0x%p, p: 0x%p\n", __func__,
> +	       the_controller, p);
> +	the_controller->gadget.dev.device_data = p;
> +}

Hm... you chose the easy way.

My hope was that you would pick up my hint and keep the functionality,
and just convert it to debug_cond() instead.

For example, as is DEBUG_SETUP() would become "active" only when
DEBUG_S3C_UDC_SETUP is defined; see "include/usb/s3c_udc.h".  If we
change the plain "#define DEBUG_S3C_UDC_SETUP" into a 
"#define DEBUG_S3C_UDC_SETUP 1", then we can replace all use of

	DEBUG_SETUP(foo, ...);

by the standard

	debug_cond(DEBUG_S3C_UDC_SETUP != 0, foo, ...);

And similar for all the other DEBUG_S3C_* macros in
"include/usb/s3c_udc.h"

That would be much more useful, wouldn't it?

Best regards,

Wolfgang Denk
Łukasz Majewski - April 30, 2012, 3:46 p.m.
Hi Wolfgang,


> Dear Lukasz Majewski,
> 
> In message <1335797479-1091-1-git-send-email-l.majewski@samsung.com>
> you wrote:
> > This commit adds support for storing private data to Samsung's UDC
> > driver. This data is afterward used by usb gadget.
> > 
> > Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > Cc: Marek Vasut <marex@denx.de>
> ...
> > --- a/drivers/usb/gadget/s3c_udc_otg.c
> > +++ b/drivers/usb/gadget/s3c_udc_otg.c
> > @@ -30,7 +30,7 @@
> >   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
> > 02111-1307  USA *
> >   */
> > -
> > +#undef DEBUG
> 
> Sorry, but please do not define what is not defined anyway.
> 
> > +void set_udc_gadget_private_data(void *p)
> > +{
> > +	debug("%s: the_controller: 0x%p, p: 0x%p\n", __func__,
> > +	       the_controller, p);
> > +	the_controller->gadget.dev.device_data = p;
> > +}
> 
> Hm... you chose the easy way.

:-)

> 
> My hope was that you would pick up my hint and keep the functionality,
> and just convert it to debug_cond() instead.
> 
> For example, as is DEBUG_SETUP() would become "active" only when
> DEBUG_S3C_UDC_SETUP is defined; see "include/usb/s3c_udc.h".  If we
> change the plain "#define DEBUG_S3C_UDC_SETUP" into a 
> "#define DEBUG_S3C_UDC_SETUP 1", then we can replace all use of
> 
> 	DEBUG_SETUP(foo, ...);
> 
> by the standard
> 
> 	debug_cond(DEBUG_S3C_UDC_SETUP != 0, foo, ...);
> 
> And similar for all the other DEBUG_S3C_* macros in
> "include/usb/s3c_udc.h"
> 
> That would be much more useful, wouldn't it?
> 

Thank you for detailed debug_cond explanation.

I will look into the code and refactor it.

Patch

diff --git a/drivers/usb/gadget/s3c_udc_otg.c b/drivers/usb/gadget/s3c_udc_otg.c
index f7f7b54..1b589b2 100644
--- a/drivers/usb/gadget/s3c_udc_otg.c
+++ b/drivers/usb/gadget/s3c_udc_otg.c
@@ -30,7 +30,7 @@ 
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  */
-
+#undef DEBUG
 #include <common.h>
 #include <asm/errno.h>
 #include <linux/list.h>
@@ -133,6 +133,18 @@  static void nuke(struct s3c_ep *ep, int status);
 static int s3c_udc_set_halt(struct usb_ep *_ep, int value);
 static void s3c_udc_set_nak(struct s3c_ep *ep);
 
+void set_udc_gadget_private_data(void *p)
+{
+	debug("%s: the_controller: 0x%p, p: 0x%p\n", __func__,
+	       the_controller, p);
+	the_controller->gadget.dev.device_data = p;
+}
+
+void *get_udc_gadget_private_data(struct usb_gadget *gadget)
+{
+	return gadget->dev.device_data;
+}
+
 static struct usb_ep_ops s3c_ep_ops = {
 	.enable = s3c_ep_enable,
 	.disable = s3c_ep_disable,