Commit 289d4d2f authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Mauro Carvalho Chehab

V4L/DVB (6400): usbvision: Convert the usbvision->lock semaphore to the mutex API

Convert the usbvision->lock semaphore to the mutex API
Signed-off-by: default avatarMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
Reviewed-by: default avatarThierry MERLE <thierry.merle@free.fr>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent b02044d8
...@@ -2242,14 +2242,18 @@ static void call_usbvision_power_off(struct work_struct *work) ...@@ -2242,14 +2242,18 @@ static void call_usbvision_power_off(struct work_struct *work)
struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork); struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork);
PDEBUG(DBG_FUNC, ""); PDEBUG(DBG_FUNC, "");
down_interruptible(&usbvision->lock); if(mutex_lock_interruptible(&usbvision->lock)) {
return;
}
if(usbvision->user == 0) { if(usbvision->user == 0) {
usbvision_i2c_unregister(usbvision); usbvision_i2c_unregister(usbvision);
usbvision_power_off(usbvision); usbvision_power_off(usbvision);
usbvision->initialized = 0; usbvision->initialized = 0;
} }
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
} }
static void usbvision_powerOffTimer(unsigned long data) static void usbvision_powerOffTimer(unsigned long data)
......
...@@ -410,7 +410,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) ...@@ -410,7 +410,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
/* If so far no errors then we shall start the camera */ /* If so far no errors then we shall start the camera */
if (!errCode) { if (!errCode) {
down(&usbvision->lock); mutex_lock(&usbvision->lock);
if (usbvision->power == 0) { if (usbvision->power == 0) {
usbvision_power_on(usbvision); usbvision_power_on(usbvision);
usbvision_i2c_register(usbvision); usbvision_i2c_register(usbvision);
...@@ -439,7 +439,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) ...@@ -439,7 +439,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file)
usbvision->initialized = 0; usbvision->initialized = 0;
} }
} }
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
} }
if (errCode) { if (errCode) {
...@@ -467,7 +467,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file) ...@@ -467,7 +467,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
(struct usb_usbvision *) video_get_drvdata(dev); (struct usb_usbvision *) video_get_drvdata(dev);
PDEBUG(DBG_IO, "close"); PDEBUG(DBG_IO, "close");
down(&usbvision->lock); mutex_lock(&usbvision->lock);
usbvision_audio_off(usbvision); usbvision_audio_off(usbvision);
usbvision_restart_isoc(usbvision); usbvision_restart_isoc(usbvision);
...@@ -487,7 +487,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file) ...@@ -487,7 +487,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file)
usbvision->initialized = 0; usbvision->initialized = 0;
} }
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
if (usbvision->remove_pending) { if (usbvision->remove_pending) {
printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__);
...@@ -647,13 +647,13 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input) ...@@ -647,13 +647,13 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input)
if ((input >= usbvision->video_inputs) || (input < 0) ) if ((input >= usbvision->video_inputs) || (input < 0) )
return -EINVAL; return -EINVAL;
down(&usbvision->lock); mutex_lock(&usbvision->lock);
usbvision_muxsel(usbvision, input); usbvision_muxsel(usbvision, input);
usbvision_set_input(usbvision); usbvision_set_input(usbvision);
usbvision_set_output(usbvision, usbvision_set_output(usbvision,
usbvision->curwidth, usbvision->curwidth,
usbvision->curheight); usbvision->curheight);
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return 0; return 0;
} }
...@@ -664,10 +664,10 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) ...@@ -664,10 +664,10 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id)
(struct usb_usbvision *) video_get_drvdata(dev); (struct usb_usbvision *) video_get_drvdata(dev);
usbvision->tvnormId=*id; usbvision->tvnormId=*id;
down(&usbvision->lock); mutex_lock(&usbvision->lock);
call_i2c_clients(usbvision, VIDIOC_S_STD, call_i2c_clients(usbvision, VIDIOC_S_STD,
&usbvision->tvnormId); &usbvision->tvnormId);
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
/* propagate the change to the decoder */ /* propagate the change to the decoder */
usbvision_muxsel(usbvision, usbvision->ctl_input); usbvision_muxsel(usbvision, usbvision->ctl_input);
...@@ -1083,9 +1083,9 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, ...@@ -1083,9 +1083,9 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv,
usbvision->curFrame = NULL; usbvision->curFrame = NULL;
/* by now we are committed to the new data... */ /* by now we are committed to the new data... */
down(&usbvision->lock); mutex_lock(&usbvision->lock);
usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height);
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return 0; return 0;
} }
...@@ -1211,16 +1211,16 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1211,16 +1211,16 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
PDEBUG(DBG_MMAP, "mmap"); PDEBUG(DBG_MMAP, "mmap");
down(&usbvision->lock); mutex_lock(&usbvision->lock);
if (!USBVISION_IS_OPERATIONAL(usbvision)) { if (!USBVISION_IS_OPERATIONAL(usbvision)) {
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return -EFAULT; return -EFAULT;
} }
if (!(vma->vm_flags & VM_WRITE) || if (!(vma->vm_flags & VM_WRITE) ||
size != PAGE_ALIGN(usbvision->max_frame_size)) { size != PAGE_ALIGN(usbvision->max_frame_size)) {
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1232,7 +1232,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1232,7 +1232,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
if (i == usbvision->num_frames) { if (i == usbvision->num_frames) {
PDEBUG(DBG_MMAP, PDEBUG(DBG_MMAP,
"mmap: user supplied mapping address is out of range"); "mmap: user supplied mapping address is out of range");
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1245,7 +1245,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1245,7 +1245,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed");
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return -EAGAIN; return -EAGAIN;
} }
start += PAGE_SIZE; start += PAGE_SIZE;
...@@ -1253,7 +1253,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -1253,7 +1253,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma)
size -= PAGE_SIZE; size -= PAGE_SIZE;
} }
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return 0; return 0;
} }
...@@ -1271,7 +1271,7 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) ...@@ -1271,7 +1271,7 @@ static int usbvision_radio_open(struct inode *inode, struct file *file)
PDEBUG(DBG_IO, "%s:", __FUNCTION__); PDEBUG(DBG_IO, "%s:", __FUNCTION__);
down(&usbvision->lock); mutex_lock(&usbvision->lock);
if (usbvision->user) { if (usbvision->user) {
err("%s: Someone tried to open an already opened USBVision Radio!", __FUNCTION__); err("%s: Someone tried to open an already opened USBVision Radio!", __FUNCTION__);
...@@ -1307,7 +1307,7 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) ...@@ -1307,7 +1307,7 @@ static int usbvision_radio_open(struct inode *inode, struct file *file)
usbvision->initialized = 0; usbvision->initialized = 0;
} }
} }
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
return errCode; return errCode;
} }
...@@ -1321,7 +1321,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) ...@@ -1321,7 +1321,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file)
PDEBUG(DBG_IO, ""); PDEBUG(DBG_IO, "");
down(&usbvision->lock); mutex_lock(&usbvision->lock);
/* Set packet size to 0 */ /* Set packet size to 0 */
usbvision->ifaceAlt=0; usbvision->ifaceAlt=0;
...@@ -1337,7 +1337,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) ...@@ -1337,7 +1337,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file)
usbvision->initialized = 0; usbvision->initialized = 0;
} }
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
if (usbvision->remove_pending) { if (usbvision->remove_pending) {
printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__);
...@@ -1641,7 +1641,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev) ...@@ -1641,7 +1641,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev)
usbvision->dev = dev; usbvision->dev = dev;
init_MUTEX(&usbvision->lock); /* to 1 == available */ mutex_init(&usbvision->lock); /* available */
// prepare control urb for control messages during interrupts // prepare control urb for control messages during interrupts
usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL);
...@@ -1676,13 +1676,13 @@ static void usbvision_release(struct usb_usbvision *usbvision) ...@@ -1676,13 +1676,13 @@ static void usbvision_release(struct usb_usbvision *usbvision)
{ {
PDEBUG(DBG_PROBE, ""); PDEBUG(DBG_PROBE, "");
down(&usbvision->lock); mutex_lock(&usbvision->lock);
usbvision_reset_powerOffTimer(usbvision); usbvision_reset_powerOffTimer(usbvision);
usbvision->initialized = 0; usbvision->initialized = 0;
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
usbvision_remove_sysfs(usbvision->vdev); usbvision_remove_sysfs(usbvision->vdev);
usbvision_unregister_video(usbvision); usbvision_unregister_video(usbvision);
...@@ -1796,7 +1796,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, ...@@ -1796,7 +1796,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
} }
PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType); PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType);
down(&usbvision->lock); mutex_lock(&usbvision->lock);
/* compute alternate max packet sizes */ /* compute alternate max packet sizes */
uif = dev->actconfig->interface[0]; uif = dev->actconfig->interface[0];
...@@ -1840,7 +1840,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, ...@@ -1840,7 +1840,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
usbvision->streaming = Stream_Off; usbvision->streaming = Stream_Off;
usbvision_register_video(usbvision); usbvision_register_video(usbvision);
usbvision_configure_video(usbvision); usbvision_configure_video(usbvision);
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
usb_set_intfdata (intf, usbvision); usb_set_intfdata (intf, usbvision);
...@@ -1871,7 +1871,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) ...@@ -1871,7 +1871,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf)
} }
usb_set_intfdata (intf, NULL); usb_set_intfdata (intf, NULL);
down(&usbvision->lock); mutex_lock(&usbvision->lock);
// At this time we ask to cancel outstanding URBs // At this time we ask to cancel outstanding URBs
usbvision_stop_isoc(usbvision); usbvision_stop_isoc(usbvision);
...@@ -1885,7 +1885,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) ...@@ -1885,7 +1885,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf)
usb_put_dev(usbvision->dev); usb_put_dev(usbvision->dev);
usbvision->dev = NULL; // USB device is no more usbvision->dev = NULL; // USB device is no more
up(&usbvision->lock); mutex_unlock(&usbvision->lock);
if (usbvision->user) { if (usbvision->user) {
printk(KERN_INFO "%s: In use, disconnect pending\n", printk(KERN_INFO "%s: In use, disconnect pending\n",
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/mutex.h>
#include <media/v4l2-common.h> #include <media/v4l2-common.h>
#include <media/tuner.h> #include <media/tuner.h>
#include <linux/videodev2.h> #include <linux/videodev2.h>
...@@ -396,7 +397,7 @@ struct usb_usbvision { ...@@ -396,7 +397,7 @@ struct usb_usbvision {
unsigned char iface; /* Video interface number */ unsigned char iface; /* Video interface number */
unsigned char ifaceAlt; /* Alt settings */ unsigned char ifaceAlt; /* Alt settings */
unsigned char Vin_Reg2_Preset; unsigned char Vin_Reg2_Preset;
struct semaphore lock; struct mutex lock;
struct timer_list powerOffTimer; struct timer_list powerOffTimer;
struct work_struct powerOffWork; struct work_struct powerOffWork;
int power; /* is the device powered on? */ int power; /* is the device powered on? */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment