Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd9a40da authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

V4L/DVB (12859): go7007: semaphore -> mutex conversion

parent 028d4c98
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -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>
@@ -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)
@@ -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;

@@ -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;
+6 −6
Original line number Diff line number Diff line
@@ -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>

@@ -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)
@@ -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);
	}

@@ -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;
}

+3 −3
Original line number Diff line number Diff line
@@ -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;
};
@@ -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;
@@ -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) \
+5 −5
Original line number Diff line number Diff line
@@ -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];
@@ -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
@@ -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;
}

@@ -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) {
+33 −33
Original line number Diff line number Diff line
@@ -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>

@@ -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);
@@ -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;
}

@@ -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;
@@ -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;
	}

@@ -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;
		}

@@ -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));

@@ -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;
}

@@ -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;

@@ -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;
}

@@ -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;

@@ -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;
}

@@ -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,
@@ -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;
}

@@ -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;
@@ -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;
}
@@ -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;
}
@@ -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;
@@ -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;
}

@@ -1862,7 +1862,7 @@ 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);
@@ -1870,7 +1870,7 @@ void go7007_v4l2_remove(struct go7007 *go)
		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