From a46229cd414de165cbcbe8cabee919c8f78a0297 Mon Sep 17 00:00:00 2001 From: Mike Isely Date: Wed, 9 Apr 2008 05:14:11 -0300 Subject: [PATCH] --- yaml --- r: 92786 b: refs/heads/master c: 18ecbb4771eb0ecf297e996966b3c42f69cd6c02 h: refs/heads/master v: v3 --- [refs] | 2 +- .../media/video/pvrusb2/pvrusb2-context.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 0dc19ec404fd..b3f4c5087227 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 13e027a8bf2a507334fa0d30246ce619ff581cbb +refs/heads/master: 18ecbb4771eb0ecf297e996966b3c42f69cd6c02 diff --git a/trunk/drivers/media/video/pvrusb2/pvrusb2-context.c b/trunk/drivers/media/video/pvrusb2/pvrusb2-context.c index e7a2ed58bde2..a2ce022c515a 100644 --- a/trunk/drivers/media/video/pvrusb2/pvrusb2-context.c +++ b/trunk/drivers/media/video/pvrusb2/pvrusb2-context.c @@ -35,6 +35,9 @@ static struct pvr2_context *pvr2_context_notify_first; static struct pvr2_context *pvr2_context_notify_last; static DEFINE_MUTEX(pvr2_context_mutex); static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_sync_data); +static DECLARE_WAIT_QUEUE_HEAD(pvr2_context_cleanup_data); +static int pvr2_context_cleanup_flag; +static int pvr2_context_cleaned_flag; static struct task_struct *pvr2_context_thread_ptr; @@ -153,7 +156,7 @@ static void pvr2_context_check(struct pvr2_context *mp) static int pvr2_context_shutok(void) { - return kthread_should_stop() && (pvr2_context_exist_first == NULL); + return pvr2_context_cleanup_flag && (pvr2_context_exist_first == NULL); } @@ -174,6 +177,15 @@ static int pvr2_context_thread_func(void *foo) pvr2_context_shutok())); } while (!pvr2_context_shutok()); + pvr2_context_cleaned_flag = !0; + wake_up(&pvr2_context_cleanup_data); + + pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread cleaned up"); + + wait_event_interruptible( + pvr2_context_sync_data, + kthread_should_stop()); + pvr2_trace(PVR2_TRACE_CTXT,"pvr2_context thread end"); return 0; @@ -191,6 +203,11 @@ int pvr2_context_global_init(void) void pvr2_context_global_done(void) { + pvr2_context_cleanup_flag = !0; + wake_up(&pvr2_context_sync_data); + wait_event_interruptible( + pvr2_context_cleanup_data, + pvr2_context_cleaned_flag); kthread_stop(pvr2_context_thread_ptr); }