aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-10-09 04:06:00 -0400
committerFelipe Balbi <balbi@ti.com>2013-10-10 11:21:52 -0400
commit5de862d73b2c1b3fbb0ac8b45eb496d77347d1b8 (patch)
tree282ddf3024c8fb916ecbc7f218a966b0de710705 /drivers/usb
parent23682e3c78c54620ccc6e3462220851e1ae8b02f (diff)
usb: gadget: f_mass_storage: create fsg_common_run_thread for use in fsg_common_init
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/f_mass_storage.c32
-rw-r--r--drivers/usb/gadget/f_mass_storage.h2
2 files changed, 23 insertions, 11 deletions
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 93a26b365e6a..5b99aa1846c3 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -2996,6 +2996,24 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
2996 i); 2996 i);
2997} 2997}
2998 2998
2999int fsg_common_run_thread(struct fsg_common *common)
3000{
3001 common->state = FSG_STATE_IDLE;
3002 /* Tell the thread to start working */
3003 common->thread_task =
3004 kthread_create(fsg_main_thread, common, "file-storage");
3005 if (IS_ERR(common->thread_task)) {
3006 common->state = FSG_STATE_TERMINATED;
3007 return PTR_ERR(common->thread_task);
3008 }
3009
3010 DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
3011
3012 wake_up_process(common->thread_task);
3013
3014 return 0;
3015}
3016
2999struct fsg_common *fsg_common_init(struct fsg_common *common, 3017struct fsg_common *fsg_common_init(struct fsg_common *common,
3000 struct usb_composite_dev *cdev, 3018 struct usb_composite_dev *cdev,
3001 struct fsg_config *cfg) 3019 struct fsg_config *cfg)
@@ -3032,21 +3050,13 @@ struct fsg_common *fsg_common_init(struct fsg_common *common,
3032 3050
3033 fsg_common_set_inquiry_string(common, cfg->vendor_name, 3051 fsg_common_set_inquiry_string(common, cfg->vendor_name,
3034 cfg->product_name); 3052 cfg->product_name);
3035 /* Tell the thread to start working */
3036 common->thread_task =
3037 kthread_create(fsg_main_thread, common, "file-storage");
3038 if (IS_ERR(common->thread_task)) {
3039 rc = PTR_ERR(common->thread_task);
3040 goto error_release;
3041 }
3042 3053
3043 /* Information */ 3054 /* Information */
3044 INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n"); 3055 INFO(common, FSG_DRIVER_DESC ", version: " FSG_DRIVER_VERSION "\n");
3045 INFO(common, "Number of LUNs=%d\n", common->nluns);
3046
3047 DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
3048 3056
3049 wake_up_process(common->thread_task); 3057 rc = fsg_common_run_thread(common);
3058 if (rc)
3059 goto error_release;
3050 3060
3051 return common; 3061 return common;
3052 3062
diff --git a/drivers/usb/gadget/f_mass_storage.h b/drivers/usb/gadget/f_mass_storage.h
index 34a15d6bc3ca..7d9e0bc1cbf1 100644
--- a/drivers/usb/gadget/f_mass_storage.h
+++ b/drivers/usb/gadget/f_mass_storage.h
@@ -126,6 +126,8 @@ int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg);
126void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn, 126void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
127 const char *pn); 127 const char *pn);
128 128
129int fsg_common_run_thread(struct fsg_common *common);
130
129void fsg_config_from_params(struct fsg_config *cfg, 131void fsg_config_from_params(struct fsg_config *cfg,
130 const struct fsg_module_parameters *params, 132 const struct fsg_module_parameters *params,
131 unsigned int fsg_num_buffers); 133 unsigned int fsg_num_buffers);