summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/pvrusb2
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2008-02-09 09:44:30 -0600
committerMike Isely <isely@pobox.com>2008-02-09 09:44:30 -0600
commitbcb7a4b2043e2028c86e25326af40f548e4b1c92 (patch)
tree639a6f8d8f9094cb1f7d18fcbd98570364c88851 /linux/drivers/media/video/pvrusb2
parent10e10ee41aa6117110610fe07f55711b6576a9cd (diff)
downloadmediapointer-dvb-s2-bcb7a4b2043e2028c86e25326af40f548e4b1c92.tar.gz
mediapointer-dvb-s2-bcb7a4b2043e2028c86e25326af40f548e4b1c92.tar.bz2
pvrusb2-dvb: Rework module tear-down
From: Mike Isely <isely@pobox.com> 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>
Diffstat (limited to 'linux/drivers/media/video/pvrusb2')
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-dvb.c31
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-dvb.h2
-rw-r--r--linux/drivers/media/video/pvrusb2/pvrusb2-main.c3
3 files changed, 19 insertions, 17 deletions
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.c b/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.c
index 1aec13900..a12b5a1ba 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.c
@@ -404,30 +404,37 @@ static int pvr2_dvb_frontend_exit(struct pvr2_dvb_adapter *adap)
return 0;
}
+static void pvr2_dvb_done(struct pvr2_dvb_adapter *adap)
+{
+ pvr2_dvb_stream_end(adap);
+ pvr2_dvb_frontend_exit(adap);
+ pvr2_dvb_adapter_exit(adap);
+ pvr2_channel_done(&adap->channel);
+}
+
+static void pvr2_dvb_internal_check(struct pvr2_channel *chp)
+{
+ struct pvr2_dvb_adapter *adap;
+ adap = container_of(chp, struct pvr2_dvb_adapter, channel);
+ if (!adap->channel.mc_head->disconnect_flag) return;
+ pvr2_dvb_done(adap);
+}
+
int pvr2_dvb_init(struct pvr2_context *pvr)
{
int ret = 0;
struct pvr2_dvb_adapter *adap;
adap = &pvr->hdw->dvb;
- adap->init = !0;
pvr2_channel_init(&adap->channel, pvr);
+ adap->channel.check_func = pvr2_dvb_internal_check;
init_waitqueue_head(&adap->buffer_wait_data);
mutex_init(&pvr->hdw->dvb.lock);
ret = pvr2_dvb_adapter_init(&pvr->hdw->dvb);
if (ret < 0) goto fail;
ret = pvr2_dvb_frontend_init(&pvr->hdw->dvb);
+ return ret;
fail:
+ pvr2_channel_done(&adap->channel);
return ret;
}
-int pvr2_dvb_exit(struct pvr2_context *pvr)
-{
- struct pvr2_dvb_adapter *adap;
- adap = &pvr->hdw->dvb;
- if (!adap->init) return 0;
- pvr2_dvb_stream_end(adap);
- pvr2_dvb_frontend_exit(adap);
- pvr2_dvb_adapter_exit(adap);
- pvr2_channel_done(&adap->channel);
- return 0;
-}
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.h b/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.h
index 4787a2e5e..effa2f46c 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.h
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-dvb.h
@@ -31,7 +31,6 @@ struct pvr2_dvb_adapter {
unsigned int digital_up:1;
unsigned int stream_run:1;
- unsigned int init:1;
wait_queue_head_t buffer_wait_data;
char *buffer_storage[PVR2_DVB_BUFFER_COUNT];
@@ -43,7 +42,6 @@ struct pvr2_dvb_props {
};
int pvr2_dvb_init(struct pvr2_context *pvr);
-int pvr2_dvb_exit(struct pvr2_context *pvr);
#endif /* __PVRUSB2_DVB_H__ */
diff --git a/linux/drivers/media/video/pvrusb2/pvrusb2-main.c b/linux/drivers/media/video/pvrusb2/pvrusb2-main.c
index 8598ce3ef..94ff261f8 100644
--- a/linux/drivers/media/video/pvrusb2/pvrusb2-main.c
+++ b/linux/drivers/media/video/pvrusb2/pvrusb2-main.c
@@ -100,9 +100,6 @@ static void pvr_disconnect(struct usb_interface *intf)
pvr2_trace(PVR2_TRACE_INIT,"pvr_disconnect(pvr=%p) BEGIN",pvr);
-#ifdef CONFIG_VIDEO_PVRUSB2_DVB
- pvr2_dvb_exit(pvr);
-#endif
usb_set_intfdata (intf, NULL);
pvr2_context_disconnect(pvr);