public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexey Klimov <klimov.linux@gmail.com>
To: linux-media@vger.kernel.org
Cc: oliver@neukum.org, dougsland@gmail.com
Subject: [patch] radio-mr800 - autosuspend for radio-mr800 driver
Date: Tue, 10 Nov 2009 01:09:49 +0300	[thread overview]
Message-ID: <20091110010949.494ee080.klimov.linux@gmail.com> (raw)


From: Oliver Neukum <oliver@neukum.org>

Patch adds autosuspend support for mr800 radio driver.

Priority: normal

Signed-off-by: Oliver Neukum <oliver@neukum.org>
Acked-by: Alexey Klimov <klimov.linux@gmail.com>

--
diff -r 19c0469c02c3 linux/drivers/media/radio/radio-mr800.c
--- a/linux/drivers/media/radio/radio-mr800.c	Sat Nov 07 15:51:01 2009 -0200
+++ b/linux/drivers/media/radio/radio-mr800.c	Tue Nov 10 00:38:19 2009 +0300
@@ -133,6 +133,7 @@
 struct amradio_device {
 	/* reference to USB and video device */
 	struct usb_device *usbdev;
+	struct usb_interface *intf;
 	struct video_device videodev;
 	struct v4l2_device v4l2_dev;
 
@@ -166,7 +167,7 @@
 	.reset_resume		= usb_amradio_resume,
 #endif
 	.id_table		= usb_amradio_device_table,
-	.supports_autosuspend	= 0,
+	.supports_autosuspend	= 1,
 };
 
 /* switch on/off the radio. Send 8 bytes to device */
@@ -509,9 +510,15 @@
 	}
 
 	file->private_data = radio;
+	retval = usb_autopm_get_interface(radio->intf);
+	if (retval)
+		goto unlock;
 
-	if (unlikely(!radio->initialized))
+	if (unlikely(!radio->initialized)) {
 		retval = usb_amradio_init(radio);
+		if (retval)
+			usb_autopm_put_interface(radio->intf);
+	}
 
 unlock:
 	mutex_unlock(&radio->lock);
@@ -528,6 +535,8 @@
 
 	if (!radio->usbdev)
 		retval = -EIO;
+	else
+		usb_autopm_put_interface(radio->intf);
 
 	mutex_unlock(&radio->lock);
 	return retval;
@@ -669,6 +678,7 @@
 	radio->videodev.release = usb_amradio_video_device_release;
 
 	radio->usbdev = interface_to_usbdev(intf);
+	radio->intf = intf;
 	radio->curfreq = 95.16 * FREQ_MUL;
 
 	mutex_init(&radio->lock);



-- 
Alexey Klimov

                 reply	other threads:[~2009-11-09 22:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091110010949.494ee080.klimov.linux@gmail.com \
    --to=klimov.linux@gmail.com \
    --cc=dougsland@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=oliver@neukum.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox