]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (7689): pvrusb2-dvb: Rework module tear-down
authorMike Isely <isely@pobox.com>
Sat, 9 Feb 2008 18:44:30 +0000 (15:44 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Thu, 24 Apr 2008 17:09:46 +0000 (14:09 -0300)
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>
drivers/media/video/pvrusb2/pvrusb2-dvb.c
drivers/media/video/pvrusb2/pvrusb2-dvb.h
drivers/media/video/pvrusb2/pvrusb2-main.c

index ab608412b41e4884140e08ae85b1715f2f7a55d3..38077b2c52829f0deab11d2be0f7f5bfbaa5ed62 100644 (file)
@@ -386,30 +386,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;
-}
index 651324ffab3dd6122f580310da9738b871b2cb2b..1326f6f455a6b4ff59f6db589aa124f15e8f98f6 100644 (file)
@@ -27,7 +27,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];
@@ -39,6 +38,5 @@ struct pvr2_dvb_props {
 };
 
 int pvr2_dvb_init(struct pvr2_context *pvr);
-int pvr2_dvb_exit(struct pvr2_context *pvr);
 
 #endif /* __PVRUSB2_DVB_H__ */
index 68f4a748073702862283433add49e8ce3b766c52..42b4c8d5a1ed7525adb1750cbeffd22051c2e802 100644 (file)
@@ -99,9 +99,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);