diff options
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-context.c')
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-context.c | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-context.c b/drivers/media/video/pvrusb2/pvrusb2-context.c index 22719ba861ac..9d94aed2e12d 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-context.c +++ b/drivers/media/video/pvrusb2/pvrusb2-context.c | |||
@@ -31,52 +31,32 @@ | |||
31 | 31 | ||
32 | static void pvr2_context_destroy(struct pvr2_context *mp) | 32 | static void pvr2_context_destroy(struct pvr2_context *mp) |
33 | { | 33 | { |
34 | if (mp->hdw) pvr2_hdw_destroy(mp->hdw); | ||
35 | pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr_main id=%p",mp); | 34 | pvr2_trace(PVR2_TRACE_STRUCT,"Destroying pvr_main id=%p",mp); |
36 | if (mp->workqueue) { | 35 | if (mp->hdw) pvr2_hdw_destroy(mp->hdw); |
37 | flush_workqueue(mp->workqueue); | ||
38 | destroy_workqueue(mp->workqueue); | ||
39 | } | ||
40 | kfree(mp); | 36 | kfree(mp); |
41 | } | 37 | } |
42 | 38 | ||
43 | 39 | ||
44 | static void pvr2_context_trigger_poll(struct pvr2_context *mp) | 40 | static void pvr2_context_state_check(struct pvr2_context *mp) |
45 | { | ||
46 | queue_work(mp->workqueue,&mp->workpoll); | ||
47 | } | ||
48 | |||
49 | |||
50 | static void pvr2_context_poll(struct work_struct *work) | ||
51 | { | ||
52 | struct pvr2_context *mp = | ||
53 | container_of(work, struct pvr2_context, workpoll); | ||
54 | pvr2_context_enter(mp); do { | ||
55 | pvr2_hdw_poll(mp->hdw); | ||
56 | } while (0); pvr2_context_exit(mp); | ||
57 | } | ||
58 | |||
59 | |||
60 | static void pvr2_context_setup(struct work_struct *work) | ||
61 | { | 41 | { |
62 | struct pvr2_context *mp = | 42 | if (mp->init_flag) return; |
63 | container_of(work, struct pvr2_context, workinit); | 43 | |
44 | switch (pvr2_hdw_get_state(mp->hdw)) { | ||
45 | case PVR2_STATE_WARM: break; | ||
46 | case PVR2_STATE_ERROR: break; | ||
47 | case PVR2_STATE_READY: break; | ||
48 | case PVR2_STATE_RUN: break; | ||
49 | default: return; | ||
50 | } | ||
64 | 51 | ||
65 | pvr2_context_enter(mp); do { | 52 | pvr2_context_enter(mp); do { |
66 | if (!pvr2_hdw_dev_ok(mp->hdw)) break; | 53 | mp->init_flag = !0; |
67 | pvr2_hdw_setup(mp->hdw); | ||
68 | pvr2_hdw_setup_poll_trigger( | ||
69 | mp->hdw, | ||
70 | (void (*)(void *))pvr2_context_trigger_poll, | ||
71 | mp); | ||
72 | if (!pvr2_hdw_dev_ok(mp->hdw)) break; | ||
73 | if (!pvr2_hdw_init_ok(mp->hdw)) break; | ||
74 | mp->video_stream.stream = pvr2_hdw_get_video_stream(mp->hdw); | 54 | mp->video_stream.stream = pvr2_hdw_get_video_stream(mp->hdw); |
75 | if (mp->setup_func) { | 55 | if (mp->setup_func) { |
76 | mp->setup_func(mp); | 56 | mp->setup_func(mp); |
77 | } | 57 | } |
78 | } while (0); pvr2_context_exit(mp); | 58 | } while (0); pvr2_context_exit(mp); |
79 | } | 59 | } |
80 | 60 | ||
81 | 61 | ||
82 | struct pvr2_context *pvr2_context_create( | 62 | struct pvr2_context *pvr2_context_create( |
@@ -96,11 +76,10 @@ struct pvr2_context *pvr2_context_create( | |||
96 | mp = NULL; | 76 | mp = NULL; |
97 | goto done; | 77 | goto done; |
98 | } | 78 | } |
99 | 79 | pvr2_hdw_set_state_callback(mp->hdw, | |
100 | mp->workqueue = create_singlethread_workqueue("pvrusb2"); | 80 | (void (*)(void *))pvr2_context_state_check, |
101 | INIT_WORK(&mp->workinit, pvr2_context_setup); | 81 | mp); |
102 | INIT_WORK(&mp->workpoll, pvr2_context_poll); | 82 | pvr2_context_state_check(mp); |
103 | queue_work(mp->workqueue,&mp->workinit); | ||
104 | done: | 83 | done: |
105 | return mp; | 84 | return mp; |
106 | } | 85 | } |