Re: [PATCH v2 07/21] usb/gadget: f_mass_storage: use usb_gstrings_attach

2013-07-25 Thread Michal Nazarewicz
On Fri, Jul 19 2013, Andrzej Pietrasiewicz wrote:
> Signed-off-by: Andrzej Pietrasiewicz 
> Signed-off-by: Kyungmin Park 

Acked-by: Michal Nazarewicz 

> ---
>  drivers/usb/gadget/f_mass_storage.c |   25 -
>  1 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_mass_storage.c 
> b/drivers/usb/gadget/f_mass_storage.c
> index d01d1dd..c56e24b 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -242,6 +242,11 @@ static struct usb_gadget_strings fsg_stringtab = {
>   .strings= fsg_strings,
>  };
>  
> +static struct usb_gadget_strings *fsg_strings_array[] = {
> + &fsg_stringtab,
> + NULL,
> +};
> +
>  /*-*/
>  
>  struct fsg_dev;
> @@ -2609,6 +2614,7 @@ struct fsg_common *fsg_common_init(struct fsg_common 
> *common,
>   struct fsg_buffhd *bh;
>   struct fsg_lun **curlun_it;
>   struct fsg_lun_config *lcfg;
> + struct usb_string *us;
>   int nluns, i, rc;
>   char *pathbuf;
>  
> @@ -2651,14 +2657,13 @@ struct fsg_common *fsg_common_init(struct fsg_common 
> *common,
>   common->ep0req = cdev->req;
>   common->cdev = cdev;
>  
> - /* Maybe allocate device-global string IDs, and patch descriptors */
> - if (fsg_strings[FSG_STRING_INTERFACE].id == 0) {
> - rc = usb_string_id(cdev);
> - if (unlikely(rc < 0))
> - goto error_release;
> - fsg_strings[FSG_STRING_INTERFACE].id = rc;
> - fsg_intf_desc.iInterface = rc;
> + us = usb_gstrings_attach(cdev, fsg_strings_array,
> +  ARRAY_SIZE(fsg_strings));
> + if (IS_ERR(us)) {
> + rc = PTR_ERR(us);
> + goto error_release;
>   }
> + fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id;
>  
>   /*
>* Create the LUNs, open their backing files, and register the
> @@ -2951,11 +2956,6 @@ autoconf_fail:
>  
>  /** ADD FUNCTION **/
>  
> -static struct usb_gadget_strings *fsg_strings_array[] = {
> - &fsg_stringtab,
> - NULL,
> -};
> -
>  static int fsg_bind_config(struct usb_composite_dev *cdev,
>  struct usb_configuration *c,
>  struct fsg_common *common)
> @@ -2968,7 +2968,6 @@ static int fsg_bind_config(struct usb_composite_dev 
> *cdev,
>   return -ENOMEM;
>  
>   fsg->function.name= FSG_DRIVER_DESC;
> - fsg->function.strings = fsg_strings_array;
>   fsg->function.bind= fsg_bind;
>   fsg->function.unbind  = fsg_unbind;
>   fsg->function.setup   = fsg_setup;
> -- 
> 1.7.0.4
>

-- 
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of  o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz(o o)
ooo +--ooO--(_)--Ooo--

signature.asc
Description: PGP signature


[PATCH v2 07/21] usb/gadget: f_mass_storage: use usb_gstrings_attach

2013-07-19 Thread Andrzej Pietrasiewicz
Signed-off-by: Andrzej Pietrasiewicz 
Signed-off-by: Kyungmin Park 
---
 drivers/usb/gadget/f_mass_storage.c |   25 -
 1 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c 
b/drivers/usb/gadget/f_mass_storage.c
index d01d1dd..c56e24b 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -242,6 +242,11 @@ static struct usb_gadget_strings   fsg_stringtab = {
.strings= fsg_strings,
 };
 
+static struct usb_gadget_strings *fsg_strings_array[] = {
+   &fsg_stringtab,
+   NULL,
+};
+
 /*-*/
 
 struct fsg_dev;
@@ -2609,6 +2614,7 @@ struct fsg_common *fsg_common_init(struct fsg_common 
*common,
struct fsg_buffhd *bh;
struct fsg_lun **curlun_it;
struct fsg_lun_config *lcfg;
+   struct usb_string *us;
int nluns, i, rc;
char *pathbuf;
 
@@ -2651,14 +2657,13 @@ struct fsg_common *fsg_common_init(struct fsg_common 
*common,
common->ep0req = cdev->req;
common->cdev = cdev;
 
-   /* Maybe allocate device-global string IDs, and patch descriptors */
-   if (fsg_strings[FSG_STRING_INTERFACE].id == 0) {
-   rc = usb_string_id(cdev);
-   if (unlikely(rc < 0))
-   goto error_release;
-   fsg_strings[FSG_STRING_INTERFACE].id = rc;
-   fsg_intf_desc.iInterface = rc;
+   us = usb_gstrings_attach(cdev, fsg_strings_array,
+ARRAY_SIZE(fsg_strings));
+   if (IS_ERR(us)) {
+   rc = PTR_ERR(us);
+   goto error_release;
}
+   fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id;
 
/*
 * Create the LUNs, open their backing files, and register the
@@ -2951,11 +2956,6 @@ autoconf_fail:
 
 /** ADD FUNCTION **/
 
-static struct usb_gadget_strings *fsg_strings_array[] = {
-   &fsg_stringtab,
-   NULL,
-};
-
 static int fsg_bind_config(struct usb_composite_dev *cdev,
   struct usb_configuration *c,
   struct fsg_common *common)
@@ -2968,7 +2968,6 @@ static int fsg_bind_config(struct usb_composite_dev *cdev,
return -ENOMEM;
 
fsg->function.name= FSG_DRIVER_DESC;
-   fsg->function.strings = fsg_strings_array;
fsg->function.bind= fsg_bind;
fsg->function.unbind  = fsg_unbind;
fsg->function.setup   = fsg_setup;
-- 
1.7.0.4

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