autopm is a bad idea for radio usb sticks: it means that when the last user closes the file handle the radio stops working which is not what you want. Removing this simplifies the code as well. Signed-off-by: Hans Verkuil <hverkuil@xxxxxxxxx> --- drivers/media/radio/radio-mr800.c | 87 ++----------------------------------- 1 files changed, 4 insertions(+), 83 deletions(-) diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c index 492cfca..fcf3a9c 100644 --- a/drivers/media/radio/radio-mr800.c +++ b/drivers/media/radio/radio-mr800.c @@ -122,11 +122,6 @@ MODULE_PARM_DESC(radio_nr, "Radio Nr"); static int usb_amradio_probe(struct usb_interface *intf, const struct usb_device_id *id); static void usb_amradio_disconnect(struct usb_interface *intf); -static int usb_amradio_open(struct file *file); -static int usb_amradio_close(struct file *file); -static int usb_amradio_suspend(struct usb_interface *intf, - pm_message_t message); -static int usb_amradio_resume(struct usb_interface *intf); /* Data for one (physical) device */ struct amradio_device { @@ -141,7 +136,6 @@ struct amradio_device { int curfreq; int stereo; int muted; - int initialized; }; static inline struct amradio_device *to_amradio_dev(struct v4l2_device *v4l2_dev) @@ -163,11 +157,7 @@ static struct usb_driver usb_amradio_driver = { .name = MR800_DRIVER_NAME, .probe = usb_amradio_probe, .disconnect = usb_amradio_disconnect, - .suspend = usb_amradio_suspend, - .resume = usb_amradio_resume, - .reset_resume = usb_amradio_resume, .id_table = usb_amradio_device_table, - .supports_autosuspend = 1, }; /* switch on/off the radio. Send 8 bytes to device */ @@ -486,7 +476,6 @@ static int usb_amradio_init(struct amradio_device *radio) if (retval) goto out_err; - radio->initialized = 1; goto out; out_err: @@ -495,81 +484,9 @@ out: return retval; } -/* open device - amradio_start() and amradio_setfreq() */ -static int usb_amradio_open(struct file *file) -{ - struct amradio_device *radio = video_drvdata(file); - int retval; - - retval = usb_autopm_get_interface(radio->intf); - if (retval) - return retval; - - if (unlikely(!radio->initialized)) { - retval = usb_amradio_init(radio); - if (retval) - usb_autopm_put_interface(radio->intf); - } - return retval; -} - -/*close device */ -static int usb_amradio_close(struct file *file) -{ - struct amradio_device *radio = video_drvdata(file); - - if (video_is_registered(&radio->videodev)) - usb_autopm_put_interface(radio->intf); - return 0; -} - -/* Suspend device - stop device. Need to be checked and fixed */ -static int usb_amradio_suspend(struct usb_interface *intf, pm_message_t message) -{ - struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf)); - - mutex_lock(&radio->lock); - if (!radio->muted && radio->initialized) { - amradio_set_mute(radio, AMRADIO_STOP); - radio->muted = 0; - } - mutex_unlock(&radio->lock); - - dev_info(&intf->dev, "going into suspend..\n"); - return 0; -} - -/* Resume device - start device. Need to be checked and fixed */ -static int usb_amradio_resume(struct usb_interface *intf) -{ - struct amradio_device *radio = to_amradio_dev(usb_get_intfdata(intf)); - - mutex_lock(&radio->lock); - if (unlikely(!radio->initialized)) - goto unlock; - - if (radio->stereo) - amradio_set_stereo(radio, WANT_STEREO); - else - amradio_set_stereo(radio, WANT_MONO); - - amradio_setfreq(radio, radio->curfreq); - - if (!radio->muted) - amradio_set_mute(radio, AMRADIO_START); - -unlock: - mutex_unlock(&radio->lock); - - dev_info(&intf->dev, "coming out of suspend..\n"); - return 0; -} - /* File system interface */ static const struct v4l2_file_operations usb_amradio_fops = { .owner = THIS_MODULE, - .open = usb_amradio_open, - .release = usb_amradio_close, .unlocked_ioctl = video_ioctl2, }; @@ -642,6 +559,10 @@ static int usb_amradio_probe(struct usb_interface *intf, video_set_drvdata(&radio->videodev, radio); + retval = usb_amradio_init(radio); + if (retval < 0) + goto err_vdev; + retval = video_register_device(&radio->videodev, VFL_TYPE_RADIO, radio_nr); if (retval < 0) { -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html