aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-09-26 07:01:18 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:06:15 -0400
commit361ae54fc7f06a0cee1fb6e6a659a42556b56702 (patch)
treefc952bedcc1e5de5bee879dd32c0b09702aa0fb1 /drivers/media/radio
parentd5906dd6564bbf59a27bf1be87743b8794b5468e (diff)
V4L/DVB: radio-mr800: remove BKL
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/radio-mr800.c74
1 files changed, 10 insertions, 64 deletions
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 353b82855949..97967ad3cd12 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -176,8 +176,6 @@ static int amradio_set_mute(struct amradio_device *radio, char argument)
176 int retval; 176 int retval;
177 int size; 177 int size;
178 178
179 BUG_ON(!mutex_is_locked(&radio->lock));
180
181 radio->buffer[0] = 0x00; 179 radio->buffer[0] = 0x00;
182 radio->buffer[1] = 0x55; 180 radio->buffer[1] = 0x55;
183 radio->buffer[2] = 0xaa; 181 radio->buffer[2] = 0xaa;
@@ -207,8 +205,6 @@ static int amradio_setfreq(struct amradio_device *radio, int freq)
207 int size; 205 int size;
208 unsigned short freq_send = 0x10 + (freq >> 3) / 25; 206 unsigned short freq_send = 0x10 + (freq >> 3) / 25;
209 207
210 BUG_ON(!mutex_is_locked(&radio->lock));
211
212 radio->buffer[0] = 0x00; 208 radio->buffer[0] = 0x00;
213 radio->buffer[1] = 0x55; 209 radio->buffer[1] = 0x55;
214 radio->buffer[2] = 0xaa; 210 radio->buffer[2] = 0xaa;
@@ -253,8 +249,6 @@ static int amradio_set_stereo(struct amradio_device *radio, char argument)
253 int retval; 249 int retval;
254 int size; 250 int size;
255 251
256 BUG_ON(!mutex_is_locked(&radio->lock));
257
258 radio->buffer[0] = 0x00; 252 radio->buffer[0] = 0x00;
259 radio->buffer[1] = 0x55; 253 radio->buffer[1] = 0x55;
260 radio->buffer[2] = 0xaa; 254 radio->buffer[2] = 0xaa;
@@ -290,11 +284,9 @@ static void usb_amradio_disconnect(struct usb_interface *intf)
290 struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf)); 284 struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
291 285
292 mutex_lock(&radio->lock); 286 mutex_lock(&radio->lock);
293 radio->usbdev = NULL;
294 mutex_unlock(&radio->lock);
295
296 v4l2_device_disconnect(&radio->v4l2_dev); 287 v4l2_device_disconnect(&radio->v4l2_dev);
297 video_unregister_device(&radio->videodev); 288 video_unregister_device(&radio->videodev);
289 mutex_unlock(&radio->lock);
298} 290}
299 291
300/* vidioc_querycap - query device capabilities */ 292/* vidioc_querycap - query device capabilities */
@@ -503,28 +495,18 @@ out:
503static int usb_amradio_open(struct file *file) 495static int usb_amradio_open(struct file *file)
504{ 496{
505 struct amradio_device *radio = video_drvdata(file); 497 struct amradio_device *radio = video_drvdata(file);
506 int retval = 0; 498 int retval;
507
508 mutex_lock(&radio->lock);
509
510 if (!radio->usbdev) {
511 retval = -EIO;
512 goto unlock;
513 }
514 499
515 file->private_data = radio; 500 file->private_data = radio;
516 retval = usb_autopm_get_interface(radio->intf); 501 retval = usb_autopm_get_interface(radio->intf);
517 if (retval) 502 if (retval)
518 goto unlock; 503 return retval;
519 504
520 if (unlikely(!radio->initialized)) { 505 if (unlikely(!radio->initialized)) {
521 retval = usb_amradio_init(radio); 506 retval = usb_amradio_init(radio);
522 if (retval) 507 if (retval)
523 usb_autopm_put_interface(radio->intf); 508 usb_autopm_put_interface(radio->intf);
524 } 509 }
525
526unlock:
527 mutex_unlock(&radio->lock);
528 return retval; 510 return retval;
529} 511}
530 512
@@ -532,37 +514,9 @@ unlock:
532static int usb_amradio_close(struct file *file) 514static int usb_amradio_close(struct file *file)
533{ 515{
534 struct amradio_device *radio = file->private_data; 516 struct amradio_device *radio = file->private_data;
535 int retval = 0;
536
537 mutex_lock(&radio->lock);
538
539 if (!radio->usbdev)
540 retval = -EIO;
541 else
542 usb_autopm_put_interface(radio->intf);
543
544 mutex_unlock(&radio->lock);
545 return retval;
546}
547
548static long usb_amradio_ioctl(struct file *file, unsigned int cmd,
549 unsigned long arg)
550{
551 struct amradio_device *radio = file->private_data;
552 long retval = 0;
553
554 mutex_lock(&radio->lock);
555
556 if (!radio->usbdev) {
557 retval = -EIO;
558 goto unlock;
559 }
560
561 retval = video_ioctl2(file, cmd, arg);
562 517
563unlock: 518 usb_autopm_put_interface(radio->intf);
564 mutex_unlock(&radio->lock); 519 return 0;
565 return retval;
566} 520}
567 521
568/* Suspend device - stop device. Need to be checked and fixed */ 522/* Suspend device - stop device. Need to be checked and fixed */
@@ -570,16 +524,12 @@ static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message)
570{ 524{
571 struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf)); 525 struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
572 526
573 mutex_lock(&radio->lock);
574
575 if (!radio->muted && radio->initialized) { 527 if (!radio->muted && radio->initialized) {
576 amradio_set_mute(radio, AMRADIO_STOP); 528 amradio_set_mute(radio, AMRADIO_STOP);
577 radio->muted = 0; 529 radio->muted = 0;
578 } 530 }
579 531
580 dev_info(&intf->dev, "going into suspend..\n"); 532 dev_info(&intf->dev, "going into suspend..\n");
581
582 mutex_unlock(&radio->lock);
583 return 0; 533 return 0;
584} 534}
585 535
@@ -588,10 +538,8 @@ static int usb_amradio_resume(struct usb_interface *intf)
588{ 538{
589 struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf)); 539 struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf));
590 540
591 mutex_lock(&radio->lock);
592
593 if (unlikely(!radio->initialized)) 541 if (unlikely(!radio->initialized))
594 goto unlock; 542 return 0;
595 543
596 if (radio->stereo) 544 if (radio->stereo)
597 amradio_set_stereo(radio, WANT_STEREO); 545 amradio_set_stereo(radio, WANT_STEREO);
@@ -603,10 +551,7 @@ static int usb_amradio_resume(struct usb_interface *intf)
603 if (!radio->muted) 551 if (!radio->muted)
604 amradio_set_mute(radio, AMRADIO_START); 552 amradio_set_mute(radio, AMRADIO_START);
605 553
606unlock:
607 dev_info(&intf->dev, "coming out of suspend..\n"); 554 dev_info(&intf->dev, "coming out of suspend..\n");
608
609 mutex_unlock(&radio->lock);
610 return 0; 555 return 0;
611} 556}
612 557
@@ -615,7 +560,7 @@ static const struct v4l2_file_operations usb_amradio_fops = {
615 .owner = THIS_MODULE, 560 .owner = THIS_MODULE,
616 .open = usb_amradio_open, 561 .open = usb_amradio_open,
617 .release = usb_amradio_close, 562 .release = usb_amradio_close,
618 .ioctl = usb_amradio_ioctl, 563 .unlocked_ioctl = video_ioctl2,
619}; 564};
620 565
621static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = { 566static const struct v4l2_ioctl_ops usb_amradio_ioctl_ops = {
@@ -671,19 +616,20 @@ static int usb_amradio_probe(struct usb_interface *intf,
671 goto err_v4l2; 616 goto err_v4l2;
672 } 617 }
673 618
619 mutex_init(&radio->lock);
620
674 strlcpy(radio->videodev.name, radio->v4l2_dev.name, 621 strlcpy(radio->videodev.name, radio->v4l2_dev.name,
675 sizeof(radio->videodev.name)); 622 sizeof(radio->videodev.name));
676 radio->videodev.v4l2_dev = &radio->v4l2_dev; 623 radio->videodev.v4l2_dev = &radio->v4l2_dev;
677 radio->videodev.fops = &usb_amradio_fops; 624 radio->videodev.fops = &usb_amradio_fops;
678 radio->videodev.ioctl_ops = &usb_amradio_ioctl_ops; 625 radio->videodev.ioctl_ops = &usb_amradio_ioctl_ops;
679 radio->videodev.release = usb_amradio_video_device_release; 626 radio->videodev.release = usb_amradio_video_device_release;
627 radio->videodev.lock = &radio->lock;
680 628
681 radio->usbdev = interface_to_usbdev(intf); 629 radio->usbdev = interface_to_usbdev(intf);
682 radio->intf = intf; 630 radio->intf = intf;
683 radio->curfreq = 95.16 * FREQ_MUL; 631 radio->curfreq = 95.16 * FREQ_MUL;
684 632
685 mutex_init(&radio->lock);
686
687 video_set_drvdata(&radio->videodev, radio); 633 video_set_drvdata(&radio->videodev, radio);
688 634
689 retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, 635 retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO,