aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-context.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c
index e7a2ed58bde2..a2ce022c515a 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-context.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-context.c
@@ -35,6 +35,9 @@ static struct pvr2_context *pvr2_context_notify_first;
35static struct pvr2_context *pvr2_context_notify_last; 35static struct pvr2_context *pvr2_context_notify_last;
36static DEFINE_MUTEX(pvr2_context_mutex); 36static DEFINE_MUTEX(pvr2_context_mutex);
37static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_sync_data); 37static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_sync_data);
38static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_cleanup_data);
39static int pvr2_context_cleanup_flag;
40static int pvr2_context_cleaned_flag;
38static struct task_struct *pvr2_context_thread_ptr; 41static struct task_struct *pvr2_context_thread_ptr;
39 42
40 43
@@ -153,7 +156,7 @@ static void pvr2_context_check(struct pvr2_context *mp)
153 156
154static int pvr2_context_shutok(void) 157static int pvr2_context_shutok(void)
155{ 158{
156 return kthread_should_stop() && (pvr2_context_exist_first == NULL); 159 return pvr2_context_cleanup_flag && (pvr2_context_exist_first == NULL);
157} 160}
158 161
159 162
@@ -174,6 +177,15 @@ static int pvr2_context_thread_func(void *foo)
174 pvr2_context_shutok())); 177 pvr2_context_shutok()));
175 } while (!pvr2_context_shutok()); 178 } while (!pvr2_context_shutok());
176 179
180 pvr2_context_cleaned_flag = !0;
181 wake_up(&pvr2_context_cleanup_data);
182
183 pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread cleaned up");
184
185 wait_event_interruptible(
186 pvr2_context_sync_data,
187 kthread_should_stop());
188
177 pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread end"); 189 pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread end");
178 190
179 return 0; 191 return 0;
@@ -191,6 +203,11 @@ int pvr2_context_global_init(void)
191 203
192void pvr2_context_global_done(void) 204void pvr2_context_global_done(void)
193{ 205{
206 pvr2_context_cleanup_flag = !0;
207 wake_up(&pvr2_context_sync_data);
208 wait_event_interruptible(
209 pvr2_context_cleanup_data,
210 pvr2_context_cleaned_flag);
194 kthread_stop(pvr2_context_thread_ptr); 211 kthread_stop(pvr2_context_thread_ptr);
195} 212}
196 213