aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-03-02 15:15:15 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-21 19:32:41 -0400
commit0cd301f19a91b3e1fb4130dcd9106777003ed4ed (patch)
tree5c6f30efc843196c15618a78f68cf22049caf8d5 /drivers
parentdc46b8c8e3d7e6c7c7ddb78fc2137a5462e98679 (diff)
[media] staging/cx25721: serialize access to devlist
Out of the three files accessing the device list, one uses a mutex, one uses the BKL and one does not have any locking. That is of course pointless, so let's make all of them use the same mutex, and get rid of one more BKL user. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Palash Bandyopadhyay <palash.bandyopadhyay@conexant.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/cx25821/Kconfig1
-rw-r--r--drivers/staging/cx25821/cx25821-alsa.c2
-rw-r--r--drivers/staging/cx25821/cx25821-core.c16
-rw-r--r--drivers/staging/cx25821/cx25821-video.c9
-rw-r--r--drivers/staging/cx25821/cx25821.h3
5 files changed, 15 insertions, 16 deletions
diff --git a/drivers/staging/cx25821/Kconfig b/drivers/staging/cx25821/Kconfig
index b2656957aa8..5f6b5421371 100644
--- a/drivers/staging/cx25821/Kconfig
+++ b/drivers/staging/cx25821/Kconfig
@@ -1,7 +1,6 @@
1config VIDEO_CX25821 1config VIDEO_CX25821
2 tristate "Conexant cx25821 support" 2 tristate "Conexant cx25821 support"
3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C 3 depends on DVB_CORE && VIDEO_DEV && PCI && I2C
4 depends on BKL # please fix
5 select I2C_ALGOBIT 4 select I2C_ALGOBIT
6 select VIDEO_BTCX 5 select VIDEO_BTCX
7 select VIDEO_TVEEPROM 6 select VIDEO_TVEEPROM
diff --git a/drivers/staging/cx25821/cx25821-alsa.c b/drivers/staging/cx25821/cx25821-alsa.c
index 160f6693aa3..ebdba7c65bc 100644
--- a/drivers/staging/cx25821/cx25821-alsa.c
+++ b/drivers/staging/cx25821/cx25821-alsa.c
@@ -770,10 +770,12 @@ static int cx25821_alsa_init(void)
770 struct cx25821_dev *dev = NULL; 770 struct cx25821_dev *dev = NULL;
771 struct list_head *list; 771 struct list_head *list;
772 772
773 mutex_lock(&cx25821_devlist_mutex);
773 list_for_each(list, &cx25821_devlist) { 774 list_for_each(list, &cx25821_devlist) {
774 dev = list_entry(list, struct cx25821_dev, devlist); 775 dev = list_entry(list, struct cx25821_dev, devlist);
775 cx25821_audio_initdev(dev); 776 cx25821_audio_initdev(dev);
776 } 777 }
778 mutex_unlock(&cx25821_devlist_mutex);
777 779
778 if (dev == NULL) 780 if (dev == NULL)
779 pr_info("ERROR ALSA: no cx25821 cards found\n"); 781 pr_info("ERROR ALSA: no cx25821 cards found\n");
diff --git a/drivers/staging/cx25821/cx25821-core.c b/drivers/staging/cx25821/cx25821-core.c
index a216b620b71..523ac5e16c1 100644
--- a/drivers/staging/cx25821/cx25821-core.c
+++ b/drivers/staging/cx25821/cx25821-core.c
@@ -33,9 +33,6 @@ MODULE_DESCRIPTION("Driver for Athena cards");
33MODULE_AUTHOR("Shu Lin - Hiep Huynh"); 33MODULE_AUTHOR("Shu Lin - Hiep Huynh");
34MODULE_LICENSE("GPL"); 34MODULE_LICENSE("GPL");
35 35
36struct list_head cx25821_devlist;
37EXPORT_SYMBOL(cx25821_devlist);
38
39static unsigned int debug; 36static unsigned int debug;
40module_param(debug, int, 0644); 37module_param(debug, int, 0644);
41MODULE_PARM_DESC(debug, "enable debug messages"); 38MODULE_PARM_DESC(debug, "enable debug messages");
@@ -46,8 +43,10 @@ MODULE_PARM_DESC(card, "card type");
46 43
47static unsigned int cx25821_devcount; 44static unsigned int cx25821_devcount;
48 45
49static DEFINE_MUTEX(devlist); 46DEFINE_MUTEX(cx25821_devlist_mutex);
47EXPORT_SYMBOL(cx25821_devlist_mutex);
50LIST_HEAD(cx25821_devlist); 48LIST_HEAD(cx25821_devlist);
49EXPORT_SYMBOL(cx25821_devlist);
51 50
52struct sram_channel cx25821_sram_channels[] = { 51struct sram_channel cx25821_sram_channels[] = {
53 [SRAM_CH00] = { 52 [SRAM_CH00] = {
@@ -911,9 +910,9 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
911 dev->nr = ++cx25821_devcount; 910 dev->nr = ++cx25821_devcount;
912 sprintf(dev->name, "cx25821[%d]", dev->nr); 911 sprintf(dev->name, "cx25821[%d]", dev->nr);
913 912
914 mutex_lock(&devlist); 913 mutex_lock(&cx25821_devlist_mutex);
915 list_add_tail(&dev->devlist, &cx25821_devlist); 914 list_add_tail(&dev->devlist, &cx25821_devlist);
916 mutex_unlock(&devlist); 915 mutex_unlock(&cx25821_devlist_mutex);
917 916
918 strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown"); 917 strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown");
919 strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821"); 918 strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821");
@@ -1465,9 +1464,9 @@ static void __devexit cx25821_finidev(struct pci_dev *pci_dev)
1465 if (pci_dev->irq) 1464 if (pci_dev->irq)
1466 free_irq(pci_dev->irq, dev); 1465 free_irq(pci_dev->irq, dev);
1467 1466
1468 mutex_lock(&devlist); 1467 mutex_lock(&cx25821_devlist_mutex);
1469 list_del(&dev->devlist); 1468 list_del(&dev->devlist);
1470 mutex_unlock(&devlist); 1469 mutex_unlock(&cx25821_devlist_mutex);
1471 1470
1472 cx25821_dev_unregister(dev); 1471 cx25821_dev_unregister(dev);
1473 v4l2_device_unregister(v4l2_dev); 1472 v4l2_device_unregister(v4l2_dev);
@@ -1501,7 +1500,6 @@ static struct pci_driver cx25821_pci_driver = {
1501 1500
1502static int __init cx25821_init(void) 1501static int __init cx25821_init(void)
1503{ 1502{
1504 INIT_LIST_HEAD(&cx25821_devlist);
1505 pr_info("driver version %d.%d.%d loaded\n", 1503 pr_info("driver version %d.%d.%d loaded\n",
1506 (CX25821_VERSION_CODE >> 16) & 0xff, 1504 (CX25821_VERSION_CODE >> 16) & 0xff,
1507 (CX25821_VERSION_CODE >> 8) & 0xff, 1505 (CX25821_VERSION_CODE >> 8) & 0xff,
diff --git a/drivers/staging/cx25821/cx25821-video.c b/drivers/staging/cx25821/cx25821-video.c
index 0d8d7567051..ab05392386e 100644
--- a/drivers/staging/cx25821/cx25821-video.c
+++ b/drivers/staging/cx25821/cx25821-video.c
@@ -27,7 +27,6 @@
27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 27#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28 28
29#include "cx25821-video.h" 29#include "cx25821-video.h"
30#include <linux/smp_lock.h>
31 30
32MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); 31MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
33MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>"); 32MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
@@ -815,7 +814,7 @@ static int video_open(struct file *file)
815 if (NULL == fh) 814 if (NULL == fh)
816 return -ENOMEM; 815 return -ENOMEM;
817 816
818 lock_kernel(); 817 mutex_lock(&cx25821_devlist_mutex);
819 818
820 list_for_each(list, &cx25821_devlist) 819 list_for_each(list, &cx25821_devlist)
821 { 820 {
@@ -832,8 +831,8 @@ static int video_open(struct file *file)
832 } 831 }
833 832
834 if (NULL == dev) { 833 if (NULL == dev) {
835 unlock_kernel(); 834 mutex_unlock(&cx25821_devlist_mutex);
836 return -ENODEV; 835 return -ENODEV;
837 } 836 }
838 837
839 file->private_data = fh; 838 file->private_data = fh;
@@ -862,7 +861,7 @@ static int video_open(struct file *file)
862 sizeof(struct cx25821_buffer), fh, NULL); 861 sizeof(struct cx25821_buffer), fh, NULL);
863 862
864 dprintk(1, "post videobuf_queue_init()\n"); 863 dprintk(1, "post videobuf_queue_init()\n");
865 unlock_kernel(); 864 mutex_unlock(&cx25821_devlist_mutex);
866 865
867 return 0; 866 return 0;
868} 867}
diff --git a/drivers/staging/cx25821/cx25821.h b/drivers/staging/cx25821/cx25821.h
index 55115235f7f..6230243e2cc 100644
--- a/drivers/staging/cx25821/cx25821.h
+++ b/drivers/staging/cx25821/cx25821.h
@@ -31,7 +31,6 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/sched.h> 32#include <linux/sched.h>
33#include <linux/kdev_t.h> 33#include <linux/kdev_t.h>
34#include <linux/smp_lock.h>
35 34
36#include <media/v4l2-common.h> 35#include <media/v4l2-common.h>
37#include <media/v4l2-device.h> 36#include <media/v4l2-device.h>
@@ -445,6 +444,8 @@ static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
445 v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args) 444 v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args)
446 445
447extern struct list_head cx25821_devlist; 446extern struct list_head cx25821_devlist;
447extern struct mutex cx25821_devlist_mutex;
448
448extern struct cx25821_board cx25821_boards[]; 449extern struct cx25821_board cx25821_boards[];
449extern struct cx25821_subid cx25821_subids[]; 450extern struct cx25821_subid cx25821_subids[];
450 451