aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorOliver Neukum <oliver@neukum.org>2009-11-09 17:09:49 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-12-05 15:41:42 -0500
commitd89ce0d9ec9f980d59eae8d5a0ead98988e3b545 (patch)
tree38f34ca547e5b9d5e37fdc875072f34b7f4d7258 /drivers/media
parent87918334792a4d8a73b0511466b77bd6aa055db3 (diff)
V4L/DVB (13402): radio-mr800 - autosuspend for radio-mr800 driver
Patch adds autosuspend support for mr800 radio driver. Signed-off-by: Oliver Neukum <oliver@neukum.org> Acked-by: Alexey Klimov <klimov.linux@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/radio/radio-mr800.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 4064109c4205..44efa68d9f8e 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -132,6 +132,7 @@ static int usb_amradio_resume(struct usb_interface *intf);
132struct amradio_device { 132struct amradio_device {
133 /* reference to USB and video device */ 133 /* reference to USB and video device */
134 struct usb_device *usbdev; 134 struct usb_device *usbdev;
135 struct usb_interface *intf;
135 struct video_device videodev; 136 struct video_device videodev;
136 struct v4l2_device v4l2_dev; 137 struct v4l2_device v4l2_dev;
137 138
@@ -163,7 +164,7 @@ static struct usb_driver usb_amradio_driver = {
163 .resume = usb_amradio_resume, 164 .resume = usb_amradio_resume,
164 .reset_resume = usb_amradio_resume, 165 .reset_resume = usb_amradio_resume,
165 .id_table = usb_amradio_device_table, 166 .id_table = usb_amradio_device_table,
166 .supports_autosuspend = 0, 167 .supports_autosuspend = 1,
167}; 168};
168 169
169/* switch on/off the radio. Send 8 bytes to device */ 170/* switch on/off the radio. Send 8 bytes to device */
@@ -506,9 +507,15 @@ static int usb_amradio_open(struct file *file)
506 } 507 }
507 508
508 file->private_data = radio; 509 file->private_data = radio;
510 retval = usb_autopm_get_interface(radio->intf);
511 if (retval)
512 goto unlock;
509 513
510 if (unlikely(!radio->initialized)) 514 if (unlikely(!radio->initialized)) {
511 retval = usb_amradio_init(radio); 515 retval = usb_amradio_init(radio);
516 if (retval)
517 usb_autopm_put_interface(radio->intf);
518 }
512 519
513unlock: 520unlock:
514 mutex_unlock(&radio->lock); 521 mutex_unlock(&radio->lock);
@@ -525,6 +532,8 @@ static int usb_amradio_close(struct file *file)
525 532
526 if (!radio->usbdev) 533 if (!radio->usbdev)
527 retval = -EIO; 534 retval = -EIO;
535 else
536 usb_autopm_put_interface(radio->intf);
528 537
529 mutex_unlock(&radio->lock); 538 mutex_unlock(&radio->lock);
530 return retval; 539 return retval;
@@ -666,6 +675,7 @@ static int usb_amradio_probe(struct usb_interface *intf,
666 radio->videodev.release = usb_amradio_video_device_release; 675 radio->videodev.release = usb_amradio_video_device_release;
667 676
668 radio->usbdev = interface_to_usbdev(intf); 677 radio->usbdev = interface_to_usbdev(intf);
678 radio->intf = intf;
669 radio->curfreq = 95.16 * FREQ_MUL; 679 radio->curfreq = 95.16 * FREQ_MUL;
670 680
671 mutex_init(&radio->lock); 681 mutex_init(&radio->lock);