V4L/DVB (10511): saa7134: get rid of KBL
authorMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 9 Feb 2009 15:27:03 +0000 (12:27 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:42:43 +0000 (12:42 -0300)
KBL is not needed on saa7134, so, let's remove it.

However, we should take some care to avoid opening the module while
initializing it. This issue exists with newer udev's that opens a device
as soon as the driver is registered. So, a proper lock is needed on
open.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/saa7134/saa7134-core.c
drivers/media/video/saa7134/saa7134-video.c
drivers/media/video/saa7134/saa7134.h

index 6a1738dccda70865db589556d62cbead81fb1951..ac574452d01e7a6d32f3babc052fe1a60f46e955 100644 (file)
@@ -86,8 +86,10 @@ MODULE_PARM_DESC(radio_nr, "radio device number");
 MODULE_PARM_DESC(tuner,    "tuner type");
 MODULE_PARM_DESC(card,     "card type");
 
-static DEFINE_MUTEX(devlist_lock);
+DEFINE_MUTEX(saa7134_devlist_lock);
+EXPORT_SYMBOL(saa7134_devlist_lock);
 LIST_HEAD(saa7134_devlist);
+EXPORT_SYMBOL(saa7134_devlist);
 static LIST_HEAD(mops_list);
 static unsigned int saa7134_devcount;
 
@@ -991,6 +993,18 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
 
        v4l2_prio_init(&dev->prio);
 
+       mutex_lock(&saa7134_devlist_lock);
+       list_for_each_entry(mops, &mops_list, next)
+               mpeg_ops_attach(mops, dev);
+       list_add_tail(&dev->devlist, &saa7134_devlist);
+       mutex_unlock(&saa7134_devlist_lock);
+
+       /* check for signal */
+       saa7134_irq_video_signalchange(dev);
+
+       if (TUNER_ABSENT != dev->tuner_type)
+               saa_call_all(dev, core, s_standby, 0);
+
        /* register v4l devices */
        if (saa7134_no_overlay > 0)
                printk(KERN_INFO "%s: Overlay support disabled.\n", dev->name);
@@ -1028,21 +1042,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
        /* everything worked */
        saa7134_devcount++;
 
-       mutex_lock(&devlist_lock);
-       list_for_each_entry(mops, &mops_list, next)
-               mpeg_ops_attach(mops, dev);
-       list_add_tail(&dev->devlist,&saa7134_devlist);
-       mutex_unlock(&devlist_lock);
-
-       /* check for signal */
-       saa7134_irq_video_signalchange(dev);
-
-       if (saa7134_dmasound_init && !dev->dmasound.priv_data) {
+       if (saa7134_dmasound_init && !dev->dmasound.priv_data)
                saa7134_dmasound_init(dev);
-       }
-
-       if (TUNER_ABSENT != dev->tuner_type)
-               saa_call_all(dev, core, s_standby, 0);
 
        return 0;
 
@@ -1093,11 +1094,11 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
        saa7134_hwfini(dev);
 
        /* unregister */
-       mutex_lock(&devlist_lock);
+       mutex_lock(&saa7134_devlist_lock);
        list_del(&dev->devlist);
        list_for_each_entry(mops, &mops_list, next)
                mpeg_ops_detach(mops, dev);
-       mutex_unlock(&devlist_lock);
+       mutex_unlock(&saa7134_devlist_lock);
        saa7134_devcount--;
 
        saa7134_i2c_unregister(dev);
@@ -1254,11 +1255,11 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
 {
        struct saa7134_dev *dev;
 
-       mutex_lock(&devlist_lock);
+       mutex_lock(&saa7134_devlist_lock);
        list_for_each_entry(dev, &saa7134_devlist, devlist)
                mpeg_ops_attach(ops, dev);
        list_add_tail(&ops->next,&mops_list);
-       mutex_unlock(&devlist_lock);
+       mutex_unlock(&saa7134_devlist_lock);
        return 0;
 }
 
@@ -1266,11 +1267,11 @@ void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
 {
        struct saa7134_dev *dev;
 
-       mutex_lock(&devlist_lock);
+       mutex_lock(&saa7134_devlist_lock);
        list_del(&ops->next);
        list_for_each_entry(dev, &saa7134_devlist, devlist)
                mpeg_ops_detach(ops, dev);
-       mutex_unlock(&devlist_lock);
+       mutex_unlock(&saa7134_devlist_lock);
 }
 
 EXPORT_SYMBOL(saa7134_ts_register);
@@ -1314,7 +1315,6 @@ module_exit(saa7134_fini);
 /* ----------------------------------------------------------- */
 
 EXPORT_SYMBOL(saa7134_set_gpio);
-EXPORT_SYMBOL(saa7134_devlist);
 EXPORT_SYMBOL(saa7134_boards);
 
 /* ----------------- for the DMA sound modules --------------- */
index adfdb662c5eb6d3da9d1939dc79d5962570b658d..aa7fa1f73a5694a4207d158e6577a38970c01e3c 100644 (file)
@@ -1335,7 +1335,7 @@ static int video_open(struct file *file)
        enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        int radio = 0;
 
-       lock_kernel();
+       mutex_lock(&saa7134_devlist_lock);
        list_for_each_entry(dev, &saa7134_devlist, devlist) {
                if (dev->video_dev && (dev->video_dev->minor == minor))
                        goto found;
@@ -1348,19 +1348,20 @@ static int video_open(struct file *file)
                        goto found;
                }
        }
-       unlock_kernel();
+       mutex_unlock(&saa7134_devlist_lock);
        return -ENODEV;
- found:
+
+found:
+       mutex_unlock(&saa7134_devlist_lock);
 
        dprintk("open minor=%d radio=%d type=%s\n",minor,radio,
                v4l2_type_names[type]);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh),GFP_KERNEL);
-       if (NULL == fh) {
-               unlock_kernel();
+       if (NULL == fh)
                return -ENOMEM;
-       }
+
        file->private_data = fh;
        fh->dev      = dev;
        fh->radio    = radio;
@@ -1393,7 +1394,6 @@ static int video_open(struct file *file)
                /* switch to video/vbi mode */
                video_mux(dev,dev->ctl_input);
        }
-       unlock_kernel();
        return 0;
 }
 
index 157f595c3ed10f8f25a06c23cbe329e1d2ef8e07..4552a4d6f192aef6c7f85f40a228d0d9ed78ec23 100644 (file)
@@ -641,6 +641,7 @@ struct saa7134_dev {
 /* saa7134-core.c                                              */
 
 extern struct list_head  saa7134_devlist;
+extern struct mutex saa7134_devlist_lock;
 extern int saa7134_no_overlay;
 
 void saa7134_track_gpio(struct saa7134_dev *dev, char *msg);