Skip to content

Commit

Permalink
V4L/DVB (3318b): sem2mutex: drivers/media/, #2
Browse files Browse the repository at this point in the history
Semaphore to mutex conversion.

The conversion was generated via scripts, and the result was validated
automatically via a script as well.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Ingo Molnar authored and Mauro Carvalho Chehab committed Feb 7, 2006
1 parent 538f963 commit 3593cab
Show file tree
Hide file tree
Showing 79 changed files with 749 additions and 718 deletions.
6 changes: 3 additions & 3 deletions drivers/media/common/saa7146_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <media/saa7146.h>

LIST_HEAD(saa7146_devices);
DECLARE_MUTEX(saa7146_devices_lock);
DEFINE_MUTEX(saa7146_devices_lock);

static int saa7146_num;

Expand Down Expand Up @@ -402,11 +402,11 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent

pci_set_drvdata(pci, dev);

init_MUTEX(&dev->lock);
mutex_init(&dev->lock);
spin_lock_init(&dev->int_slock);
spin_lock_init(&dev->slock);

init_MUTEX(&dev->i2c_lock);
mutex_init(&dev->i2c_lock);

dev->module = THIS_MODULE;
init_waitqueue_head(&dev->i2c_wq);
Expand Down
18 changes: 9 additions & 9 deletions drivers/media/common/saa7146_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ int saa7146_res_get(struct saa7146_fh *fh, unsigned int bit)
}

/* is it free? */
down(&dev->lock);
mutex_lock(&dev->lock);
if (vv->resources & bit) {
DEB_D(("locked! vv->resources:0x%02x, we want:0x%02x\n",vv->resources,bit));
/* no, someone else uses it */
up(&dev->lock);
mutex_unlock(&dev->lock);
return 0;
}
/* it's free, grab it */
fh->resources |= bit;
vv->resources |= bit;
DEB_D(("res: get 0x%02x, cur:0x%02x\n",bit,vv->resources));
up(&dev->lock);
mutex_unlock(&dev->lock);
return 1;
}

Expand All @@ -40,11 +40,11 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
if ((fh->resources & bits) != bits)
BUG();

down(&dev->lock);
mutex_lock(&dev->lock);
fh->resources &= ~bits;
vv->resources &= ~bits;
DEB_D(("res: put 0x%02x, cur:0x%02x\n",bits,vv->resources));
up(&dev->lock);
mutex_unlock(&dev->lock);
}


Expand Down Expand Up @@ -204,7 +204,7 @@ static int fops_open(struct inode *inode, struct file *file)

DEB_EE(("inode:%p, file:%p, minor:%d\n",inode,file,minor));

if (down_interruptible(&saa7146_devices_lock))
if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;

list_for_each(list,&saa7146_devices) {
Expand Down Expand Up @@ -276,7 +276,7 @@ static int fops_open(struct inode *inode, struct file *file)
kfree(fh);
file->private_data = NULL;
}
up(&saa7146_devices_lock);
mutex_unlock(&saa7146_devices_lock);
return result;
}

Expand All @@ -287,7 +287,7 @@ static int fops_release(struct inode *inode, struct file *file)

DEB_EE(("inode:%p, file:%p\n",inode,file));

if (down_interruptible(&saa7146_devices_lock))
if (mutex_lock_interruptible(&saa7146_devices_lock))
return -ERESTARTSYS;

if( fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) {
Expand All @@ -303,7 +303,7 @@ static int fops_release(struct inode *inode, struct file *file)
file->private_data = NULL;
kfree(fh);

up(&saa7146_devices_lock);
mutex_unlock(&saa7146_devices_lock);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/common/saa7146_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
int address_err = 0;
int short_delay = 0;

if (down_interruptible (&dev->i2c_lock))
if (mutex_lock_interruptible(&dev->i2c_lock))
return -ERESTARTSYS;

for(i=0;i<num;i++) {
Expand Down Expand Up @@ -366,7 +366,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
}
}

up(&dev->i2c_lock);
mutex_unlock(&dev->i2c_lock);
return err;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/common/saa7146_vbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ static int vbi_open(struct saa7146_dev *dev, struct file *file)
V4L2_FIELD_SEQ_TB, // FIXME: does this really work?
sizeof(struct saa7146_buf),
file);
init_MUTEX(&fh->vbi_q.lock);
mutex_init(&fh->vbi_q.lock);

init_timer(&fh->vbi_read_timeout);
fh->vbi_read_timeout.function = vbi_read_timeout;
Expand Down
30 changes: 15 additions & 15 deletions drivers/media/common/saa7146_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ static int s_fmt(struct saa7146_fh *fh, struct v4l2_format *f)
err = try_win(dev,&f->fmt.win);
if (0 != err)
return err;
down(&dev->lock);
mutex_lock(&dev->lock);
fh->ov.win = f->fmt.win;
fh->ov.nclips = f->fmt.win.clipcount;
if (fh->ov.nclips > 16)
fh->ov.nclips = 16;
if (copy_from_user(fh->ov.clips,f->fmt.win.clips,sizeof(struct v4l2_clip)*fh->ov.nclips)) {
up(&dev->lock);
mutex_unlock(&dev->lock);
return -EFAULT;
}

/* fh->ov.fh is used to indicate that we have valid overlay informations, too */
fh->ov.fh = fh;

up(&dev->lock);
mutex_unlock(&dev->lock);

/* check if our current overlay is active */
if (IS_OVERLAY_ACTIVE(fh) != 0) {
Expand Down Expand Up @@ -516,7 +516,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
return -EINVAL;
}

down(&dev->lock);
mutex_lock(&dev->lock);

switch (ctrl->type) {
case V4L2_CTRL_TYPE_BOOLEAN:
Expand Down Expand Up @@ -560,15 +560,15 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
/* fixme: we can support changing VFLIP and HFLIP here... */
if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("V4L2_CID_HFLIP while active capture.\n"));
up(&dev->lock);
mutex_unlock(&dev->lock);
return -EINVAL;
}
vv->hflip = c->value;
break;
case V4L2_CID_VFLIP:
if (IS_CAPTURE_ACTIVE(fh) != 0) {
DEB_D(("V4L2_CID_VFLIP while active capture.\n"));
up(&dev->lock);
mutex_unlock(&dev->lock);
return -EINVAL;
}
vv->vflip = c->value;
Expand All @@ -577,7 +577,7 @@ static int set_control(struct saa7146_fh *fh, struct v4l2_control *c)
return -EINVAL;
}
}
up(&dev->lock);
mutex_unlock(&dev->lock);

if (IS_OVERLAY_ACTIVE(fh) != 0) {
saa7146_stop_preview(fh);
Expand Down Expand Up @@ -939,7 +939,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
}
}

down(&dev->lock);
mutex_lock(&dev->lock);

/* ok, accept it */
vv->ov_fb = *fb;
Expand All @@ -948,7 +948,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
vv->ov_fb.fmt.bytesperline =
vv->ov_fb.fmt.width*fmt->depth/8;

up(&dev->lock);
mutex_unlock(&dev->lock);

return 0;
}
Expand Down Expand Up @@ -1086,7 +1086,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
}
}

down(&dev->lock);
mutex_lock(&dev->lock);

for(i = 0; i < dev->ext_vv_data->num_stds; i++)
if (*id & dev->ext_vv_data->stds[i].id)
Expand All @@ -1098,7 +1098,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
found = 1;
}

up(&dev->lock);
mutex_unlock(&dev->lock);

if (vv->ov_suspend != NULL) {
saa7146_start_preview(vv->ov_suspend);
Expand Down Expand Up @@ -1201,19 +1201,19 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
DEB_D(("VIDIOCGMBUF \n"));

q = &fh->video_q;
down(&q->lock);
mutex_lock(&q->lock);
err = videobuf_mmap_setup(q,gbuffers,gbufsize,
V4L2_MEMORY_MMAP);
if (err < 0) {
up(&q->lock);
mutex_unlock(&q->lock);
return err;
}
memset(mbuf,0,sizeof(*mbuf));
mbuf->frames = gbuffers;
mbuf->size = gbuffers * gbufsize;
for (i = 0; i < gbuffers; i++)
mbuf->offsets[i] = i * gbufsize;
up(&q->lock);
mutex_unlock(&q->lock);
return 0;
}
default:
Expand Down Expand Up @@ -1414,7 +1414,7 @@ static int video_open(struct saa7146_dev *dev, struct file *file)
sizeof(struct saa7146_buf),
file);

init_MUTEX(&fh->video_q.lock);
mutex_init(&fh->video_q.lock);

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/b2c2/flexcop-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <linux/config.h>
#include <linux/pci.h>
#include <linux/mutex.h>

#include "flexcop-reg.h"

Expand Down Expand Up @@ -73,8 +74,7 @@ struct flexcop_device {
int (*fe_sleep) (struct dvb_frontend *);

struct i2c_adapter i2c_adap;
struct semaphore i2c_sem;

struct mutex i2c_mutex;
struct module *owner;

/* options and status */
Expand Down
6 changes: 3 additions & 3 deletions drivers/media/dvb/b2c2/flexcop-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
struct flexcop_device *fc = i2c_get_adapdata(i2c_adap);
int i, ret = 0;

if (down_interruptible(&fc->i2c_sem))
if (mutex_lock_interruptible(&fc->i2c_mutex))
return -ERESTARTSYS;

/* reading */
Expand All @@ -161,7 +161,7 @@ static int flexcop_master_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msgs
else
ret = num;

up(&fc->i2c_sem);
mutex_unlock(&fc->i2c_mutex);

return ret;
}
Expand All @@ -180,7 +180,7 @@ int flexcop_i2c_init(struct flexcop_device *fc)
{
int ret;

sema_init(&fc->i2c_sem,1);
mutex_init(&fc->i2c_mutex);

memset(&fc->i2c_adap, 0, sizeof(struct i2c_adapter));
strncpy(fc->i2c_adap.name, "B2C2 FlexCop device",I2C_NAME_SIZE);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/dvb/bt8xx/bt878.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
int retval;

retval = 0;
if (down_interruptible (&bt->gpio_lock))
if (mutex_lock_interruptible(&bt->gpio_lock))
return -ERESTARTSYS;
/* special gpio signal */
switch (cmd) {
Expand Down Expand Up @@ -375,7 +375,7 @@ bt878_device_control(struct bt878 *bt, unsigned int cmd, union dst_gpio_packet *
retval = -EINVAL;
break;
}
up(&bt->gpio_lock);
mutex_unlock(&bt->gpio_lock);
return retval;
}

Expand Down
4 changes: 3 additions & 1 deletion drivers/media/dvb/bt8xx/bt878.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <linux/pci.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>

#include "bt848.h"
#include "bttv.h"

Expand Down Expand Up @@ -108,7 +110,7 @@ struct cards {
extern int bt878_num;

struct bt878 {
struct semaphore gpio_lock;
struct mutex gpio_lock;
unsigned int nr;
unsigned int bttv_nr;
struct i2c_adapter *adapter;
Expand Down
14 changes: 7 additions & 7 deletions drivers/media/dvb/bt8xx/dst.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,7 @@ static int dst_get_device_id(struct dst_state *state)

static int dst_probe(struct dst_state *state)
{
sema_init(&state->dst_mutex, 1);
mutex_init(&state->dst_mutex);
if ((rdc_8820_reset(state)) < 0) {
dprintk(verbose, DST_ERROR, 1, "RDC 8820 RESET Failed.");
return -1;
Expand Down Expand Up @@ -962,7 +962,7 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
{
u8 reply;

down(&state->dst_mutex);
mutex_lock(&state->dst_mutex);
if ((dst_comm_init(state)) < 0) {
dprintk(verbose, DST_NOTICE, 1, "DST Communication Initialization Failed.");
goto error;
Expand Down Expand Up @@ -1013,11 +1013,11 @@ int dst_command(struct dst_state *state, u8 *data, u8 len)
dprintk(verbose, DST_INFO, 1, "checksum failure");
goto error;
}
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return 0;

error:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return -EIO;

}
Expand Down Expand Up @@ -1128,7 +1128,7 @@ static int dst_write_tuna(struct dvb_frontend *fe)
dst_set_voltage(fe, SEC_VOLTAGE_13);
}
state->diseq_flags &= ~(HAS_LOCK | ATTEMPT_TUNE);
down(&state->dst_mutex);
mutex_lock(&state->dst_mutex);
if ((dst_comm_init(state)) < 0) {
dprintk(verbose, DST_DEBUG, 1, "DST Communication initialization failed.");
goto error;
Expand Down Expand Up @@ -1160,11 +1160,11 @@ static int dst_write_tuna(struct dvb_frontend *fe)
state->diseq_flags |= ATTEMPT_TUNE;
retval = dst_get_tuna(state);
werr:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return retval;

error:
up(&state->dst_mutex);
mutex_unlock(&state->dst_mutex);
return -EIO;
}

Expand Down
Loading

0 comments on commit 3593cab

Please sign in to comment.