aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/function/f_mass_storage.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/function/f_mass_storage.c')
-rw-r--r--drivers/usb/gadget/function/f_mass_storage.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index acf210f16328..5c6d4d7ca605 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2977,25 +2977,6 @@ void fsg_common_set_inquiry_string(struct fsg_common *common, const char *vn,
2977} 2977}
2978EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string); 2978EXPORT_SYMBOL_GPL(fsg_common_set_inquiry_string);
2979 2979
2980int fsg_common_run_thread(struct fsg_common *common)
2981{
2982 common->state = FSG_STATE_IDLE;
2983 /* Tell the thread to start working */
2984 common->thread_task =
2985 kthread_create(fsg_main_thread, common, "file-storage");
2986 if (IS_ERR(common->thread_task)) {
2987 common->state = FSG_STATE_TERMINATED;
2988 return PTR_ERR(common->thread_task);
2989 }
2990
2991 DBG(common, "I/O thread pid: %d\n", task_pid_nr(common->thread_task));
2992
2993 wake_up_process(common->thread_task);
2994
2995 return 0;
2996}
2997EXPORT_SYMBOL_GPL(fsg_common_run_thread);
2998
2999static void fsg_common_release(struct kref *ref) 2980static void fsg_common_release(struct kref *ref)
3000{ 2981{
3001 struct fsg_common *common = container_of(ref, struct fsg_common, ref); 2982 struct fsg_common *common = container_of(ref, struct fsg_common, ref);
@@ -3005,6 +2986,7 @@ static void fsg_common_release(struct kref *ref)
3005 if (common->state != FSG_STATE_TERMINATED) { 2986 if (common->state != FSG_STATE_TERMINATED) {
3006 raise_exception(common, FSG_STATE_EXIT); 2987 raise_exception(common, FSG_STATE_EXIT);
3007 wait_for_completion(&common->thread_notifier); 2988 wait_for_completion(&common->thread_notifier);
2989 common->thread_task = NULL;
3008 } 2990 }
3009 2991
3010 for (i = 0; i < ARRAY_SIZE(common->luns); ++i) { 2992 for (i = 0; i < ARRAY_SIZE(common->luns); ++i) {
@@ -3050,9 +3032,21 @@ static int fsg_bind(struct usb_configuration *c, struct usb_function *f)
3050 if (ret) 3032 if (ret)
3051 return ret; 3033 return ret;
3052 fsg_common_set_inquiry_string(fsg->common, NULL, NULL); 3034 fsg_common_set_inquiry_string(fsg->common, NULL, NULL);
3053 ret = fsg_common_run_thread(fsg->common); 3035 }
3054 if (ret) 3036
3037 if (!common->thread_task) {
3038 common->state = FSG_STATE_IDLE;
3039 common->thread_task =
3040 kthread_create(fsg_main_thread, common, "file-storage");
3041 if (IS_ERR(common->thread_task)) {
3042 int ret = PTR_ERR(common->thread_task);
3043 common->thread_task = NULL;
3044 common->state = FSG_STATE_TERMINATED;
3055 return ret; 3045 return ret;
3046 }
3047 DBG(common, "I/O thread pid: %d\n",
3048 task_pid_nr(common->thread_task));
3049 wake_up_process(common->thread_task);
3056 } 3050 }
3057 3051
3058 fsg->gadget = gadget; 3052 fsg->gadget = gadget;