diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-12-19 16:54:08 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 15:38:07 -0400 |
commit | e64d07c92daa5c7973c1d4433f939a4e0fa3beb9 (patch) | |
tree | badf3e43a17c2741b889becb401b09ba189dae26 /drivers/media/radio | |
parent | 2335e2b817186cf79a07311f14560ef8b30f6a9a (diff) |
[media] dsbr100: convert to unlocked_ioctl
Use core-assisted locking so .ioctl can be replaced by .unlocked_ioctl.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/dsbr100.c | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/drivers/media/radio/dsbr100.c b/drivers/media/radio/dsbr100.c index ed9cd7ad0604..bf2dd6ff042a 100644 --- a/drivers/media/radio/dsbr100.c +++ b/drivers/media/radio/dsbr100.c | |||
@@ -148,7 +148,7 @@ struct dsbr100_device { | |||
148 | struct v4l2_device v4l2_dev; | 148 | struct v4l2_device v4l2_dev; |
149 | 149 | ||
150 | u8 *transfer_buffer; | 150 | u8 *transfer_buffer; |
151 | struct mutex lock; /* buffer locking */ | 151 | struct mutex v4l2_lock; |
152 | int curfreq; | 152 | int curfreq; |
153 | int stereo; | 153 | int stereo; |
154 | int removed; | 154 | int removed; |
@@ -182,8 +182,6 @@ static int dsbr100_start(struct dsbr100_device *radio) | |||
182 | int retval; | 182 | int retval; |
183 | int request; | 183 | int request; |
184 | 184 | ||
185 | mutex_lock(&radio->lock); | ||
186 | |||
187 | retval = usb_control_msg(radio->usbdev, | 185 | retval = usb_control_msg(radio->usbdev, |
188 | usb_rcvctrlpipe(radio->usbdev, 0), | 186 | usb_rcvctrlpipe(radio->usbdev, 0), |
189 | USB_REQ_GET_STATUS, | 187 | USB_REQ_GET_STATUS, |
@@ -207,11 +205,9 @@ static int dsbr100_start(struct dsbr100_device *radio) | |||
207 | } | 205 | } |
208 | 206 | ||
209 | radio->status = STARTED; | 207 | radio->status = STARTED; |
210 | mutex_unlock(&radio->lock); | ||
211 | return (radio->transfer_buffer)[0]; | 208 | return (radio->transfer_buffer)[0]; |
212 | 209 | ||
213 | usb_control_msg_failed: | 210 | usb_control_msg_failed: |
214 | mutex_unlock(&radio->lock); | ||
215 | dev_err(&radio->usbdev->dev, | 211 | dev_err(&radio->usbdev->dev, |
216 | "%s - usb_control_msg returned %i, request %i\n", | 212 | "%s - usb_control_msg returned %i, request %i\n", |
217 | __func__, retval, request); | 213 | __func__, retval, request); |
@@ -225,8 +221,6 @@ static int dsbr100_stop(struct dsbr100_device *radio) | |||
225 | int retval; | 221 | int retval; |
226 | int request; | 222 | int request; |
227 | 223 | ||
228 | mutex_lock(&radio->lock); | ||
229 | |||
230 | retval = usb_control_msg(radio->usbdev, | 224 | retval = usb_control_msg(radio->usbdev, |
231 | usb_rcvctrlpipe(radio->usbdev, 0), | 225 | usb_rcvctrlpipe(radio->usbdev, 0), |
232 | USB_REQ_GET_STATUS, | 226 | USB_REQ_GET_STATUS, |
@@ -250,11 +244,9 @@ static int dsbr100_stop(struct dsbr100_device *radio) | |||
250 | } | 244 | } |
251 | 245 | ||
252 | radio->status = STOPPED; | 246 | radio->status = STOPPED; |
253 | mutex_unlock(&radio->lock); | ||
254 | return (radio->transfer_buffer)[0]; | 247 | return (radio->transfer_buffer)[0]; |
255 | 248 | ||
256 | usb_control_msg_failed: | 249 | usb_control_msg_failed: |
257 | mutex_unlock(&radio->lock); | ||
258 | dev_err(&radio->usbdev->dev, | 250 | dev_err(&radio->usbdev->dev, |
259 | "%s - usb_control_msg returned %i, request %i\n", | 251 | "%s - usb_control_msg returned %i, request %i\n", |
260 | __func__, retval, request); | 252 | __func__, retval, request); |
@@ -269,8 +261,6 @@ static int dsbr100_setfreq(struct dsbr100_device *radio) | |||
269 | int request; | 261 | int request; |
270 | int freq = (radio->curfreq / 16 * 80) / 1000 + 856; | 262 | int freq = (radio->curfreq / 16 * 80) / 1000 + 856; |
271 | 263 | ||
272 | mutex_lock(&radio->lock); | ||
273 | |||
274 | retval = usb_control_msg(radio->usbdev, | 264 | retval = usb_control_msg(radio->usbdev, |
275 | usb_rcvctrlpipe(radio->usbdev, 0), | 265 | usb_rcvctrlpipe(radio->usbdev, 0), |
276 | DSB100_TUNE, | 266 | DSB100_TUNE, |
@@ -306,12 +296,10 @@ static int dsbr100_setfreq(struct dsbr100_device *radio) | |||
306 | } | 296 | } |
307 | 297 | ||
308 | radio->stereo = !((radio->transfer_buffer)[0] & 0x01); | 298 | radio->stereo = !((radio->transfer_buffer)[0] & 0x01); |
309 | mutex_unlock(&radio->lock); | ||
310 | return (radio->transfer_buffer)[0]; | 299 | return (radio->transfer_buffer)[0]; |
311 | 300 | ||
312 | usb_control_msg_failed: | 301 | usb_control_msg_failed: |
313 | radio->stereo = -1; | 302 | radio->stereo = -1; |
314 | mutex_unlock(&radio->lock); | ||
315 | dev_err(&radio->usbdev->dev, | 303 | dev_err(&radio->usbdev->dev, |
316 | "%s - usb_control_msg returned %i, request %i\n", | 304 | "%s - usb_control_msg returned %i, request %i\n", |
317 | __func__, retval, request); | 305 | __func__, retval, request); |
@@ -324,8 +312,6 @@ static void dsbr100_getstat(struct dsbr100_device *radio) | |||
324 | { | 312 | { |
325 | int retval; | 313 | int retval; |
326 | 314 | ||
327 | mutex_lock(&radio->lock); | ||
328 | |||
329 | retval = usb_control_msg(radio->usbdev, | 315 | retval = usb_control_msg(radio->usbdev, |
330 | usb_rcvctrlpipe(radio->usbdev, 0), | 316 | usb_rcvctrlpipe(radio->usbdev, 0), |
331 | USB_REQ_GET_STATUS, | 317 | USB_REQ_GET_STATUS, |
@@ -340,33 +326,8 @@ static void dsbr100_getstat(struct dsbr100_device *radio) | |||
340 | } else { | 326 | } else { |
341 | radio->stereo = !(radio->transfer_buffer[0] & 0x01); | 327 | radio->stereo = !(radio->transfer_buffer[0] & 0x01); |
342 | } | 328 | } |
343 | |||
344 | mutex_unlock(&radio->lock); | ||
345 | } | ||
346 | |||
347 | /* USB subsystem interface begins here */ | ||
348 | |||
349 | /* | ||
350 | * Handle unplugging of the device. | ||
351 | * We call video_unregister_device in any case. | ||
352 | * The last function called in this procedure is | ||
353 | * usb_dsbr100_video_device_release | ||
354 | */ | ||
355 | static void usb_dsbr100_disconnect(struct usb_interface *intf) | ||
356 | { | ||
357 | struct dsbr100_device *radio = usb_get_intfdata(intf); | ||
358 | |||
359 | usb_set_intfdata (intf, NULL); | ||
360 | |||
361 | mutex_lock(&radio->lock); | ||
362 | radio->removed = 1; | ||
363 | mutex_unlock(&radio->lock); | ||
364 | |||
365 | video_unregister_device(&radio->videodev); | ||
366 | v4l2_device_disconnect(&radio->v4l2_dev); | ||
367 | } | 329 | } |
368 | 330 | ||
369 | |||
370 | static int vidioc_querycap(struct file *file, void *priv, | 331 | static int vidioc_querycap(struct file *file, void *priv, |
371 | struct v4l2_capability *v) | 332 | struct v4l2_capability *v) |
372 | { | 333 | { |
@@ -432,9 +393,7 @@ static int vidioc_s_frequency(struct file *file, void *priv, | |||
432 | if (radio->removed) | 393 | if (radio->removed) |
433 | return -EIO; | 394 | return -EIO; |
434 | 395 | ||
435 | mutex_lock(&radio->lock); | ||
436 | radio->curfreq = f->frequency; | 396 | radio->curfreq = f->frequency; |
437 | mutex_unlock(&radio->lock); | ||
438 | 397 | ||
439 | retval = dsbr100_setfreq(radio); | 398 | retval = dsbr100_setfreq(radio); |
440 | if (retval < 0) | 399 | if (retval < 0) |
@@ -548,12 +507,36 @@ static int vidioc_s_audio(struct file *file, void *priv, | |||
548 | return 0; | 507 | return 0; |
549 | } | 508 | } |
550 | 509 | ||
510 | /* USB subsystem interface begins here */ | ||
511 | |||
512 | /* | ||
513 | * Handle unplugging of the device. | ||
514 | * We call video_unregister_device in any case. | ||
515 | * The last function called in this procedure is | ||
516 | * usb_dsbr100_video_device_release | ||
517 | */ | ||
518 | static void usb_dsbr100_disconnect(struct usb_interface *intf) | ||
519 | { | ||
520 | struct dsbr100_device *radio = usb_get_intfdata(intf); | ||
521 | |||
522 | usb_set_intfdata(intf, NULL); | ||
523 | |||
524 | mutex_lock(&radio->v4l2_lock); | ||
525 | radio->removed = 1; | ||
526 | mutex_unlock(&radio->v4l2_lock); | ||
527 | |||
528 | video_unregister_device(&radio->videodev); | ||
529 | v4l2_device_disconnect(&radio->v4l2_dev); | ||
530 | } | ||
531 | |||
532 | |||
551 | /* Suspend device - stop device. */ | 533 | /* Suspend device - stop device. */ |
552 | static int usb_dsbr100_suspend(struct usb_interface *intf, pm_message_t message) | 534 | static int usb_dsbr100_suspend(struct usb_interface *intf, pm_message_t message) |
553 | { | 535 | { |
554 | struct dsbr100_device *radio = usb_get_intfdata(intf); | 536 | struct dsbr100_device *radio = usb_get_intfdata(intf); |
555 | int retval; | 537 | int retval; |
556 | 538 | ||
539 | mutex_lock(&radio->v4l2_lock); | ||
557 | if (radio->status == STARTED) { | 540 | if (radio->status == STARTED) { |
558 | retval = dsbr100_stop(radio); | 541 | retval = dsbr100_stop(radio); |
559 | if (retval < 0) | 542 | if (retval < 0) |
@@ -564,11 +547,9 @@ static int usb_dsbr100_suspend(struct usb_interface *intf, pm_message_t message) | |||
564 | * we set status equal to STARTED. | 547 | * we set status equal to STARTED. |
565 | * On resume we will check status and run radio if needed. | 548 | * On resume we will check status and run radio if needed. |
566 | */ | 549 | */ |
567 | |||
568 | mutex_lock(&radio->lock); | ||
569 | radio->status = STARTED; | 550 | radio->status = STARTED; |
570 | mutex_unlock(&radio->lock); | ||
571 | } | 551 | } |
552 | mutex_unlock(&radio->v4l2_lock); | ||
572 | 553 | ||
573 | dev_info(&intf->dev, "going into suspend..\n"); | 554 | dev_info(&intf->dev, "going into suspend..\n"); |
574 | 555 | ||
@@ -581,11 +562,13 @@ static int usb_dsbr100_resume(struct usb_interface *intf) | |||
581 | struct dsbr100_device *radio = usb_get_intfdata(intf); | 562 | struct dsbr100_device *radio = usb_get_intfdata(intf); |
582 | int retval; | 563 | int retval; |
583 | 564 | ||
565 | mutex_lock(&radio->v4l2_lock); | ||
584 | if (radio->status == STARTED) { | 566 | if (radio->status == STARTED) { |
585 | retval = dsbr100_start(radio); | 567 | retval = dsbr100_start(radio); |
586 | if (retval < 0) | 568 | if (retval < 0) |
587 | dev_warn(&intf->dev, "dsbr100_start failed\n"); | 569 | dev_warn(&intf->dev, "dsbr100_start failed\n"); |
588 | } | 570 | } |
571 | mutex_unlock(&radio->v4l2_lock); | ||
589 | 572 | ||
590 | dev_info(&intf->dev, "coming out of suspend..\n"); | 573 | dev_info(&intf->dev, "coming out of suspend..\n"); |
591 | 574 | ||
@@ -605,7 +588,7 @@ static void usb_dsbr100_video_device_release(struct video_device *videodev) | |||
605 | /* File system interface */ | 588 | /* File system interface */ |
606 | static const struct v4l2_file_operations usb_dsbr100_fops = { | 589 | static const struct v4l2_file_operations usb_dsbr100_fops = { |
607 | .owner = THIS_MODULE, | 590 | .owner = THIS_MODULE, |
608 | .ioctl = video_ioctl2, | 591 | .unlocked_ioctl = video_ioctl2, |
609 | }; | 592 | }; |
610 | 593 | ||
611 | static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { | 594 | static const struct v4l2_ioctl_ops usb_dsbr100_ioctl_ops = { |
@@ -653,13 +636,13 @@ static int usb_dsbr100_probe(struct usb_interface *intf, | |||
653 | return retval; | 636 | return retval; |
654 | } | 637 | } |
655 | 638 | ||
639 | mutex_init(&radio->v4l2_lock); | ||
656 | strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name)); | 640 | strlcpy(radio->videodev.name, v4l2_dev->name, sizeof(radio->videodev.name)); |
657 | radio->videodev.v4l2_dev = v4l2_dev; | 641 | radio->videodev.v4l2_dev = v4l2_dev; |
658 | radio->videodev.fops = &usb_dsbr100_fops; | 642 | radio->videodev.fops = &usb_dsbr100_fops; |
659 | radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops; | 643 | radio->videodev.ioctl_ops = &usb_dsbr100_ioctl_ops; |
660 | radio->videodev.release = usb_dsbr100_video_device_release; | 644 | radio->videodev.release = usb_dsbr100_video_device_release; |
661 | 645 | radio->videodev.lock = &radio->v4l2_lock; | |
662 | mutex_init(&radio->lock); | ||
663 | 646 | ||
664 | radio->removed = 0; | 647 | radio->removed = 0; |
665 | radio->usbdev = interface_to_usbdev(intf); | 648 | radio->usbdev = interface_to_usbdev(intf); |