diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-10-24 16:31:15 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:00:55 -0500 |
commit | 289d4d2f0746715ada41e0945116eb3d62d5f35c (patch) | |
tree | dfb7dc29cd73101db3c3dc83a6835a1b2748955c | |
parent | b02044d81fc028d4fef1c65f9b179a0aec091f0b (diff) |
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: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Reviewed-by: Thierry MERLE <thierry.merle@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/usbvision/usbvision-core.c | 8 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 54 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision.h | 3 |
3 files changed, 35 insertions, 30 deletions
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c index c7d5f9ed22d7..2038d409f1dc 100644 --- a/drivers/media/video/usbvision/usbvision-core.c +++ b/drivers/media/video/usbvision/usbvision-core.c | |||
@@ -2242,14 +2242,18 @@ static void call_usbvision_power_off(struct work_struct *work) | |||
2242 | struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork); | 2242 | struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork); |
2243 | 2243 | ||
2244 | PDEBUG(DBG_FUNC, ""); | 2244 | PDEBUG(DBG_FUNC, ""); |
2245 | down_interruptible(&usbvision->lock); | 2245 | if(mutex_lock_interruptible(&usbvision->lock)) { |
2246 | return; | ||
2247 | } | ||
2248 | |||
2249 | |||
2246 | if(usbvision->user == 0) { | 2250 | if(usbvision->user == 0) { |
2247 | usbvision_i2c_unregister(usbvision); | 2251 | usbvision_i2c_unregister(usbvision); |
2248 | 2252 | ||
2249 | usbvision_power_off(usbvision); | 2253 | usbvision_power_off(usbvision); |
2250 | usbvision->initialized = 0; | 2254 | usbvision->initialized = 0; |
2251 | } | 2255 | } |
2252 | up(&usbvision->lock); | 2256 | mutex_unlock(&usbvision->lock); |
2253 | } | 2257 | } |
2254 | 2258 | ||
2255 | static void usbvision_powerOffTimer(unsigned long data) | 2259 | static void usbvision_powerOffTimer(unsigned long data) |
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index 36e689fa16c0..e34f311124e3 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -410,7 +410,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) | |||
410 | 410 | ||
411 | /* If so far no errors then we shall start the camera */ | 411 | /* If so far no errors then we shall start the camera */ |
412 | if (!errCode) { | 412 | if (!errCode) { |
413 | down(&usbvision->lock); | 413 | mutex_lock(&usbvision->lock); |
414 | if (usbvision->power == 0) { | 414 | if (usbvision->power == 0) { |
415 | usbvision_power_on(usbvision); | 415 | usbvision_power_on(usbvision); |
416 | usbvision_i2c_register(usbvision); | 416 | usbvision_i2c_register(usbvision); |
@@ -439,7 +439,7 @@ static int usbvision_v4l2_open(struct inode *inode, struct file *file) | |||
439 | usbvision->initialized = 0; | 439 | usbvision->initialized = 0; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | up(&usbvision->lock); | 442 | mutex_unlock(&usbvision->lock); |
443 | } | 443 | } |
444 | 444 | ||
445 | if (errCode) { | 445 | if (errCode) { |
@@ -467,7 +467,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file) | |||
467 | (struct usb_usbvision *) video_get_drvdata(dev); | 467 | (struct usb_usbvision *) video_get_drvdata(dev); |
468 | 468 | ||
469 | PDEBUG(DBG_IO, "close"); | 469 | PDEBUG(DBG_IO, "close"); |
470 | down(&usbvision->lock); | 470 | mutex_lock(&usbvision->lock); |
471 | 471 | ||
472 | usbvision_audio_off(usbvision); | 472 | usbvision_audio_off(usbvision); |
473 | usbvision_restart_isoc(usbvision); | 473 | usbvision_restart_isoc(usbvision); |
@@ -487,7 +487,7 @@ static int usbvision_v4l2_close(struct inode *inode, struct file *file) | |||
487 | usbvision->initialized = 0; | 487 | usbvision->initialized = 0; |
488 | } | 488 | } |
489 | 489 | ||
490 | up(&usbvision->lock); | 490 | mutex_unlock(&usbvision->lock); |
491 | 491 | ||
492 | if (usbvision->remove_pending) { | 492 | if (usbvision->remove_pending) { |
493 | printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); | 493 | 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 | if ((input >= usbvision->video_inputs) || (input < 0) ) | 647 | if ((input >= usbvision->video_inputs) || (input < 0) ) |
648 | return -EINVAL; | 648 | return -EINVAL; |
649 | 649 | ||
650 | down(&usbvision->lock); | 650 | mutex_lock(&usbvision->lock); |
651 | usbvision_muxsel(usbvision, input); | 651 | usbvision_muxsel(usbvision, input); |
652 | usbvision_set_input(usbvision); | 652 | usbvision_set_input(usbvision); |
653 | usbvision_set_output(usbvision, | 653 | usbvision_set_output(usbvision, |
654 | usbvision->curwidth, | 654 | usbvision->curwidth, |
655 | usbvision->curheight); | 655 | usbvision->curheight); |
656 | up(&usbvision->lock); | 656 | mutex_unlock(&usbvision->lock); |
657 | return 0; | 657 | return 0; |
658 | } | 658 | } |
659 | 659 | ||
@@ -664,10 +664,10 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
664 | (struct usb_usbvision *) video_get_drvdata(dev); | 664 | (struct usb_usbvision *) video_get_drvdata(dev); |
665 | usbvision->tvnormId=*id; | 665 | usbvision->tvnormId=*id; |
666 | 666 | ||
667 | down(&usbvision->lock); | 667 | mutex_lock(&usbvision->lock); |
668 | call_i2c_clients(usbvision, VIDIOC_S_STD, | 668 | call_i2c_clients(usbvision, VIDIOC_S_STD, |
669 | &usbvision->tvnormId); | 669 | &usbvision->tvnormId); |
670 | up(&usbvision->lock); | 670 | mutex_unlock(&usbvision->lock); |
671 | /* propagate the change to the decoder */ | 671 | /* propagate the change to the decoder */ |
672 | usbvision_muxsel(usbvision, usbvision->ctl_input); | 672 | usbvision_muxsel(usbvision, usbvision->ctl_input); |
673 | 673 | ||
@@ -1083,9 +1083,9 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv, | |||
1083 | usbvision->curFrame = NULL; | 1083 | usbvision->curFrame = NULL; |
1084 | 1084 | ||
1085 | /* by now we are committed to the new data... */ | 1085 | /* by now we are committed to the new data... */ |
1086 | down(&usbvision->lock); | 1086 | mutex_lock(&usbvision->lock); |
1087 | usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); | 1087 | usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); |
1088 | up(&usbvision->lock); | 1088 | mutex_unlock(&usbvision->lock); |
1089 | 1089 | ||
1090 | return 0; | 1090 | return 0; |
1091 | } | 1091 | } |
@@ -1211,16 +1211,16 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1211 | 1211 | ||
1212 | PDEBUG(DBG_MMAP, "mmap"); | 1212 | PDEBUG(DBG_MMAP, "mmap"); |
1213 | 1213 | ||
1214 | down(&usbvision->lock); | 1214 | mutex_lock(&usbvision->lock); |
1215 | 1215 | ||
1216 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { | 1216 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { |
1217 | up(&usbvision->lock); | 1217 | mutex_unlock(&usbvision->lock); |
1218 | return -EFAULT; | 1218 | return -EFAULT; |
1219 | } | 1219 | } |
1220 | 1220 | ||
1221 | if (!(vma->vm_flags & VM_WRITE) || | 1221 | if (!(vma->vm_flags & VM_WRITE) || |
1222 | size != PAGE_ALIGN(usbvision->max_frame_size)) { | 1222 | size != PAGE_ALIGN(usbvision->max_frame_size)) { |
1223 | up(&usbvision->lock); | 1223 | mutex_unlock(&usbvision->lock); |
1224 | return -EINVAL; | 1224 | return -EINVAL; |
1225 | } | 1225 | } |
1226 | 1226 | ||
@@ -1232,7 +1232,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1232 | if (i == usbvision->num_frames) { | 1232 | if (i == usbvision->num_frames) { |
1233 | PDEBUG(DBG_MMAP, | 1233 | PDEBUG(DBG_MMAP, |
1234 | "mmap: user supplied mapping address is out of range"); | 1234 | "mmap: user supplied mapping address is out of range"); |
1235 | up(&usbvision->lock); | 1235 | mutex_unlock(&usbvision->lock); |
1236 | return -EINVAL; | 1236 | return -EINVAL; |
1237 | } | 1237 | } |
1238 | 1238 | ||
@@ -1245,7 +1245,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1245 | 1245 | ||
1246 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 1246 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
1247 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); | 1247 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); |
1248 | up(&usbvision->lock); | 1248 | mutex_unlock(&usbvision->lock); |
1249 | return -EAGAIN; | 1249 | return -EAGAIN; |
1250 | } | 1250 | } |
1251 | start += PAGE_SIZE; | 1251 | start += PAGE_SIZE; |
@@ -1253,7 +1253,7 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1253 | size -= PAGE_SIZE; | 1253 | size -= PAGE_SIZE; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | up(&usbvision->lock); | 1256 | mutex_unlock(&usbvision->lock); |
1257 | return 0; | 1257 | return 0; |
1258 | } | 1258 | } |
1259 | 1259 | ||
@@ -1271,7 +1271,7 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) | |||
1271 | 1271 | ||
1272 | PDEBUG(DBG_IO, "%s:", __FUNCTION__); | 1272 | PDEBUG(DBG_IO, "%s:", __FUNCTION__); |
1273 | 1273 | ||
1274 | down(&usbvision->lock); | 1274 | mutex_lock(&usbvision->lock); |
1275 | 1275 | ||
1276 | if (usbvision->user) { | 1276 | if (usbvision->user) { |
1277 | err("%s: Someone tried to open an already opened USBVision Radio!", __FUNCTION__); | 1277 | 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 | usbvision->initialized = 0; | 1307 | usbvision->initialized = 0; |
1308 | } | 1308 | } |
1309 | } | 1309 | } |
1310 | up(&usbvision->lock); | 1310 | mutex_unlock(&usbvision->lock); |
1311 | return errCode; | 1311 | return errCode; |
1312 | } | 1312 | } |
1313 | 1313 | ||
@@ -1321,7 +1321,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) | |||
1321 | 1321 | ||
1322 | PDEBUG(DBG_IO, ""); | 1322 | PDEBUG(DBG_IO, ""); |
1323 | 1323 | ||
1324 | down(&usbvision->lock); | 1324 | mutex_lock(&usbvision->lock); |
1325 | 1325 | ||
1326 | /* Set packet size to 0 */ | 1326 | /* Set packet size to 0 */ |
1327 | usbvision->ifaceAlt=0; | 1327 | usbvision->ifaceAlt=0; |
@@ -1337,7 +1337,7 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) | |||
1337 | usbvision->initialized = 0; | 1337 | usbvision->initialized = 0; |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | up(&usbvision->lock); | 1340 | mutex_unlock(&usbvision->lock); |
1341 | 1341 | ||
1342 | if (usbvision->remove_pending) { | 1342 | if (usbvision->remove_pending) { |
1343 | printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); | 1343 | printk(KERN_INFO "%s: Final disconnect\n", __FUNCTION__); |
@@ -1641,7 +1641,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev) | |||
1641 | 1641 | ||
1642 | usbvision->dev = dev; | 1642 | usbvision->dev = dev; |
1643 | 1643 | ||
1644 | init_MUTEX(&usbvision->lock); /* to 1 == available */ | 1644 | mutex_init(&usbvision->lock); /* available */ |
1645 | 1645 | ||
1646 | // prepare control urb for control messages during interrupts | 1646 | // prepare control urb for control messages during interrupts |
1647 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); | 1647 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); |
@@ -1676,13 +1676,13 @@ static void usbvision_release(struct usb_usbvision *usbvision) | |||
1676 | { | 1676 | { |
1677 | PDEBUG(DBG_PROBE, ""); | 1677 | PDEBUG(DBG_PROBE, ""); |
1678 | 1678 | ||
1679 | down(&usbvision->lock); | 1679 | mutex_lock(&usbvision->lock); |
1680 | 1680 | ||
1681 | usbvision_reset_powerOffTimer(usbvision); | 1681 | usbvision_reset_powerOffTimer(usbvision); |
1682 | 1682 | ||
1683 | usbvision->initialized = 0; | 1683 | usbvision->initialized = 0; |
1684 | 1684 | ||
1685 | up(&usbvision->lock); | 1685 | mutex_unlock(&usbvision->lock); |
1686 | 1686 | ||
1687 | usbvision_remove_sysfs(usbvision->vdev); | 1687 | usbvision_remove_sysfs(usbvision->vdev); |
1688 | usbvision_unregister_video(usbvision); | 1688 | usbvision_unregister_video(usbvision); |
@@ -1796,7 +1796,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1796 | } | 1796 | } |
1797 | PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType); | 1797 | PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType); |
1798 | 1798 | ||
1799 | down(&usbvision->lock); | 1799 | mutex_lock(&usbvision->lock); |
1800 | 1800 | ||
1801 | /* compute alternate max packet sizes */ | 1801 | /* compute alternate max packet sizes */ |
1802 | uif = dev->actconfig->interface[0]; | 1802 | uif = dev->actconfig->interface[0]; |
@@ -1840,7 +1840,7 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1840 | usbvision->streaming = Stream_Off; | 1840 | usbvision->streaming = Stream_Off; |
1841 | usbvision_register_video(usbvision); | 1841 | usbvision_register_video(usbvision); |
1842 | usbvision_configure_video(usbvision); | 1842 | usbvision_configure_video(usbvision); |
1843 | up(&usbvision->lock); | 1843 | mutex_unlock(&usbvision->lock); |
1844 | 1844 | ||
1845 | 1845 | ||
1846 | usb_set_intfdata (intf, usbvision); | 1846 | usb_set_intfdata (intf, usbvision); |
@@ -1871,7 +1871,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
1871 | } | 1871 | } |
1872 | usb_set_intfdata (intf, NULL); | 1872 | usb_set_intfdata (intf, NULL); |
1873 | 1873 | ||
1874 | down(&usbvision->lock); | 1874 | mutex_lock(&usbvision->lock); |
1875 | 1875 | ||
1876 | // At this time we ask to cancel outstanding URBs | 1876 | // At this time we ask to cancel outstanding URBs |
1877 | usbvision_stop_isoc(usbvision); | 1877 | usbvision_stop_isoc(usbvision); |
@@ -1885,7 +1885,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
1885 | usb_put_dev(usbvision->dev); | 1885 | usb_put_dev(usbvision->dev); |
1886 | usbvision->dev = NULL; // USB device is no more | 1886 | usbvision->dev = NULL; // USB device is no more |
1887 | 1887 | ||
1888 | up(&usbvision->lock); | 1888 | mutex_unlock(&usbvision->lock); |
1889 | 1889 | ||
1890 | if (usbvision->user) { | 1890 | if (usbvision->user) { |
1891 | printk(KERN_INFO "%s: In use, disconnect pending\n", | 1891 | printk(KERN_INFO "%s: In use, disconnect pending\n", |
diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h index c5b6c501c869..c32f68566bf9 100644 --- a/drivers/media/video/usbvision/usbvision.h +++ b/drivers/media/video/usbvision/usbvision.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/usb.h> | 35 | #include <linux/usb.h> |
36 | #include <linux/i2c.h> | 36 | #include <linux/i2c.h> |
37 | #include <linux/mutex.h> | ||
37 | #include <media/v4l2-common.h> | 38 | #include <media/v4l2-common.h> |
38 | #include <media/tuner.h> | 39 | #include <media/tuner.h> |
39 | #include <linux/videodev2.h> | 40 | #include <linux/videodev2.h> |
@@ -396,7 +397,7 @@ struct usb_usbvision { | |||
396 | unsigned char iface; /* Video interface number */ | 397 | unsigned char iface; /* Video interface number */ |
397 | unsigned char ifaceAlt; /* Alt settings */ | 398 | unsigned char ifaceAlt; /* Alt settings */ |
398 | unsigned char Vin_Reg2_Preset; | 399 | unsigned char Vin_Reg2_Preset; |
399 | struct semaphore lock; | 400 | struct mutex lock; |
400 | struct timer_list powerOffTimer; | 401 | struct timer_list powerOffTimer; |
401 | struct work_struct powerOffWork; | 402 | struct work_struct powerOffWork; |
402 | int power; /* is the device powered on? */ | 403 | int power; /* is the device powered on? */ |