diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-12-18 09:06:09 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-30 05:01:45 -0500 |
commit | c627b9d1f580f26fe99a8045d37a57f91e9aef66 (patch) | |
tree | 3699c7f3fbcc44bfaae1d6bd09cb814a69adb404 /drivers/media | |
parent | 427aacfe1d0c540bf80e5243d18ba1272f9b756f (diff) |
[media] usbvision: convert to unlocked_ioctl
Convert driver to use core-assisted locking.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-core.c | 6 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 44 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision.h | 2 |
3 files changed, 9 insertions, 43 deletions
diff --git a/drivers/media/video/usbvision/usbvision-core.c b/drivers/media/video/usbvision/usbvision-core.c index b9dd74fde212..de58aa7d9e1d 100644 --- a/drivers/media/video/usbvision/usbvision-core.c +++ b/drivers/media/video/usbvision/usbvision-core.c | |||
@@ -2291,10 +2291,8 @@ static void call_usbvision_power_off(struct work_struct *work) | |||
2291 | struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork); | 2291 | struct usb_usbvision *usbvision = container_of(work, struct usb_usbvision, powerOffWork); |
2292 | 2292 | ||
2293 | PDEBUG(DBG_FUNC, ""); | 2293 | PDEBUG(DBG_FUNC, ""); |
2294 | if(mutex_lock_interruptible(&usbvision->lock)) { | 2294 | if (mutex_lock_interruptible(&usbvision->v4l2_lock)) |
2295 | return; | 2295 | return; |
2296 | } | ||
2297 | |||
2298 | 2296 | ||
2299 | if(usbvision->user == 0) { | 2297 | if(usbvision->user == 0) { |
2300 | usbvision_i2c_unregister(usbvision); | 2298 | usbvision_i2c_unregister(usbvision); |
@@ -2302,7 +2300,7 @@ static void call_usbvision_power_off(struct work_struct *work) | |||
2302 | usbvision_power_off(usbvision); | 2300 | usbvision_power_off(usbvision); |
2303 | usbvision->initialized = 0; | 2301 | usbvision->initialized = 0; |
2304 | } | 2302 | } |
2305 | mutex_unlock(&usbvision->lock); | 2303 | mutex_unlock(&usbvision->v4l2_lock); |
2306 | } | 2304 | } |
2307 | 2305 | ||
2308 | static void usbvision_powerOffTimer(unsigned long data) | 2306 | 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 20da6ea2cdf0..a5709a576772 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -356,7 +356,6 @@ static int usbvision_v4l2_open(struct file *file) | |||
356 | 356 | ||
357 | PDEBUG(DBG_IO, "open"); | 357 | PDEBUG(DBG_IO, "open"); |
358 | 358 | ||
359 | mutex_lock(&usbvision->lock); | ||
360 | usbvision_reset_powerOffTimer(usbvision); | 359 | usbvision_reset_powerOffTimer(usbvision); |
361 | 360 | ||
362 | if (usbvision->user) | 361 | if (usbvision->user) |
@@ -412,7 +411,6 @@ static int usbvision_v4l2_open(struct file *file) | |||
412 | usbvision_empty_framequeues(usbvision); | 411 | usbvision_empty_framequeues(usbvision); |
413 | 412 | ||
414 | PDEBUG(DBG_IO, "success"); | 413 | PDEBUG(DBG_IO, "success"); |
415 | mutex_unlock(&usbvision->lock); | ||
416 | return errCode; | 414 | return errCode; |
417 | } | 415 | } |
418 | 416 | ||
@@ -429,7 +427,6 @@ static int usbvision_v4l2_close(struct file *file) | |||
429 | struct usb_usbvision *usbvision = video_drvdata(file); | 427 | struct usb_usbvision *usbvision = video_drvdata(file); |
430 | 428 | ||
431 | PDEBUG(DBG_IO, "close"); | 429 | PDEBUG(DBG_IO, "close"); |
432 | mutex_lock(&usbvision->lock); | ||
433 | 430 | ||
434 | usbvision_audio_off(usbvision); | 431 | usbvision_audio_off(usbvision); |
435 | usbvision_restart_isoc(usbvision); | 432 | usbvision_restart_isoc(usbvision); |
@@ -449,8 +446,6 @@ static int usbvision_v4l2_close(struct file *file) | |||
449 | usbvision->initialized = 0; | 446 | usbvision->initialized = 0; |
450 | } | 447 | } |
451 | 448 | ||
452 | mutex_unlock(&usbvision->lock); | ||
453 | |||
454 | if (usbvision->remove_pending) { | 449 | if (usbvision->remove_pending) { |
455 | printk(KERN_INFO "%s: Final disconnect\n", __func__); | 450 | printk(KERN_INFO "%s: Final disconnect\n", __func__); |
456 | usbvision_release(usbvision); | 451 | usbvision_release(usbvision); |
@@ -597,13 +592,11 @@ static int vidioc_s_input (struct file *file, void *priv, unsigned int input) | |||
597 | if (input >= usbvision->video_inputs) | 592 | if (input >= usbvision->video_inputs) |
598 | return -EINVAL; | 593 | return -EINVAL; |
599 | 594 | ||
600 | mutex_lock(&usbvision->lock); | ||
601 | usbvision_muxsel(usbvision, input); | 595 | usbvision_muxsel(usbvision, input); |
602 | usbvision_set_input(usbvision); | 596 | usbvision_set_input(usbvision); |
603 | usbvision_set_output(usbvision, | 597 | usbvision_set_output(usbvision, |
604 | usbvision->curwidth, | 598 | usbvision->curwidth, |
605 | usbvision->curheight); | 599 | usbvision->curheight); |
606 | mutex_unlock(&usbvision->lock); | ||
607 | return 0; | 600 | return 0; |
608 | } | 601 | } |
609 | 602 | ||
@@ -613,9 +606,7 @@ static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id *id) | |||
613 | 606 | ||
614 | usbvision->tvnormId=*id; | 607 | usbvision->tvnormId=*id; |
615 | 608 | ||
616 | mutex_lock(&usbvision->lock); | ||
617 | call_all(usbvision, core, s_std, usbvision->tvnormId); | 609 | call_all(usbvision, core, s_std, usbvision->tvnormId); |
618 | mutex_unlock(&usbvision->lock); | ||
619 | /* propagate the change to the decoder */ | 610 | /* propagate the change to the decoder */ |
620 | usbvision_muxsel(usbvision, usbvision->ctl_input); | 611 | usbvision_muxsel(usbvision, usbvision->ctl_input); |
621 | 612 | ||
@@ -977,9 +968,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
977 | usbvision->curFrame = NULL; | 968 | usbvision->curFrame = NULL; |
978 | 969 | ||
979 | /* by now we are committed to the new data... */ | 970 | /* by now we are committed to the new data... */ |
980 | mutex_lock(&usbvision->lock); | ||
981 | usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); | 971 | usbvision_set_output(usbvision, vf->fmt.pix.width, vf->fmt.pix.height); |
982 | mutex_unlock(&usbvision->lock); | ||
983 | 972 | ||
984 | return 0; | 973 | return 0; |
985 | } | 974 | } |
@@ -1100,16 +1089,12 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1100 | 1089 | ||
1101 | PDEBUG(DBG_MMAP, "mmap"); | 1090 | PDEBUG(DBG_MMAP, "mmap"); |
1102 | 1091 | ||
1103 | mutex_lock(&usbvision->lock); | ||
1104 | |||
1105 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { | 1092 | if (!USBVISION_IS_OPERATIONAL(usbvision)) { |
1106 | mutex_unlock(&usbvision->lock); | ||
1107 | return -EFAULT; | 1093 | return -EFAULT; |
1108 | } | 1094 | } |
1109 | 1095 | ||
1110 | if (!(vma->vm_flags & VM_WRITE) || | 1096 | if (!(vma->vm_flags & VM_WRITE) || |
1111 | size != PAGE_ALIGN(usbvision->max_frame_size)) { | 1097 | size != PAGE_ALIGN(usbvision->max_frame_size)) { |
1112 | mutex_unlock(&usbvision->lock); | ||
1113 | return -EINVAL; | 1098 | return -EINVAL; |
1114 | } | 1099 | } |
1115 | 1100 | ||
@@ -1121,7 +1106,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1121 | if (i == usbvision->num_frames) { | 1106 | if (i == usbvision->num_frames) { |
1122 | PDEBUG(DBG_MMAP, | 1107 | PDEBUG(DBG_MMAP, |
1123 | "mmap: user supplied mapping address is out of range"); | 1108 | "mmap: user supplied mapping address is out of range"); |
1124 | mutex_unlock(&usbvision->lock); | ||
1125 | return -EINVAL; | 1109 | return -EINVAL; |
1126 | } | 1110 | } |
1127 | 1111 | ||
@@ -1134,7 +1118,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1134 | 1118 | ||
1135 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 1119 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
1136 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); | 1120 | PDEBUG(DBG_MMAP, "mmap: vm_insert_page failed"); |
1137 | mutex_unlock(&usbvision->lock); | ||
1138 | return -EAGAIN; | 1121 | return -EAGAIN; |
1139 | } | 1122 | } |
1140 | start += PAGE_SIZE; | 1123 | start += PAGE_SIZE; |
@@ -1142,7 +1125,6 @@ static int usbvision_v4l2_mmap(struct file *file, struct vm_area_struct *vma) | |||
1142 | size -= PAGE_SIZE; | 1125 | size -= PAGE_SIZE; |
1143 | } | 1126 | } |
1144 | 1127 | ||
1145 | mutex_unlock(&usbvision->lock); | ||
1146 | return 0; | 1128 | return 0; |
1147 | } | 1129 | } |
1148 | 1130 | ||
@@ -1158,8 +1140,6 @@ static int usbvision_radio_open(struct file *file) | |||
1158 | 1140 | ||
1159 | PDEBUG(DBG_IO, "%s:", __func__); | 1141 | PDEBUG(DBG_IO, "%s:", __func__); |
1160 | 1142 | ||
1161 | mutex_lock(&usbvision->lock); | ||
1162 | |||
1163 | if (usbvision->user) { | 1143 | if (usbvision->user) { |
1164 | dev_err(&usbvision->rdev->dev, | 1144 | dev_err(&usbvision->rdev->dev, |
1165 | "%s: Someone tried to open an already opened USBVision Radio!\n", | 1145 | "%s: Someone tried to open an already opened USBVision Radio!\n", |
@@ -1198,7 +1178,6 @@ static int usbvision_radio_open(struct file *file) | |||
1198 | } | 1178 | } |
1199 | } | 1179 | } |
1200 | out: | 1180 | out: |
1201 | mutex_unlock(&usbvision->lock); | ||
1202 | return errCode; | 1181 | return errCode; |
1203 | } | 1182 | } |
1204 | 1183 | ||
@@ -1210,8 +1189,6 @@ static int usbvision_radio_close(struct file *file) | |||
1210 | 1189 | ||
1211 | PDEBUG(DBG_IO, ""); | 1190 | PDEBUG(DBG_IO, ""); |
1212 | 1191 | ||
1213 | mutex_lock(&usbvision->lock); | ||
1214 | |||
1215 | /* Set packet size to 0 */ | 1192 | /* Set packet size to 0 */ |
1216 | usbvision->ifaceAlt=0; | 1193 | usbvision->ifaceAlt=0; |
1217 | errCode = usb_set_interface(usbvision->dev, usbvision->iface, | 1194 | errCode = usb_set_interface(usbvision->dev, usbvision->iface, |
@@ -1226,8 +1203,6 @@ static int usbvision_radio_close(struct file *file) | |||
1226 | usbvision->initialized = 0; | 1203 | usbvision->initialized = 0; |
1227 | } | 1204 | } |
1228 | 1205 | ||
1229 | mutex_unlock(&usbvision->lock); | ||
1230 | |||
1231 | if (usbvision->remove_pending) { | 1206 | if (usbvision->remove_pending) { |
1232 | printk(KERN_INFO "%s: Final disconnect\n", __func__); | 1207 | printk(KERN_INFO "%s: Final disconnect\n", __func__); |
1233 | usbvision_release(usbvision); | 1208 | usbvision_release(usbvision); |
@@ -1248,7 +1223,7 @@ static const struct v4l2_file_operations usbvision_fops = { | |||
1248 | .release = usbvision_v4l2_close, | 1223 | .release = usbvision_v4l2_close, |
1249 | .read = usbvision_v4l2_read, | 1224 | .read = usbvision_v4l2_read, |
1250 | .mmap = usbvision_v4l2_mmap, | 1225 | .mmap = usbvision_v4l2_mmap, |
1251 | .ioctl = video_ioctl2, | 1226 | .unlocked_ioctl = video_ioctl2, |
1252 | /* .poll = video_poll, */ | 1227 | /* .poll = video_poll, */ |
1253 | }; | 1228 | }; |
1254 | 1229 | ||
@@ -1298,7 +1273,7 @@ static const struct v4l2_file_operations usbvision_radio_fops = { | |||
1298 | .owner = THIS_MODULE, | 1273 | .owner = THIS_MODULE, |
1299 | .open = usbvision_radio_open, | 1274 | .open = usbvision_radio_open, |
1300 | .release = usbvision_radio_close, | 1275 | .release = usbvision_radio_close, |
1301 | .ioctl = video_ioctl2, | 1276 | .unlocked_ioctl = video_ioctl2, |
1302 | }; | 1277 | }; |
1303 | 1278 | ||
1304 | static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { | 1279 | static const struct v4l2_ioctl_ops usbvision_radio_ioctl_ops = { |
@@ -1346,6 +1321,7 @@ static struct video_device *usbvision_vdev_init(struct usb_usbvision *usbvision, | |||
1346 | return NULL; | 1321 | return NULL; |
1347 | } | 1322 | } |
1348 | *vdev = *vdev_template; | 1323 | *vdev = *vdev_template; |
1324 | vdev->lock = &usbvision->v4l2_lock; | ||
1349 | vdev->v4l2_dev = &usbvision->v4l2_dev; | 1325 | vdev->v4l2_dev = &usbvision->v4l2_dev; |
1350 | snprintf(vdev->name, sizeof(vdev->name), "%s", name); | 1326 | snprintf(vdev->name, sizeof(vdev->name), "%s", name); |
1351 | video_set_drvdata(vdev, usbvision); | 1327 | video_set_drvdata(vdev, usbvision); |
@@ -1448,7 +1424,7 @@ static struct usb_usbvision *usbvision_alloc(struct usb_device *dev, | |||
1448 | if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev)) | 1424 | if (v4l2_device_register(&intf->dev, &usbvision->v4l2_dev)) |
1449 | goto err_free; | 1425 | goto err_free; |
1450 | 1426 | ||
1451 | mutex_init(&usbvision->lock); /* available */ | 1427 | mutex_init(&usbvision->v4l2_lock); |
1452 | 1428 | ||
1453 | // prepare control urb for control messages during interrupts | 1429 | // prepare control urb for control messages during interrupts |
1454 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); | 1430 | usbvision->ctrlUrb = usb_alloc_urb(USBVISION_URB_FRAMES, GFP_KERNEL); |
@@ -1478,14 +1454,10 @@ static void usbvision_release(struct usb_usbvision *usbvision) | |||
1478 | { | 1454 | { |
1479 | PDEBUG(DBG_PROBE, ""); | 1455 | PDEBUG(DBG_PROBE, ""); |
1480 | 1456 | ||
1481 | mutex_lock(&usbvision->lock); | ||
1482 | |||
1483 | usbvision_reset_powerOffTimer(usbvision); | 1457 | usbvision_reset_powerOffTimer(usbvision); |
1484 | 1458 | ||
1485 | usbvision->initialized = 0; | 1459 | usbvision->initialized = 0; |
1486 | 1460 | ||
1487 | mutex_unlock(&usbvision->lock); | ||
1488 | |||
1489 | usbvision_remove_sysfs(usbvision->vdev); | 1461 | usbvision_remove_sysfs(usbvision->vdev); |
1490 | usbvision_unregister_video(usbvision); | 1462 | usbvision_unregister_video(usbvision); |
1491 | 1463 | ||
@@ -1598,8 +1570,6 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1598 | } | 1570 | } |
1599 | PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType); | 1571 | PDEBUG(DBG_PROBE, "bridgeType %d", usbvision->bridgeType); |
1600 | 1572 | ||
1601 | mutex_lock(&usbvision->lock); | ||
1602 | |||
1603 | /* compute alternate max packet sizes */ | 1573 | /* compute alternate max packet sizes */ |
1604 | uif = dev->actconfig->interface[0]; | 1574 | uif = dev->actconfig->interface[0]; |
1605 | 1575 | ||
@@ -1609,7 +1579,6 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1609 | usbvision->num_alt,GFP_KERNEL); | 1579 | usbvision->num_alt,GFP_KERNEL); |
1610 | if (usbvision->alt_max_pkt_size == NULL) { | 1580 | if (usbvision->alt_max_pkt_size == NULL) { |
1611 | dev_err(&intf->dev, "usbvision: out of memory!\n"); | 1581 | dev_err(&intf->dev, "usbvision: out of memory!\n"); |
1612 | mutex_unlock(&usbvision->lock); | ||
1613 | return -ENOMEM; | 1582 | return -ENOMEM; |
1614 | } | 1583 | } |
1615 | 1584 | ||
@@ -1641,7 +1610,6 @@ static int __devinit usbvision_probe(struct usb_interface *intf, | |||
1641 | usbvision->streaming = Stream_Off; | 1610 | usbvision->streaming = Stream_Off; |
1642 | usbvision_configure_video(usbvision); | 1611 | usbvision_configure_video(usbvision); |
1643 | usbvision_register_video(usbvision); | 1612 | usbvision_register_video(usbvision); |
1644 | mutex_unlock(&usbvision->lock); | ||
1645 | 1613 | ||
1646 | usbvision_create_sysfs(usbvision->vdev); | 1614 | usbvision_create_sysfs(usbvision->vdev); |
1647 | 1615 | ||
@@ -1669,7 +1637,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
1669 | return; | 1637 | return; |
1670 | } | 1638 | } |
1671 | 1639 | ||
1672 | mutex_lock(&usbvision->lock); | 1640 | mutex_lock(&usbvision->v4l2_lock); |
1673 | 1641 | ||
1674 | // At this time we ask to cancel outstanding URBs | 1642 | // At this time we ask to cancel outstanding URBs |
1675 | usbvision_stop_isoc(usbvision); | 1643 | usbvision_stop_isoc(usbvision); |
@@ -1685,7 +1653,7 @@ static void __devexit usbvision_disconnect(struct usb_interface *intf) | |||
1685 | usb_put_dev(usbvision->dev); | 1653 | usb_put_dev(usbvision->dev); |
1686 | usbvision->dev = NULL; // USB device is no more | 1654 | usbvision->dev = NULL; // USB device is no more |
1687 | 1655 | ||
1688 | mutex_unlock(&usbvision->lock); | 1656 | mutex_unlock(&usbvision->v4l2_lock); |
1689 | 1657 | ||
1690 | if (usbvision->user) { | 1658 | if (usbvision->user) { |
1691 | printk(KERN_INFO "%s: In use, disconnect pending\n", | 1659 | 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 cc4e96c8cd6c..2271ede78ddf 100644 --- a/drivers/media/video/usbvision/usbvision.h +++ b/drivers/media/video/usbvision/usbvision.h | |||
@@ -391,7 +391,7 @@ struct usb_usbvision { | |||
391 | unsigned char iface; /* Video interface number */ | 391 | unsigned char iface; /* Video interface number */ |
392 | unsigned char ifaceAlt; /* Alt settings */ | 392 | unsigned char ifaceAlt; /* Alt settings */ |
393 | unsigned char Vin_Reg2_Preset; | 393 | unsigned char Vin_Reg2_Preset; |
394 | struct mutex lock; | 394 | struct mutex v4l2_lock; |
395 | struct timer_list powerOffTimer; | 395 | struct timer_list powerOffTimer; |
396 | struct work_struct powerOffWork; | 396 | struct work_struct powerOffWork; |
397 | int power; /* is the device powered on? */ | 397 | int power; /* is the device powered on? */ |