V4L/DVB (7711): pvrusb2: Fix race on module unload
[deliverable/linux.git] / drivers / media / video / pvrusb2 / pvrusb2-main.c
index ca9e2789c8ca58d5c00988cb56158a4cbffb519b..332aced8a5a1f04d182c19acbe600f474900ff4c 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/videodev2.h>
 
 #include "pvrusb2-hdw.h"
+#include "pvrusb2-devattr.h"
 #include "pvrusb2-context.h"
 #include "pvrusb2-debug.h"
 #include "pvrusb2-v4l2.h"
@@ -59,6 +60,10 @@ static void pvr_setup_attach(struct pvr2_context *pvr)
 {
        /* Create association with v4l layer */
        pvr2_v4l2_create(pvr);
+#ifdef CONFIG_VIDEO_PVRUSB2_DVB
+       /* Create association with dvb layer */
+       pvr2_dvb_create(pvr);
+#endif
 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
        pvr2_sysfs_create(pvr,class_ptr);
 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
@@ -120,6 +125,12 @@ static int __init pvr_init(void)
 
        pvr2_trace(PVR2_TRACE_INIT,"pvr_init");
 
+       ret = pvr2_context_global_init();
+       if (ret != 0) {
+               pvr2_trace(PVR2_TRACE_INIT,"pvr_init failure code=%d",ret);
+               return ret;
+       }
+
 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
        class_ptr = pvr2_sysfs_class_create();
 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
@@ -131,29 +142,29 @@ static int __init pvr_init(void)
        if (pvrusb2_debug) info("Debug mask is %d (0x%x)",
                                pvrusb2_debug,pvrusb2_debug);
 
+       pvr2_trace(PVR2_TRACE_INIT,"pvr_init complete");
+
        return ret;
 }
 
 static void __exit pvr_exit(void)
 {
-
        pvr2_trace(PVR2_TRACE_INIT,"pvr_exit");
 
+       usb_deregister(&pvr_driver);
+
 #ifdef CONFIG_VIDEO_PVRUSB2_SYSFS
        pvr2_sysfs_class_destroy(class_ptr);
 #endif /* CONFIG_VIDEO_PVRUSB2_SYSFS */
 
-       usb_deregister(&pvr_driver);
+       pvr2_context_global_done();
+
+       pvr2_trace(PVR2_TRACE_INIT,"pvr_exit complete");
 }
 
 module_init(pvr_init);
 module_exit(pvr_exit);
 
-/* Mike Isely <mcisely@pobox.com> 11-Mar-2006: See pvrusb2-hdw.c for
-   MODULE_DEVICE_TABLE().  We have to declare that attribute there
-   because that's where the device table actually is now and it seems
-   that certain gcc configurations get angry if MODULE_DEVICE_TABLE()
-   is used on what ends up being an external symbol. */
 MODULE_AUTHOR(DRIVER_AUTHOR);
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
This page took 0.02415 seconds and 5 git commands to generate.