Skip to content

Commit

Permalink
V4L/DVB (10511): saa7134: get rid of KBL
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mauro Carvalho Chehab committed Mar 30, 2009
1 parent 553d3c5 commit befd6e6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
44 changes: 22 additions & 22 deletions drivers/media/video/saa7134/saa7134-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1254,23 +1255,23 @@ 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;
}

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);
Expand Down Expand Up @@ -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 --------------- */
Expand Down
14 changes: 7 additions & 7 deletions drivers/media/video/saa7134/saa7134-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions drivers/media/video/saa7134/saa7134.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit befd6e6

Please sign in to comment.