Skip to content

Commit

Permalink
V4L/DVB (12859): go7007: semaphore -> mutex conversion
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Mauro Carvalho Chehab committed Sep 19, 2009
1 parent 028d4c9 commit fd9a40d
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 70 deletions.
12 changes: 6 additions & 6 deletions drivers/staging/go7007/go7007-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/firmware.h>
#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <asm/system.h>
#include <linux/videodev2.h>
Expand Down Expand Up @@ -140,9 +140,9 @@ int go7007_boot_encoder(struct go7007 *go, int init_i2c)
{
int ret;

down(&go->hw_lock);
mutex_lock(&go->hw_lock);
ret = go7007_load_encoder(go);
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
if (ret < 0)
return -1;
if (!init_i2c)
Expand Down Expand Up @@ -257,9 +257,9 @@ int go7007_register_encoder(struct go7007 *go)

printk(KERN_INFO "go7007: registering new %s\n", go->name);

down(&go->hw_lock);
mutex_lock(&go->hw_lock);
ret = go7007_init_encoder(go);
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
if (ret < 0)
return -1;

Expand Down Expand Up @@ -604,7 +604,7 @@ struct go7007 *go7007_alloc(struct go7007_board_info *board, struct device *dev)
go->tuner_type = -1;
go->channel_number = 0;
go->name[0] = 0;
init_MUTEX(&go->hw_lock);
mutex_init(&go->hw_lock);
init_waitqueue_head(&go->frame_waitq);
spin_lock_init(&go->spinlock);
go->video_dev = NULL;
Expand Down
12 changes: 6 additions & 6 deletions drivers/staging/go7007/go7007-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <linux/time.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <asm/system.h>

Expand All @@ -48,7 +48,7 @@

/* There is only one I2C port on the TW2804 that feeds all four GO7007 VIPs
* on the Adlink PCI-MPG24, so access is shared between all of them. */
static DECLARE_MUTEX(adlink_mpg24_i2c_lock);
static DEFINE_MUTEX(adlink_mpg24_i2c_lock);

static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
u16 command, int flags, u8 *data)
Expand All @@ -69,11 +69,11 @@ static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
*data, command, addr);
#endif

down(&go->hw_lock);
mutex_lock(&go->hw_lock);

if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
/* Bridge the I2C port on this GO7007 to the shared bus */
down(&adlink_mpg24_i2c_lock);
mutex_lock(&adlink_mpg24_i2c_lock);
go7007_write_addr(go, 0x3c82, 0x0020);
}

Expand Down Expand Up @@ -134,9 +134,9 @@ static int go7007_i2c_xfer(struct go7007 *go, u16 addr, int read,
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
/* Isolate the I2C port on this GO7007 from the shared bus */
go7007_write_addr(go, 0x3c82, 0x0000);
up(&adlink_mpg24_i2c_lock);
mutex_unlock(&adlink_mpg24_i2c_lock);
}
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
return ret;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/go7007/go7007-priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct go7007_buffer {

struct go7007_file {
struct go7007 *go;
struct semaphore lock;
struct mutex lock;
int buf_count;
struct go7007_buffer *bufs;
};
Expand Down Expand Up @@ -170,7 +170,7 @@ struct go7007 {
int ref_count;
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
spinlock_t spinlock;
struct semaphore hw_lock;
struct mutex hw_lock;
int streaming;
int in_use;
int audio_enabled;
Expand Down Expand Up @@ -240,7 +240,7 @@ struct go7007 {
unsigned short interrupt_data;
};

/* All of these must be called with the hpi_lock semaphore held! */
/* All of these must be called with the hpi_lock mutex held! */
#define go7007_interface_reset(go) \
((go)->hpi_ops->interface_reset(go))
#define go7007_write_interrupt(go, x, y) \
Expand Down
10 changes: 5 additions & 5 deletions drivers/staging/go7007/go7007-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct go7007_usb_board {

struct go7007_usb {
struct go7007_usb_board *board;
struct semaphore i2c_lock;
struct mutex i2c_lock;
struct usb_device *usbdev;
struct urb *video_urbs[8];
struct urb *audio_urbs[8];
Expand Down Expand Up @@ -734,7 +734,7 @@ static int go7007_usb_read_interrupt(struct go7007 *go)
static void go7007_usb_read_video_pipe_complete(struct urb *urb)
{
struct go7007 *go = (struct go7007 *)urb->context;
int r, status = urb-> status;
int r, status = urb->status;

if (!go->streaming) {
wake_up_interruptible(&go->frame_waitq);
Expand Down Expand Up @@ -877,7 +877,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter *adapter,
if (go->status == STATUS_SHUTDOWN)
return -1;

down(&usb->i2c_lock);
mutex_lock(&usb->i2c_lock);

for (i = 0; i < num; ++i) {
/* The hardware command is "write some bytes then read some
Expand Down Expand Up @@ -935,7 +935,7 @@ static int go7007_usb_i2c_master_xfer(struct i2c_adapter *adapter,
ret = 0;

i2c_done:
up(&usb->i2c_lock);
mutex_unlock(&usb->i2c_lock);
return ret;
}

Expand Down Expand Up @@ -1065,7 +1065,7 @@ static int go7007_usb_probe(struct usb_interface *intf,
if (board->flags & GO7007_USB_EZUSB_I2C) {
memcpy(&go->i2c_adapter, &go7007_usb_adap_templ,
sizeof(go7007_usb_adap_templ));
init_MUTEX(&usb->i2c_lock);
mutex_init(&usb->i2c_lock);
go->i2c_adapter.dev.parent = go->dev;
i2c_set_adapdata(&go->i2c_adapter, go);
if (i2c_add_adapter(&go->i2c_adapter) < 0) {
Expand Down
66 changes: 33 additions & 33 deletions drivers/staging/go7007/go7007-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <media/v4l2-common.h>
#include <media/v4l2-ioctl.h>
#include <linux/i2c.h>
#include <linux/semaphore.h>
#include <linux/mutex.h>
#include <linux/uaccess.h>
#include <asm/system.h>

Expand Down Expand Up @@ -75,7 +75,7 @@ static int go7007_streamoff(struct go7007 *go)
int retval = -EINVAL;
unsigned long flags;

down(&go->hw_lock);
mutex_lock(&go->hw_lock);
if (go->streaming) {
go->streaming = 0;
go7007_stream_stop(go);
Expand All @@ -85,7 +85,7 @@ static int go7007_streamoff(struct go7007 *go)
go7007_reset_encoder(go);
retval = 0;
}
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
return 0;
}

Expand All @@ -101,7 +101,7 @@ static int go7007_open(struct file *file)
return -ENOMEM;
++go->ref_count;
gofh->go = go;
init_MUTEX(&gofh->lock);
mutex_init(&gofh->lock);
gofh->buf_count = 0;
file->private_data = gofh;
return 0;
Expand Down Expand Up @@ -705,14 +705,14 @@ static int vidioc_reqbufs(struct file *file, void *priv,
req->memory != V4L2_MEMORY_MMAP)
return -EINVAL;

down(&gofh->lock);
mutex_lock(&gofh->lock);
for (i = 0; i < gofh->buf_count; ++i)
if (gofh->bufs[i].mapped > 0)
goto unlock_and_return;

down(&go->hw_lock);
mutex_lock(&go->hw_lock);
if (go->in_use > 0 && gofh->buf_count == 0) {
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
goto unlock_and_return;
}

Expand All @@ -731,7 +731,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
GFP_KERNEL);

if (!gofh->bufs) {
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
goto unlock_and_return;
}

Expand All @@ -750,8 +750,8 @@ static int vidioc_reqbufs(struct file *file, void *priv,
}

gofh->buf_count = count;
up(&go->hw_lock);
up(&gofh->lock);
mutex_unlock(&go->hw_lock);
mutex_unlock(&gofh->lock);

memset(req, 0, sizeof(*req));

Expand All @@ -762,7 +762,7 @@ static int vidioc_reqbufs(struct file *file, void *priv,
return 0;

unlock_and_return:
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return retval;
}

Expand All @@ -778,7 +778,7 @@ static int vidioc_querybuf(struct file *file, void *priv,

index = buf->index;

down(&gofh->lock);
mutex_lock(&gofh->lock);
if (index >= gofh->buf_count)
goto unlock_and_return;

Expand All @@ -802,12 +802,12 @@ static int vidioc_querybuf(struct file *file, void *priv,
buf->memory = V4L2_MEMORY_MMAP;
buf->m.offset = index * GO7007_BUF_SIZE;
buf->length = GO7007_BUF_SIZE;
up(&gofh->lock);
mutex_unlock(&gofh->lock);

return 0;

unlock_and_return:
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return retval;
}

Expand All @@ -824,7 +824,7 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
buf->memory != V4L2_MEMORY_MMAP)
return retval;

down(&gofh->lock);
mutex_lock(&gofh->lock);
if (buf->index < 0 || buf->index >= gofh->buf_count)
goto unlock_and_return;

Expand Down Expand Up @@ -865,12 +865,12 @@ static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
spin_lock_irqsave(&go->spinlock, flags);
list_add_tail(&gobuf->stream, &go->stream);
spin_unlock_irqrestore(&go->spinlock, flags);
up(&gofh->lock);
mutex_unlock(&gofh->lock);

return 0;

unlock_and_return:
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return retval;
}

Expand All @@ -890,7 +890,7 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
if (buf->memory != V4L2_MEMORY_MMAP)
return retval;

down(&gofh->lock);
mutex_lock(&gofh->lock);
if (list_empty(&go->stream))
goto unlock_and_return;
gobuf = list_entry(go->stream.next,
Expand Down Expand Up @@ -934,11 +934,11 @@ static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *buf)
buf->length = GO7007_BUF_SIZE;
buf->reserved = gobuf->modet_active;

up(&gofh->lock);
mutex_unlock(&gofh->lock);
return 0;

unlock_and_return:
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return retval;
}

Expand All @@ -952,8 +952,8 @@ static int vidioc_streamon(struct file *file, void *priv,
if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;

down(&gofh->lock);
down(&go->hw_lock);
mutex_lock(&gofh->lock);
mutex_lock(&go->hw_lock);

if (!go->streaming) {
go->streaming = 1;
Expand All @@ -964,8 +964,8 @@ static int vidioc_streamon(struct file *file, void *priv,
else
retval = 0;
}
up(&go->hw_lock);
up(&gofh->lock);
mutex_unlock(&go->hw_lock);
mutex_unlock(&gofh->lock);

return retval;
}
Expand All @@ -978,9 +978,9 @@ static int vidioc_streamoff(struct file *file, void *priv,

if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
down(&gofh->lock);
mutex_lock(&gofh->lock);
go7007_streamoff(go);
up(&gofh->lock);
mutex_unlock(&gofh->lock);

return 0;
}
Expand Down Expand Up @@ -1734,18 +1734,18 @@ static int go7007_mmap(struct file *file, struct vm_area_struct *vma)
return -EINVAL; /* only support VM_SHARED mapping */
if (vma->vm_end - vma->vm_start != GO7007_BUF_SIZE)
return -EINVAL; /* must map exactly one full buffer */
down(&gofh->lock);
mutex_lock(&gofh->lock);
index = vma->vm_pgoff / GO7007_BUF_PAGES;
if (index >= gofh->buf_count) {
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return -EINVAL; /* trying to map beyond requested buffers */
}
if (index * GO7007_BUF_PAGES != vma->vm_pgoff) {
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return -EINVAL; /* offset is not aligned on buffer boundary */
}
if (gofh->bufs[index].mapped > 0) {
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return -EBUSY;
}
gofh->bufs[index].mapped = 1;
Expand All @@ -1754,7 +1754,7 @@ static int go7007_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_flags |= VM_DONTEXPAND;
vma->vm_flags &= ~VM_IO;
vma->vm_private_data = &gofh->bufs[index];
up(&gofh->lock);
mutex_unlock(&gofh->lock);
return 0;
}

Expand Down Expand Up @@ -1862,15 +1862,15 @@ void go7007_v4l2_remove(struct go7007 *go)
{
unsigned long flags;

down(&go->hw_lock);
mutex_lock(&go->hw_lock);
if (go->streaming) {
go->streaming = 0;
go7007_stream_stop(go);
spin_lock_irqsave(&go->spinlock, flags);
abort_queued(go);
spin_unlock_irqrestore(&go->spinlock, flags);
}
up(&go->hw_lock);
mutex_unlock(&go->hw_lock);
if (go->video_dev)
video_unregister_device(go->video_dev);
}
Loading

0 comments on commit fd9a40d

Please sign in to comment.