提交 1e4baed3 编写于 作者: I Ingo Molnar 提交者: Mauro Carvalho Chehab

V4L/DVB (3380): Semaphore to mutex conversion on drivers/media

- Semaphore to mutex conversion.
The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: NIngo Molnar <mingo@elte.hu>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 7d83e843
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/mutex.h>
#include "dvbdev.h" #include "dvbdev.h"
static int dvbdev_debug; static int dvbdev_debug;
...@@ -44,7 +44,7 @@ MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off)."); ...@@ -44,7 +44,7 @@ MODULE_PARM_DESC(dvbdev_debug, "Turn on/off device debugging (default:off).");
#define dprintk if (dvbdev_debug) printk #define dprintk if (dvbdev_debug) printk
static LIST_HEAD(dvb_adapter_list); static LIST_HEAD(dvb_adapter_list);
static DECLARE_MUTEX(dvbdev_register_lock); static DEFINE_MUTEX(dvbdev_register_lock);
static const char * const dnames[] = { static const char * const dnames[] = {
"video", "audio", "sec", "frontend", "demux", "dvr", "ca", "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
...@@ -202,11 +202,11 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, ...@@ -202,11 +202,11 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
struct dvb_device *dvbdev; struct dvb_device *dvbdev;
int id; int id;
if (down_interruptible (&dvbdev_register_lock)) if (mutex_lock_interruptible(&dvbdev_register_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
if ((id = dvbdev_get_free_id (adap, type)) < 0) { if ((id = dvbdev_get_free_id (adap, type)) < 0) {
up (&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
*pdvbdev = NULL; *pdvbdev = NULL;
printk ("%s: could get find free device id...\n", __FUNCTION__); printk ("%s: could get find free device id...\n", __FUNCTION__);
return -ENFILE; return -ENFILE;
...@@ -215,11 +215,11 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, ...@@ -215,11 +215,11 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
*pdvbdev = dvbdev = kmalloc(sizeof(struct dvb_device), GFP_KERNEL); *pdvbdev = dvbdev = kmalloc(sizeof(struct dvb_device), GFP_KERNEL);
if (!dvbdev) { if (!dvbdev) {
up(&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return -ENOMEM; return -ENOMEM;
} }
up (&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
memcpy(dvbdev, template, sizeof(struct dvb_device)); memcpy(dvbdev, template, sizeof(struct dvb_device));
dvbdev->type = type; dvbdev->type = type;
...@@ -289,11 +289,11 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu ...@@ -289,11 +289,11 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu
{ {
int num; int num;
if (down_interruptible (&dvbdev_register_lock)) if (mutex_lock_interruptible(&dvbdev_register_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
if ((num = dvbdev_get_free_adapter_num ()) < 0) { if ((num = dvbdev_get_free_adapter_num ()) < 0) {
up (&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return -ENFILE; return -ENFILE;
} }
...@@ -309,7 +309,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu ...@@ -309,7 +309,7 @@ int dvb_register_adapter(struct dvb_adapter *adap, const char *name, struct modu
list_add_tail (&adap->list_head, &dvb_adapter_list); list_add_tail (&adap->list_head, &dvb_adapter_list);
up (&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return num; return num;
} }
...@@ -320,10 +320,10 @@ int dvb_unregister_adapter(struct dvb_adapter *adap) ...@@ -320,10 +320,10 @@ int dvb_unregister_adapter(struct dvb_adapter *adap)
{ {
devfs_remove("dvb/adapter%d", adap->num); devfs_remove("dvb/adapter%d", adap->num);
if (down_interruptible (&dvbdev_register_lock)) if (mutex_lock_interruptible(&dvbdev_register_lock))
return -ERESTARTSYS; return -ERESTARTSYS;
list_del (&adap->list_head); list_del (&adap->list_head);
up (&dvbdev_register_lock); mutex_unlock(&dvbdev_register_lock);
return 0; return 0;
} }
EXPORT_SYMBOL(dvb_unregister_adapter); EXPORT_SYMBOL(dvb_unregister_adapter);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
#include <linux/mutex.h>
#include "cx88.h" #include "cx88.h"
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
...@@ -75,7 +76,7 @@ MODULE_PARM_DESC(nocomb,"disable comb filter"); ...@@ -75,7 +76,7 @@ MODULE_PARM_DESC(nocomb,"disable comb filter");
static unsigned int cx88_devcount; static unsigned int cx88_devcount;
static LIST_HEAD(cx88_devlist); static LIST_HEAD(cx88_devlist);
static DECLARE_MUTEX(devlist); static DEFINE_MUTEX(devlist);
#define NO_SYNC_LINE (-1U) #define NO_SYNC_LINE (-1U)
...@@ -1036,7 +1037,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) ...@@ -1036,7 +1037,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
struct list_head *item; struct list_head *item;
int i; int i;
down(&devlist); mutex_lock(&devlist);
list_for_each(item,&cx88_devlist) { list_for_each(item,&cx88_devlist) {
core = list_entry(item, struct cx88_core, devlist); core = list_entry(item, struct cx88_core, devlist);
if (pci->bus->number != core->pci_bus) if (pci->bus->number != core->pci_bus)
...@@ -1047,7 +1048,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) ...@@ -1047,7 +1048,7 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
if (0 != get_ressources(core,pci)) if (0 != get_ressources(core,pci))
goto fail_unlock; goto fail_unlock;
atomic_inc(&core->refcount); atomic_inc(&core->refcount);
up(&devlist); mutex_unlock(&devlist);
return core; return core;
} }
core = kzalloc(sizeof(*core),GFP_KERNEL); core = kzalloc(sizeof(*core),GFP_KERNEL);
...@@ -1122,13 +1123,13 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci) ...@@ -1122,13 +1123,13 @@ struct cx88_core* cx88_core_get(struct pci_dev *pci)
cx88_card_setup(core); cx88_card_setup(core);
cx88_ir_init(core,pci); cx88_ir_init(core,pci);
up(&devlist); mutex_unlock(&devlist);
return core; return core;
fail_free: fail_free:
kfree(core); kfree(core);
fail_unlock: fail_unlock:
up(&devlist); mutex_unlock(&devlist);
return NULL; return NULL;
} }
...@@ -1140,14 +1141,14 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci) ...@@ -1140,14 +1141,14 @@ void cx88_core_put(struct cx88_core *core, struct pci_dev *pci)
if (!atomic_dec_and_test(&core->refcount)) if (!atomic_dec_and_test(&core->refcount))
return; return;
down(&devlist); mutex_lock(&devlist);
cx88_ir_fini(core); cx88_ir_fini(core);
if (0 == core->i2c_rc) if (0 == core->i2c_rc)
i2c_bit_del_bus(&core->i2c_adap); i2c_bit_del_bus(&core->i2c_adap);
list_del(&core->devlist); list_del(&core->devlist);
iounmap(core->lmmio); iounmap(core->lmmio);
cx88_devcount--; cx88_devcount--;
up(&devlist); mutex_unlock(&devlist);
kfree(core); kfree(core);
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/version.h> #include <linux/version.h>
#include <linux/video_decoder.h> #include <linux/video_decoder.h>
#include <linux/mutex.h>
#include "em28xx.h" #include "em28xx.h"
#include <media/tuner.h> #include <media/tuner.h>
...@@ -191,7 +192,7 @@ static struct v4l2_queryctrl saa711x_qctrl[] = { ...@@ -191,7 +192,7 @@ static struct v4l2_queryctrl saa711x_qctrl[] = {
static struct usb_driver em28xx_usb_driver; static struct usb_driver em28xx_usb_driver;
static DECLARE_MUTEX(em28xx_sysfs_lock); static DEFINE_MUTEX(em28xx_sysfs_lock);
static DECLARE_RWSEM(em28xx_disconnect); static DECLARE_RWSEM(em28xx_disconnect);
/********************* v4l2 interface ******************************************/ /********************* v4l2 interface ******************************************/
...@@ -394,7 +395,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) ...@@ -394,7 +395,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
*/ */
static void em28xx_release_resources(struct em28xx *dev) static void em28xx_release_resources(struct em28xx *dev)
{ {
down(&em28xx_sysfs_lock); mutex_lock(&em28xx_sysfs_lock);
em28xx_info("V4L2 device /dev/video%d deregistered\n", em28xx_info("V4L2 device /dev/video%d deregistered\n",
dev->vdev->minor); dev->vdev->minor);
...@@ -403,7 +404,7 @@ static void em28xx_release_resources(struct em28xx *dev) ...@@ -403,7 +404,7 @@ static void em28xx_release_resources(struct em28xx *dev)
/* video_unregister_device(dev->vbi_dev); */ /* video_unregister_device(dev->vbi_dev); */
em28xx_i2c_unregister(dev); em28xx_i2c_unregister(dev);
usb_put_dev(dev->udev); usb_put_dev(dev->udev);
up(&em28xx_sysfs_lock); mutex_unlock(&em28xx_sysfs_lock);
} }
/* /*
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/sound.h> #include <linux/sound.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/mutex.h>
#include "saa7134-reg.h" #include "saa7134-reg.h"
#include "saa7134.h" #include "saa7134.h"
...@@ -84,7 +85,7 @@ MODULE_PARM_DESC(radio_nr, "radio device number"); ...@@ -84,7 +85,7 @@ MODULE_PARM_DESC(radio_nr, "radio device number");
MODULE_PARM_DESC(tuner, "tuner type"); MODULE_PARM_DESC(tuner, "tuner type");
MODULE_PARM_DESC(card, "card type"); MODULE_PARM_DESC(card, "card type");
static DECLARE_MUTEX(devlist_lock); static DEFINE_MUTEX(devlist_lock);
LIST_HEAD(saa7134_devlist); LIST_HEAD(saa7134_devlist);
static LIST_HEAD(mops_list); static LIST_HEAD(mops_list);
static unsigned int saa7134_devcount; static unsigned int saa7134_devcount;
...@@ -969,13 +970,13 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -969,13 +970,13 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
pci_set_drvdata(pci_dev,dev); pci_set_drvdata(pci_dev,dev);
saa7134_devcount++; saa7134_devcount++;
down(&devlist_lock); mutex_lock(&devlist_lock);
list_for_each(item,&mops_list) { list_for_each(item,&mops_list) {
mops = list_entry(item, struct saa7134_mpeg_ops, next); mops = list_entry(item, struct saa7134_mpeg_ops, next);
mpeg_ops_attach(mops, dev); mpeg_ops_attach(mops, dev);
} }
list_add_tail(&dev->devlist,&saa7134_devlist); list_add_tail(&dev->devlist,&saa7134_devlist);
up(&devlist_lock); mutex_unlock(&devlist_lock);
/* check for signal */ /* check for signal */
saa7134_irq_video_intl(dev); saa7134_irq_video_intl(dev);
...@@ -1031,13 +1032,13 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev) ...@@ -1031,13 +1032,13 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
saa7134_hwfini(dev); saa7134_hwfini(dev);
/* unregister */ /* unregister */
down(&devlist_lock); mutex_lock(&devlist_lock);
list_del(&dev->devlist); list_del(&dev->devlist);
list_for_each(item,&mops_list) { list_for_each(item,&mops_list) {
mops = list_entry(item, struct saa7134_mpeg_ops, next); mops = list_entry(item, struct saa7134_mpeg_ops, next);
mpeg_ops_detach(mops, dev); mpeg_ops_detach(mops, dev);
} }
up(&devlist_lock); mutex_unlock(&devlist_lock);
saa7134_devcount--; saa7134_devcount--;
saa7134_i2c_unregister(dev); saa7134_i2c_unregister(dev);
...@@ -1071,13 +1072,13 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops) ...@@ -1071,13 +1072,13 @@ int saa7134_ts_register(struct saa7134_mpeg_ops *ops)
struct list_head *item; struct list_head *item;
struct saa7134_dev *dev; struct saa7134_dev *dev;
down(&devlist_lock); mutex_lock(&devlist_lock);
list_for_each(item,&saa7134_devlist) { list_for_each(item,&saa7134_devlist) {
dev = list_entry(item, struct saa7134_dev, devlist); dev = list_entry(item, struct saa7134_dev, devlist);
mpeg_ops_attach(ops, dev); mpeg_ops_attach(ops, dev);
} }
list_add_tail(&ops->next,&mops_list); list_add_tail(&ops->next,&mops_list);
up(&devlist_lock); mutex_unlock(&devlist_lock);
return 0; return 0;
} }
...@@ -1086,13 +1087,13 @@ void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops) ...@@ -1086,13 +1087,13 @@ void saa7134_ts_unregister(struct saa7134_mpeg_ops *ops)
struct list_head *item; struct list_head *item;
struct saa7134_dev *dev; struct saa7134_dev *dev;
down(&devlist_lock); mutex_lock(&devlist_lock);
list_del(&ops->next); list_del(&ops->next);
list_for_each(item,&saa7134_devlist) { list_for_each(item,&saa7134_devlist) {
dev = list_entry(item, struct saa7134_dev, devlist); dev = list_entry(item, struct saa7134_dev, devlist);
mpeg_ops_detach(ops, dev); mpeg_ops_detach(ops, dev);
} }
up(&devlist_lock); mutex_unlock(&devlist_lock);
} }
EXPORT_SYMBOL(saa7134_ts_register); EXPORT_SYMBOL(saa7134_ts_register);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include <linux/devfs_fs_kernel.h> #include <linux/devfs_fs_kernel.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/semaphore.h>
#include <linux/videodev.h> #include <linux/videodev.h>
...@@ -83,7 +82,7 @@ static struct class video_class = { ...@@ -83,7 +82,7 @@ static struct class video_class = {
*/ */
static struct video_device *video_device[VIDEO_NUM_DEVICES]; static struct video_device *video_device[VIDEO_NUM_DEVICES];
static DECLARE_MUTEX(videodev_lock); static DEFINE_MUTEX(videodev_lock);
struct video_device* video_devdata(struct file *file) struct video_device* video_devdata(struct file *file)
{ {
...@@ -102,15 +101,15 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -102,15 +101,15 @@ static int video_open(struct inode *inode, struct file *file)
if(minor>=VIDEO_NUM_DEVICES) if(minor>=VIDEO_NUM_DEVICES)
return -ENODEV; return -ENODEV;
down(&videodev_lock); mutex_lock(&videodev_lock);
vfl=video_device[minor]; vfl=video_device[minor];
if(vfl==NULL) { if(vfl==NULL) {
up(&videodev_lock); mutex_unlock(&videodev_lock);
request_module("char-major-%d-%d", VIDEO_MAJOR, minor); request_module("char-major-%d-%d", VIDEO_MAJOR, minor);
down(&videodev_lock); mutex_lock(&videodev_lock);
vfl=video_device[minor]; vfl=video_device[minor];
if (vfl==NULL) { if (vfl==NULL) {
up(&videodev_lock); mutex_unlock(&videodev_lock);
return -ENODEV; return -ENODEV;
} }
} }
...@@ -123,7 +122,7 @@ static int video_open(struct inode *inode, struct file *file) ...@@ -123,7 +122,7 @@ static int video_open(struct inode *inode, struct file *file)
file->f_op = fops_get(old_fops); file->f_op = fops_get(old_fops);
} }
fops_put(old_fops); fops_put(old_fops);
up(&videodev_lock); mutex_unlock(&videodev_lock);
return err; return err;
} }
...@@ -304,12 +303,12 @@ int video_register_device(struct video_device *vfd, int type, int nr) ...@@ -304,12 +303,12 @@ int video_register_device(struct video_device *vfd, int type, int nr)
} }
/* pick a minor number */ /* pick a minor number */
down(&videodev_lock); mutex_lock(&videodev_lock);
if (nr >= 0 && nr < end-base) { if (nr >= 0 && nr < end-base) {
/* use the one the driver asked for */ /* use the one the driver asked for */
i = base+nr; i = base+nr;
if (NULL != video_device[i]) { if (NULL != video_device[i]) {
up(&videodev_lock); mutex_unlock(&videodev_lock);
return -ENFILE; return -ENFILE;
} }
} else { } else {
...@@ -318,13 +317,13 @@ int video_register_device(struct video_device *vfd, int type, int nr) ...@@ -318,13 +317,13 @@ int video_register_device(struct video_device *vfd, int type, int nr)
if (NULL == video_device[i]) if (NULL == video_device[i])
break; break;
if (i == end) { if (i == end) {
up(&videodev_lock); mutex_unlock(&videodev_lock);
return -ENFILE; return -ENFILE;
} }
} }
video_device[i]=vfd; video_device[i]=vfd;
vfd->minor=i; vfd->minor=i;
up(&videodev_lock); mutex_unlock(&videodev_lock);
sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base); sprintf(vfd->devfs_name, "v4l/%s%d", name_base, i - base);
devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor), devfs_mk_cdev(MKDEV(VIDEO_MAJOR, vfd->minor),
...@@ -362,14 +361,14 @@ int video_register_device(struct video_device *vfd, int type, int nr) ...@@ -362,14 +361,14 @@ int video_register_device(struct video_device *vfd, int type, int nr)
void video_unregister_device(struct video_device *vfd) void video_unregister_device(struct video_device *vfd)
{ {
down(&videodev_lock); mutex_lock(&videodev_lock);
if(video_device[vfd->minor]!=vfd) if(video_device[vfd->minor]!=vfd)
panic("videodev: bad unregister"); panic("videodev: bad unregister");
devfs_remove(vfd->devfs_name); devfs_remove(vfd->devfs_name);
video_device[vfd->minor]=NULL; video_device[vfd->minor]=NULL;
class_device_unregister(&vfd->class_dev); class_device_unregister(&vfd->class_dev);
up(&videodev_lock); mutex_unlock(&videodev_lock);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册