]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
usb: gadget: f_mass_storage: create fsg_common_run_thread for use in fsg_common_init
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Wed, 9 Oct 2013 08:06:00 +0000 (10:06 +0200)
committerFelipe Balbi <balbi@ti.com>
Thu, 10 Oct 2013 15:21:52 +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 93a26b365e6a2a4262b3d0bcc969c1d6d96cc965..5b99aa1846c3b70c1399f028b3d93b787bb4cf2a 100644 (file)
@@ -2996,6 +2996,24 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
                 i);
 }
 
+int fsg_common_run_thread(struct fsg_common *common)
+{
+       common->state = FSG_STATE_IDLE;
+       /* Tell the thread to start working */
+       common->thread_task =
+               kthread_create(fsg_main_thread, common, "file-storage");
+       if (IS_ERR(common->thread_task)) {
+               common->state = FSG_STATE_TERMINATED;
+               return PTR_ERR(common->thread_task);
+       }
+
+       DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
+
+       wake_up_process(common->thread_task);
+
+       return 0;
+}
+
 struct fsg_common *fsg_common_init(struct fsg_common *common,
                                   struct usb_composite_dev *cdev,
                                   struct fsg_config *cfg)
@@ -3032,21 +3050,13 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
 
        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");
-       if (IS_ERR(common->thread_task)) {
-               rc = PTR_ERR(common->thread_task);
-               goto error_release;
-       }
 
        /* Information */
        INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n");
-       INFO(common, "Number of LUNs=%d\n", common->nluns);
-
-       DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
 
-       wake_up_process(common->thread_task);
+       rc = fsg_common_run_thread(common);
+       if (rc)
+               goto error_release;
 
        return common;
 
index 34a15d6bc3caa79d4d9af489c27489d94bf379fb..7d9e0bc1cbf1c265a8d27a8632a6641289b49195 100644 (file)
@@ -126,6 +126,8 @@ 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);
 
+int fsg_common_run_thread(struct fsg_common *common);
+
 void fsg_config_from_params(struct fsg_config *cfg,
                            const struct fsg_module_parameters *params,
                            unsigned int fsg_num_buffers);