usb: gadget: f_mass_storage: create fsg_common_set_inquiry_string for use in fsg_comm...
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Wed, 9 Oct 2013 08:05:59 +0000 (10:05 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 10 Oct 2013 15:21:51 +0000 (10:21 -0500)
fsg_common_init is a lengthy function. Factor a portion of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/f_mass_storage.c
drivers/usb/gadget/f_mass_storage.h

index 6a67e2ed75d9f516703059106bc121e36d0adfa2..93a26b365e6a2a4262b3d0bcc969c1d6d96cc965 100644 (file)
@@ -2980,11 +2980,27 @@ fail:
        return rc;
 }
 
+void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
+                                  const char *pn)
+{
+       int i;
+
+       /* Prepare inquiryString */
+       i = get_default_bcdDevice();
+       snprintf(common->inquiry_string, sizeof(common->inquiry_string),
+                "%-8s%-16s%04x", vn ?: "Linux",
+                /* Assume product name dependent on the first LUN */
+                pn ?: ((*common->luns)->cdrom
+                    ? "File-CD Gadget"
+                    : "File-Stor Gadget"),
+                i);
+}
+
 struct fsg_common *fsg_common_init(struct fsg_common *common,
                                   struct usb_composite_dev *cdev,
                                   struct fsg_config *cfg)
 {
-       int i, rc;
+       int rc;
 
        common = fsg_common_setup(common);
        if (IS_ERR(common))
@@ -3013,16 +3029,9 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
        if (rc)
                goto error_release;
 
-       /* Prepare inquiryString */
-       i = get_default_bcdDevice();
-       snprintf(common->inquiry_string, sizeof common->inquiry_string,
-                "%-8s%-16s%04x", cfg->vendor_name ?: "Linux",
-                /* Assume product name dependent on the first LUN */
-                cfg->product_name ?: ((*common->luns)->cdrom
-                                    ? "File-CD Gadget"
-                                    : "File-Stor Gadget"),
-                i);
 
+       fsg_common_set_inquiry_string(common, cfg->vendor_name,
+                                     cfg->product_name);
        /* Tell the thread to start working */
        common->thread_task =
                kthread_create(fsg_main_thread, common, "file-storage");
index 2a51e7b1cc60bd32494ae4635de74b7e0facc771..34a15d6bc3caa79d4d9af489c27489d94bf379fb 100644 (file)
@@ -123,6 +123,9 @@ int fsg_common_create_lun(struct fsg_common *common, struct fsg_lun_config *cfg,
 
 int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
 
+void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
+                                  const char *pn);
+
 void fsg_config_from_params(struct fsg_config *cfg,
                            const struct fsg_module_parameters *params,
                            unsigned int fsg_num_buffers);