[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>
This commit is contained in:
Arnd Bergmann 2011-03-02 17:15:15 -03:00 committed by Mauro Carvalho Chehab
parent dc46b8c8e3
commit 0cd301f19a
5 changed files with 15 additions and 16 deletions

View File

@ -1,7 +1,6 @@
config VIDEO_CX25821 config VIDEO_CX25821
tristate "Conexant cx25821 support" tristate "Conexant cx25821 support"
depends on DVB_CORE && VIDEO_DEV && PCI && I2C depends on DVB_CORE && VIDEO_DEV && PCI && I2C
depends on BKL # please fix
select I2C_ALGOBIT select I2C_ALGOBIT
select VIDEO_BTCX select VIDEO_BTCX
select VIDEO_TVEEPROM select VIDEO_TVEEPROM

View File

@ -770,10 +770,12 @@ static int cx25821_alsa_init(void)
struct cx25821_dev *dev = NULL; struct cx25821_dev *dev = NULL;
struct list_head *list; struct list_head *list;
mutex_lock(&cx25821_devlist_mutex);
list_for_each(list, &cx25821_devlist) { list_for_each(list, &cx25821_devlist) {
dev = list_entry(list, struct cx25821_dev, devlist); dev = list_entry(list, struct cx25821_dev, devlist);
cx25821_audio_initdev(dev); cx25821_audio_initdev(dev);
} }
mutex_unlock(&cx25821_devlist_mutex);
if (dev == NULL) if (dev == NULL)
pr_info("ERROR ALSA: no cx25821 cards found\n"); pr_info("ERROR ALSA: no cx25821 cards found\n");

View File

@ -33,9 +33,6 @@ MODULE_DESCRIPTION("Driver for Athena cards");
MODULE_AUTHOR("Shu Lin - Hiep Huynh"); MODULE_AUTHOR("Shu Lin - Hiep Huynh");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
struct list_head cx25821_devlist;
EXPORT_SYMBOL(cx25821_devlist);
static unsigned int debug; static unsigned int debug;
module_param(debug, int, 0644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "enable debug messages"); MODULE_PARM_DESC(debug, "enable debug messages");
@ -46,8 +43,10 @@ MODULE_PARM_DESC(card, "card type");
static unsigned int cx25821_devcount; static unsigned int cx25821_devcount;
static DEFINE_MUTEX(devlist); DEFINE_MUTEX(cx25821_devlist_mutex);
EXPORT_SYMBOL(cx25821_devlist_mutex);
LIST_HEAD(cx25821_devlist); LIST_HEAD(cx25821_devlist);
EXPORT_SYMBOL(cx25821_devlist);
struct sram_channel cx25821_sram_channels[] = { struct sram_channel cx25821_sram_channels[] = {
[SRAM_CH00] = { [SRAM_CH00] = {
@ -911,9 +910,9 @@ static int cx25821_dev_setup(struct cx25821_dev *dev)
dev->nr = ++cx25821_devcount; dev->nr = ++cx25821_devcount;
sprintf(dev->name, "cx25821[%d]", dev->nr); sprintf(dev->name, "cx25821[%d]", dev->nr);
mutex_lock(&devlist); mutex_lock(&cx25821_devlist_mutex);
list_add_tail(&dev->devlist, &cx25821_devlist); list_add_tail(&dev->devlist, &cx25821_devlist);
mutex_unlock(&devlist); mutex_unlock(&cx25821_devlist_mutex);
strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown"); strcpy(cx25821_boards[UNKNOWN_BOARD].name, "unknown");
strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821"); strcpy(cx25821_boards[CX25821_BOARD].name, "cx25821");
@ -1465,9 +1464,9 @@ static void __devexit cx25821_finidev(struct pci_dev *pci_dev)
if (pci_dev->irq) if (pci_dev->irq)
free_irq(pci_dev->irq, dev); free_irq(pci_dev->irq, dev);
mutex_lock(&devlist); mutex_lock(&cx25821_devlist_mutex);
list_del(&dev->devlist); list_del(&dev->devlist);
mutex_unlock(&devlist); mutex_unlock(&cx25821_devlist_mutex);
cx25821_dev_unregister(dev); cx25821_dev_unregister(dev);
v4l2_device_unregister(v4l2_dev); v4l2_device_unregister(v4l2_dev);
@ -1501,7 +1500,6 @@ static struct pci_driver cx25821_pci_driver = {
static int __init cx25821_init(void) static int __init cx25821_init(void)
{ {
INIT_LIST_HEAD(&cx25821_devlist);
pr_info("driver version %d.%d.%d loaded\n", pr_info("driver version %d.%d.%d loaded\n",
(CX25821_VERSION_CODE >> 16) & 0xff, (CX25821_VERSION_CODE >> 16) & 0xff,
(CX25821_VERSION_CODE >> 8) & 0xff, (CX25821_VERSION_CODE >> 8) & 0xff,

View File

@ -27,7 +27,6 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "cx25821-video.h" #include "cx25821-video.h"
#include <linux/smp_lock.h>
MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards"); MODULE_DESCRIPTION("v4l2 driver module for cx25821 based TV cards");
MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>"); MODULE_AUTHOR("Hiep Huynh <hiep.huynh@conexant.com>");
@ -815,7 +814,7 @@ static int video_open(struct file *file)
if (NULL == fh) if (NULL == fh)
return -ENOMEM; return -ENOMEM;
lock_kernel(); mutex_lock(&cx25821_devlist_mutex);
list_for_each(list, &cx25821_devlist) list_for_each(list, &cx25821_devlist)
{ {
@ -832,8 +831,8 @@ static int video_open(struct file *file)
} }
if (NULL == dev) { if (NULL == dev) {
unlock_kernel(); mutex_unlock(&cx25821_devlist_mutex);
return -ENODEV; return -ENODEV;
} }
file->private_data = fh; file->private_data = fh;
@ -862,7 +861,7 @@ static int video_open(struct file *file)
sizeof(struct cx25821_buffer), fh, NULL); sizeof(struct cx25821_buffer), fh, NULL);
dprintk(1, "post videobuf_queue_init()\n"); dprintk(1, "post videobuf_queue_init()\n");
unlock_kernel(); mutex_unlock(&cx25821_devlist_mutex);
return 0; return 0;
} }

View File

@ -31,7 +31,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kdev_t.h> #include <linux/kdev_t.h>
#include <linux/smp_lock.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/v4l2-device.h> #include <media/v4l2-device.h>
@ -445,6 +444,8 @@ static inline struct cx25821_dev *get_cx25821(struct v4l2_device *v4l2_dev)
v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args) v4l2_device_call_all(&dev->v4l2_dev, 0, o, f, ##args)
extern struct list_head cx25821_devlist; extern struct list_head cx25821_devlist;
extern struct mutex cx25821_devlist_mutex;
extern struct cx25821_board cx25821_boards[]; extern struct cx25821_board cx25821_boards[];
extern struct cx25821_subid cx25821_subids[]; extern struct cx25821_subid cx25821_subids[];