aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/radio/radio-mr800.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/drivers/media/radio/radio-mr800.c b/drivers/media/radio/radio-mr800.c
index 399032e8cc18..7db992d3b0db 100644
--- a/drivers/media/radio/radio-mr800.c
+++ b/drivers/media/radio/radio-mr800.c
@@ -85,6 +85,9 @@ MODULE_LICENSE("GPL");
85#define amradio_dev_warn(dev, fmt, arg...) \ 85#define amradio_dev_warn(dev, fmt, arg...) \
86 dev_warn(dev, MR800_DRIVER_NAME " - " fmt, ##arg) 86 dev_warn(dev, MR800_DRIVER_NAME " - " fmt, ##arg)
87 87
88#define amradio_dev_err(dev, fmt, arg...) \
89 dev_err(dev, MR800_DRIVER_NAME " - " fmt, ##arg)
90
88/* Probably USB_TIMEOUT should be modified in module parameter */ 91/* Probably USB_TIMEOUT should be modified in module parameter */
89#define BUFFER_LENGTH 8 92#define BUFFER_LENGTH 8
90#define USB_TIMEOUT 500 93#define USB_TIMEOUT 500
@@ -137,6 +140,7 @@ struct amradio_device {
137 int curfreq; 140 int curfreq;
138 int stereo; 141 int stereo;
139 int muted; 142 int muted;
143 int initialized;
140}; 144};
141 145
142#define vdev_to_amradio(r) container_of(r, struct amradio_device, videodev) 146#define vdev_to_amradio(r) container_of(r, struct amradio_device, videodev)
@@ -478,6 +482,31 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
478 return 0; 482 return 0;
479} 483}
480 484
485static int usb_amradio_init(struct amradio_device *radio)
486{
487 int retval;
488
489 retval = amradio_set_mute(radio, AMRADIO_STOP);
490 if (retval < 0) {
491 amradio_dev_warn(&radio->videodev.dev, "amradio_stop failed\n");
492 goto out_err;
493 }
494
495 retval = amradio_set_stereo(radio, WANT_STEREO);
496 if (retval < 0) {
497 amradio_dev_warn(&radio->videodev.dev, "set stereo failed\n");
498 goto out_err;
499 }
500
501 radio->initialized = 1;
502 goto out;
503
504out_err:
505 amradio_dev_err(&radio->videodev.dev, "initialization failed\n");
506out:
507 return retval;
508}
509
481/* open device - amradio_start() and amradio_setfreq() */ 510/* open device - amradio_start() and amradio_setfreq() */
482static int usb_amradio_open(struct file *file) 511static int usb_amradio_open(struct file *file)
483{ 512{
@@ -493,6 +522,9 @@ static int usb_amradio_open(struct file *file)
493 522
494 file->private_data = radio; 523 file->private_data = radio;
495 524
525 if (unlikely(!radio->initialized))
526 retval = usb_amradio_init(radio);
527
496unlock: 528unlock:
497 mutex_unlock(&radio->lock); 529 mutex_unlock(&radio->lock);
498 return retval; 530 return retval;
@@ -641,8 +673,6 @@ static int usb_amradio_probe(struct usb_interface *intf,
641 673
642 radio->usbdev = interface_to_usbdev(intf); 674 radio->usbdev = interface_to_usbdev(intf);
643 radio->curfreq = 95.16 * FREQ_MUL; 675 radio->curfreq = 95.16 * FREQ_MUL;
644 radio->stereo = -1;
645 radio->muted = 1;
646 676
647 mutex_init(&radio->lock); 677 mutex_init(&radio->lock);
648 678