Revert "usb/gadget: f_mass_storage: use usb_gstrings_attach"
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Tue, 14 Jan 2014 13:27:23 +0000 (14:27 +0100)
committerChanho Park <chanho61.park@samsung.com>
Tue, 18 Nov 2014 02:46:15 +0000 (11:46 +0900)
This reverts commit 2089c2070341b55b6476907100bfe2fd04467edd.

drivers/usb/gadget/f_mass_storage.c

index 04ee635..05d34a0 100644 (file)
@@ -242,11 +242,6 @@ static struct usb_gadget_strings   fsg_stringtab = {
        .strings        = fsg_strings,
 };
 
-static struct usb_gadget_strings *fsg_strings_array[] = {
-       &fsg_stringtab,
-       NULL,
-};
-
 /*-------------------------------------------------------------------------*/
 
 struct fsg_dev;
@@ -2615,7 +2610,6 @@ 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;
 
@@ -2658,13 +2652,14 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
        common->ep0req = cdev->req;
        common->cdev = cdev;
 
-       us = usb_gstrings_attach(cdev, fsg_strings_array,
-                                ARRAY_SIZE(fsg_strings));
-       if (IS_ERR(us)) {
-               rc = PTR_ERR(us);
-               goto error_release;
+       /* 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;
        }
-       fsg_intf_desc.iInterface = us[FSG_STRING_INTERFACE].id;
 
        /*
         * Create the LUNs, open their backing files, and register the
@@ -2958,6 +2953,11 @@ 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)
@@ -2970,6 +2970,7 @@ 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;