aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/pvrusb2/pvrusb2-dvb.c
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2008-02-09 13:44:30 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 13:09:46 -0400
commit891d99efc5be16d2762bdbb9d0486f7250990eee (patch)
tree42bf20210b0c44a43943b90acb8edae50f7ce4e2 /drivers/media/video/pvrusb2/pvrusb2-dvb.c
parenta36416d0a70899d3724d2e69e378062e06252a41 (diff)
V4L/DVB (7689): pvrusb2-dvb: Rework module tear-down
Rather than making an explicit call to tear down the pvrusb2-dvb module, use the callback in the pvr2_channel structure. This has the advantage that now tear-down only happens when it makes sense. The previous implementation had scenarios where it was possible for the tear-down call to happen without a prior initialization. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/pvrusb2/pvrusb2-dvb.c')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-dvb.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/drivers/media/video/pvrusb2/pvrusb2-dvb.c
index ab608412b41e..38077b2c5282 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-dvb.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-dvb.c
@@ -386,30 +386,37 @@ static int pvr2_dvb_frontend_exit(struct pvr2_dvb_adapter *adap)
386 return 0; 386 return 0;
387} 387}
388 388
389static void pvr2_dvb_done(struct pvr2_dvb_adapter *adap)
390{
391 pvr2_dvb_stream_end(adap);
392 pvr2_dvb_frontend_exit(adap);
393 pvr2_dvb_adapter_exit(adap);
394 pvr2_channel_done(&adap->channel);
395}
396
397static void pvr2_dvb_internal_check(struct pvr2_channel *chp)
398{
399 struct pvr2_dvb_adapter *adap;
400 adap = container_of(chp, struct pvr2_dvb_adapter, channel);
401 if (!adap->channel.mc_head->disconnect_flag) return;
402 pvr2_dvb_done(adap);
403}
404
389int pvr2_dvb_init(struct pvr2_context *pvr) 405int pvr2_dvb_init(struct pvr2_context *pvr)
390{ 406{
391 int ret = 0; 407 int ret = 0;
392 struct pvr2_dvb_adapter *adap; 408 struct pvr2_dvb_adapter *adap;
393 adap = &pvr->hdw->dvb; 409 adap = &pvr->hdw->dvb;
394 adap->init = !0;
395 pvr2_channel_init(&adap->channel, pvr); 410 pvr2_channel_init(&adap->channel, pvr);
411 adap->channel.check_func = pvr2_dvb_internal_check;
396 init_waitqueue_head(&adap->buffer_wait_data); 412 init_waitqueue_head(&adap->buffer_wait_data);
397 mutex_init(&pvr->hdw->dvb.lock); 413 mutex_init(&pvr->hdw->dvb.lock);
398 ret = pvr2_dvb_adapter_init(&pvr->hdw->dvb); 414 ret = pvr2_dvb_adapter_init(&pvr->hdw->dvb);
399 if (ret < 0) goto fail; 415 if (ret < 0) goto fail;
400 ret = pvr2_dvb_frontend_init(&pvr->hdw->dvb); 416 ret = pvr2_dvb_frontend_init(&pvr->hdw->dvb);
417 return ret;
401fail: 418fail:
419 pvr2_channel_done(&adap->channel);
402 return ret; 420 return ret;
403} 421}
404 422
405int pvr2_dvb_exit(struct pvr2_context *pvr)
406{
407 struct pvr2_dvb_adapter *adap;
408 adap = &pvr->hdw->dvb;
409 if (!adap->init) return 0;
410 pvr2_dvb_stream_end(adap);
411 pvr2_dvb_frontend_exit(adap);
412 pvr2_dvb_adapter_exit(adap);
413 pvr2_channel_done(&adap->channel);
414 return 0;
415}