aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/radio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/radio')
-rw-r--r--drivers/media/radio/radio-aimslab.c16
-rw-r--r--drivers/media/radio/radio-aztech.c6
-rw-r--r--drivers/media/radio/radio-cadet.c12
-rw-r--r--drivers/media/radio/radio-gemtek-pci.c6
-rw-r--r--drivers/media/radio/radio-gemtek.c14
-rw-r--r--drivers/media/radio/radio-maestro.c14
-rw-r--r--drivers/media/radio/radio-maxiradio.c2
-rw-r--r--drivers/media/radio/radio-miropcm20.c6
-rw-r--r--drivers/media/radio/radio-rtrack2.c10
-rw-r--r--drivers/media/radio/radio-sf16fmi.c7
-rw-r--r--drivers/media/radio/radio-sf16fmr2.c11
-rw-r--r--drivers/media/radio/radio-si4713.c3
-rw-r--r--drivers/media/radio/radio-tea5764.c49
-rw-r--r--drivers/media/radio/radio-terratec.c8
-rw-r--r--drivers/media/radio/radio-timb.c5
-rw-r--r--drivers/media/radio/radio-trust.c18
-rw-r--r--drivers/media/radio/radio-typhoon.c16
-rw-r--r--drivers/media/radio/radio-zoltrix.c30
18 files changed, 106 insertions, 127 deletions
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index 5bf4985daede..05e832f61c3e 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -361,7 +361,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
361 361
362static const struct v4l2_file_operations rtrack_fops = { 362static const struct v4l2_file_operations rtrack_fops = {
363 .owner = THIS_MODULE, 363 .owner = THIS_MODULE,
364 .ioctl = video_ioctl2, 364 .unlocked_ioctl = video_ioctl2,
365}; 365};
366 366
367static const struct v4l2_ioctl_ops rtrack_ioctl_ops = { 367static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
@@ -412,13 +412,6 @@ static int __init rtrack_init(void)
412 rt->vdev.release = video_device_release_empty; 412 rt->vdev.release = video_device_release_empty;
413 video_set_drvdata(&rt->vdev, rt); 413 video_set_drvdata(&rt->vdev, rt);
414 414
415 if (video_register_device(&rt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
416 v4l2_device_unregister(&rt->v4l2_dev);
417 release_region(rt->io, 2);
418 return -EINVAL;
419 }
420 v4l2_info(v4l2_dev, "AIMSlab RadioTrack/RadioReveal card driver.\n");
421
422 /* Set up the I/O locking */ 415 /* Set up the I/O locking */
423 416
424 mutex_init(&rt->lock); 417 mutex_init(&rt->lock);
@@ -430,6 +423,13 @@ static int __init rtrack_init(void)
430 sleep_delay(2000000); /* make sure it's totally down */ 423 sleep_delay(2000000); /* make sure it's totally down */
431 outb(0xc0, rt->io); /* steady volume, mute card */ 424 outb(0xc0, rt->io); /* steady volume, mute card */
432 425
426 if (video_register_device(&rt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
427 v4l2_device_unregister(&rt->v4l2_dev);
428 release_region(rt->io, 2);
429 return -EINVAL;
430 }
431 v4l2_info(v4l2_dev, "AIMSlab RadioTrack/RadioReveal card driver.\n");
432
433 return 0; 433 return 0;
434} 434}
435 435
diff --git a/drivers/media/radio/radio-aztech.c b/drivers/media/radio/radio-aztech.c
index c22311393624..dd8a6ab0d437 100644
--- a/drivers/media/radio/radio-aztech.c
+++ b/drivers/media/radio/radio-aztech.c
@@ -324,7 +324,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
324 324
325static const struct v4l2_file_operations aztech_fops = { 325static const struct v4l2_file_operations aztech_fops = {
326 .owner = THIS_MODULE, 326 .owner = THIS_MODULE,
327 .ioctl = video_ioctl2, 327 .unlocked_ioctl = video_ioctl2,
328}; 328};
329 329
330static const struct v4l2_ioctl_ops aztech_ioctl_ops = { 330static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
@@ -375,6 +375,8 @@ static int __init aztech_init(void)
375 az->vdev.ioctl_ops = &aztech_ioctl_ops; 375 az->vdev.ioctl_ops = &aztech_ioctl_ops;
376 az->vdev.release = video_device_release_empty; 376 az->vdev.release = video_device_release_empty;
377 video_set_drvdata(&az->vdev, az); 377 video_set_drvdata(&az->vdev, az);
378 /* mute card - prevents noisy bootups */
379 outb(0, az->io);
378 380
379 if (video_register_device(&az->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 381 if (video_register_device(&az->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
380 v4l2_device_unregister(v4l2_dev); 382 v4l2_device_unregister(v4l2_dev);
@@ -383,8 +385,6 @@ static int __init aztech_init(void)
383 } 385 }
384 386
385 v4l2_info(v4l2_dev, "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n"); 387 v4l2_info(v4l2_dev, "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n");
386 /* mute card - prevents noisy bootups */
387 outb(0, az->io);
388 return 0; 388 return 0;
389} 389}
390 390
diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
index b701ea6e7c73..bc9ad0897c55 100644
--- a/drivers/media/radio/radio-cadet.c
+++ b/drivers/media/radio/radio-cadet.c
@@ -328,11 +328,10 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
328 unsigned char readbuf[RDS_BUFFER]; 328 unsigned char readbuf[RDS_BUFFER];
329 int i = 0; 329 int i = 0;
330 330
331 mutex_lock(&dev->lock);
331 if (dev->rdsstat == 0) { 332 if (dev->rdsstat == 0) {
332 mutex_lock(&dev->lock);
333 dev->rdsstat = 1; 333 dev->rdsstat = 1;
334 outb(0x80, dev->io); /* Select RDS fifo */ 334 outb(0x80, dev->io); /* Select RDS fifo */
335 mutex_unlock(&dev->lock);
336 init_timer(&dev->readtimer); 335 init_timer(&dev->readtimer);
337 dev->readtimer.function = cadet_handler; 336 dev->readtimer.function = cadet_handler;
338 dev->readtimer.data = (unsigned long)dev; 337 dev->readtimer.data = (unsigned long)dev;
@@ -340,12 +339,15 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
340 add_timer(&dev->readtimer); 339 add_timer(&dev->readtimer);
341 } 340 }
342 if (dev->rdsin == dev->rdsout) { 341 if (dev->rdsin == dev->rdsout) {
342 mutex_unlock(&dev->lock);
343 if (file->f_flags & O_NONBLOCK) 343 if (file->f_flags & O_NONBLOCK)
344 return -EWOULDBLOCK; 344 return -EWOULDBLOCK;
345 interruptible_sleep_on(&dev->read_queue); 345 interruptible_sleep_on(&dev->read_queue);
346 mutex_lock(&dev->lock);
346 } 347 }
347 while (i < count && dev->rdsin != dev->rdsout) 348 while (i < count && dev->rdsin != dev->rdsout)
348 readbuf[i++] = dev->rdsbuf[dev->rdsout++]; 349 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
350 mutex_unlock(&dev->lock);
349 351
350 if (copy_to_user(data, readbuf, i)) 352 if (copy_to_user(data, readbuf, i))
351 return -EFAULT; 353 return -EFAULT;
@@ -525,9 +527,11 @@ static int cadet_open(struct file *file)
525{ 527{
526 struct cadet *dev = video_drvdata(file); 528 struct cadet *dev = video_drvdata(file);
527 529
530 mutex_lock(&dev->lock);
528 dev->users++; 531 dev->users++;
529 if (1 == dev->users) 532 if (1 == dev->users)
530 init_waitqueue_head(&dev->read_queue); 533 init_waitqueue_head(&dev->read_queue);
534 mutex_unlock(&dev->lock);
531 return 0; 535 return 0;
532} 536}
533 537
@@ -535,11 +539,13 @@ static int cadet_release(struct file *file)
535{ 539{
536 struct cadet *dev = video_drvdata(file); 540 struct cadet *dev = video_drvdata(file);
537 541
542 mutex_lock(&dev->lock);
538 dev->users--; 543 dev->users--;
539 if (0 == dev->users) { 544 if (0 == dev->users) {
540 del_timer_sync(&dev->readtimer); 545 del_timer_sync(&dev->readtimer);
541 dev->rdsstat = 0; 546 dev->rdsstat = 0;
542 } 547 }
548 mutex_unlock(&dev->lock);
543 return 0; 549 return 0;
544} 550}
545 551
@@ -559,7 +565,7 @@ static const struct v4l2_file_operations cadet_fops = {
559 .open = cadet_open, 565 .open = cadet_open,
560 .release = cadet_release, 566 .release = cadet_release,
561 .read = cadet_read, 567 .read = cadet_read,
562 .ioctl = video_ioctl2, 568 .unlocked_ioctl = video_ioctl2,
563 .poll = cadet_poll, 569 .poll = cadet_poll,
564}; 570};
565 571
diff --git a/drivers/media/radio/radio-gemtek-pci.c b/drivers/media/radio/radio-gemtek-pci.c
index 79039674a0e0..28fa85ba2087 100644
--- a/drivers/media/radio/radio-gemtek-pci.c
+++ b/drivers/media/radio/radio-gemtek-pci.c
@@ -361,7 +361,7 @@ MODULE_DEVICE_TABLE(pci, gemtek_pci_id);
361 361
362static const struct v4l2_file_operations gemtek_pci_fops = { 362static const struct v4l2_file_operations gemtek_pci_fops = {
363 .owner = THIS_MODULE, 363 .owner = THIS_MODULE,
364 .ioctl = video_ioctl2, 364 .unlocked_ioctl = video_ioctl2,
365}; 365};
366 366
367static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = { 367static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
@@ -422,11 +422,11 @@ static int __devinit gemtek_pci_probe(struct pci_dev *pdev, const struct pci_dev
422 card->vdev.release = video_device_release_empty; 422 card->vdev.release = video_device_release_empty;
423 video_set_drvdata(&card->vdev, card); 423 video_set_drvdata(&card->vdev, card);
424 424
425 gemtek_pci_mute(card);
426
425 if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0) 427 if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0)
426 goto err_video; 428 goto err_video;
427 429
428 gemtek_pci_mute(card);
429
430 v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n", 430 v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",
431 pdev->revision, card->iobase, card->iobase + card->length - 1); 431 pdev->revision, card->iobase, card->iobase + card->length - 1);
432 432
diff --git a/drivers/media/radio/radio-gemtek.c b/drivers/media/radio/radio-gemtek.c
index 73985f641f07..259936422e49 100644
--- a/drivers/media/radio/radio-gemtek.c
+++ b/drivers/media/radio/radio-gemtek.c
@@ -378,7 +378,7 @@ static int gemtek_probe(struct gemtek *gt)
378 378
379static const struct v4l2_file_operations gemtek_fops = { 379static const struct v4l2_file_operations gemtek_fops = {
380 .owner = THIS_MODULE, 380 .owner = THIS_MODULE,
381 .ioctl = video_ioctl2, 381 .unlocked_ioctl = video_ioctl2,
382}; 382};
383 383
384static int vidioc_querycap(struct file *file, void *priv, 384static int vidioc_querycap(struct file *file, void *priv,
@@ -577,12 +577,6 @@ static int __init gemtek_init(void)
577 gt->vdev.release = video_device_release_empty; 577 gt->vdev.release = video_device_release_empty;
578 video_set_drvdata(&gt->vdev, gt); 578 video_set_drvdata(&gt->vdev, gt);
579 579
580 if (video_register_device(&gt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
581 v4l2_device_unregister(v4l2_dev);
582 release_region(gt->io, 1);
583 return -EBUSY;
584 }
585
586 /* Set defaults */ 580 /* Set defaults */
587 gt->lastfreq = GEMTEK_LOWFREQ; 581 gt->lastfreq = GEMTEK_LOWFREQ;
588 gt->bu2614data = 0; 582 gt->bu2614data = 0;
@@ -590,6 +584,12 @@ static int __init gemtek_init(void)
590 if (initmute) 584 if (initmute)
591 gemtek_mute(gt); 585 gemtek_mute(gt);
592 586
587 if (video_register_device(&gt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
588 v4l2_device_unregister(v4l2_dev);
589 release_region(gt->io, 1);
590 return -EBUSY;
591 }
592
593 return 0; 593 return 0;
594} 594}
595 595
diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c
index 08f1051979ca..6af61bfeb178 100644
--- a/drivers/media/radio/radio-maestro.c
+++ b/drivers/media/radio/radio-maestro.c
@@ -299,7 +299,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
299 299
300static const struct v4l2_file_operations maestro_fops = { 300static const struct v4l2_file_operations maestro_fops = {
301 .owner = THIS_MODULE, 301 .owner = THIS_MODULE,
302 .ioctl = video_ioctl2, 302 .unlocked_ioctl = video_ioctl2,
303}; 303};
304 304
305static const struct v4l2_ioctl_ops maestro_ioctl_ops = { 305static const struct v4l2_ioctl_ops maestro_ioctl_ops = {
@@ -383,22 +383,20 @@ static int __devinit maestro_probe(struct pci_dev *pdev,
383 dev->vdev.release = video_device_release_empty; 383 dev->vdev.release = video_device_release_empty;
384 video_set_drvdata(&dev->vdev, dev); 384 video_set_drvdata(&dev->vdev, dev);
385 385
386 if (!radio_power_on(dev)) {
387 retval = -EIO;
388 goto errfr1;
389 }
390
386 retval = video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr); 391 retval = video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr);
387 if (retval) { 392 if (retval) {
388 v4l2_err(v4l2_dev, "can't register video device!\n"); 393 v4l2_err(v4l2_dev, "can't register video device!\n");
389 goto errfr1; 394 goto errfr1;
390 } 395 }
391 396
392 if (!radio_power_on(dev)) {
393 retval = -EIO;
394 goto errunr;
395 }
396
397 v4l2_info(v4l2_dev, "version " DRIVER_VERSION "\n"); 397 v4l2_info(v4l2_dev, "version " DRIVER_VERSION "\n");
398 398
399 return 0; 399 return 0;
400errunr:
401 video_unregister_device(&dev->vdev);
402errfr1: 400errfr1:
403 v4l2_device_unregister(v4l2_dev); 401 v4l2_device_unregister(v4l2_dev);
404errfr: 402errfr:
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
index 255d40df4b46..6459a220b0dd 100644
--- a/drivers/media/radio/radio-maxiradio.c
+++ b/drivers/media/radio/radio-maxiradio.c
@@ -346,7 +346,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
346 346
347static const struct v4l2_file_operations maxiradio_fops = { 347static const struct v4l2_file_operations maxiradio_fops = {
348 .owner = THIS_MODULE, 348 .owner = THIS_MODULE,
349 .ioctl = video_ioctl2, 349 .unlocked_ioctl = video_ioctl2,
350}; 350};
351 351
352static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = { 352static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
diff --git a/drivers/media/radio/radio-miropcm20.c b/drivers/media/radio/radio-miropcm20.c
index 4ff885445fd4..3fb76e3834c9 100644
--- a/drivers/media/radio/radio-miropcm20.c
+++ b/drivers/media/radio/radio-miropcm20.c
@@ -33,6 +33,7 @@ struct pcm20 {
33 unsigned long freq; 33 unsigned long freq;
34 int muted; 34 int muted;
35 struct snd_miro_aci *aci; 35 struct snd_miro_aci *aci;
36 struct mutex lock;
36}; 37};
37 38
38static struct pcm20 pcm20_card = { 39static struct pcm20 pcm20_card = {
@@ -72,7 +73,7 @@ static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq)
72 73
73static const struct v4l2_file_operations pcm20_fops = { 74static const struct v4l2_file_operations pcm20_fops = {
74 .owner = THIS_MODULE, 75 .owner = THIS_MODULE,
75 .ioctl = video_ioctl2, 76 .unlocked_ioctl = video_ioctl2,
76}; 77};
77 78
78static int vidioc_querycap(struct file *file, void *priv, 79static int vidioc_querycap(struct file *file, void *priv,
@@ -229,7 +230,7 @@ static int __init pcm20_init(void)
229 return -ENODEV; 230 return -ENODEV;
230 } 231 }
231 strlcpy(v4l2_dev->name, "miropcm20", sizeof(v4l2_dev->name)); 232 strlcpy(v4l2_dev->name, "miropcm20", sizeof(v4l2_dev->name));
232 233 mutex_init(&dev->lock);
233 234
234 res = v4l2_device_register(NULL, v4l2_dev); 235 res = v4l2_device_register(NULL, v4l2_dev);
235 if (res < 0) { 236 if (res < 0) {
@@ -242,6 +243,7 @@ static int __init pcm20_init(void)
242 dev->vdev.fops = &pcm20_fops; 243 dev->vdev.fops = &pcm20_fops;
243 dev->vdev.ioctl_ops = &pcm20_ioctl_ops; 244 dev->vdev.ioctl_ops = &pcm20_ioctl_ops;
244 dev->vdev.release = video_device_release_empty; 245 dev->vdev.release = video_device_release_empty;
246 dev->vdev.lock = &dev->lock;
245 video_set_drvdata(&dev->vdev, dev); 247 video_set_drvdata(&dev->vdev, dev);
246 248
247 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) 249 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0)
diff --git a/drivers/media/radio/radio-rtrack2.c b/drivers/media/radio/radio-rtrack2.c
index a79296aac9a9..8d6ea591bd18 100644
--- a/drivers/media/radio/radio-rtrack2.c
+++ b/drivers/media/radio/radio-rtrack2.c
@@ -266,7 +266,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
266 266
267static const struct v4l2_file_operations rtrack2_fops = { 267static const struct v4l2_file_operations rtrack2_fops = {
268 .owner = THIS_MODULE, 268 .owner = THIS_MODULE,
269 .ioctl = video_ioctl2, 269 .unlocked_ioctl = video_ioctl2,
270}; 270};
271 271
272static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = { 272static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = {
@@ -315,6 +315,10 @@ static int __init rtrack2_init(void)
315 dev->vdev.release = video_device_release_empty; 315 dev->vdev.release = video_device_release_empty;
316 video_set_drvdata(&dev->vdev, dev); 316 video_set_drvdata(&dev->vdev, dev);
317 317
318 /* mute card - prevents noisy bootups */
319 outb(1, dev->io);
320 dev->muted = 1;
321
318 mutex_init(&dev->lock); 322 mutex_init(&dev->lock);
319 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 323 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
320 v4l2_device_unregister(v4l2_dev); 324 v4l2_device_unregister(v4l2_dev);
@@ -324,10 +328,6 @@ static int __init rtrack2_init(void)
324 328
325 v4l2_info(v4l2_dev, "AIMSlab Radiotrack II card driver.\n"); 329 v4l2_info(v4l2_dev, "AIMSlab Radiotrack II card driver.\n");
326 330
327 /* mute card - prevents noisy bootups */
328 outb(1, dev->io);
329 dev->muted = 1;
330
331 return 0; 331 return 0;
332} 332}
333 333
diff --git a/drivers/media/radio/radio-sf16fmi.c b/drivers/media/radio/radio-sf16fmi.c
index 985359d18aa5..b5a5f89e238a 100644
--- a/drivers/media/radio/radio-sf16fmi.c
+++ b/drivers/media/radio/radio-sf16fmi.c
@@ -260,7 +260,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
260 260
261static const struct v4l2_file_operations fmi_fops = { 261static const struct v4l2_file_operations fmi_fops = {
262 .owner = THIS_MODULE, 262 .owner = THIS_MODULE,
263 .ioctl = video_ioctl2, 263 .unlocked_ioctl = video_ioctl2,
264}; 264};
265 265
266static const struct v4l2_ioctl_ops fmi_ioctl_ops = { 266static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
@@ -382,6 +382,9 @@ static int __init fmi_init(void)
382 382
383 mutex_init(&fmi->lock); 383 mutex_init(&fmi->lock);
384 384
385 /* mute card - prevents noisy bootups */
386 fmi_mute(fmi);
387
385 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 388 if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
386 v4l2_device_unregister(v4l2_dev); 389 v4l2_device_unregister(v4l2_dev);
387 release_region(fmi->io, 2); 390 release_region(fmi->io, 2);
@@ -391,8 +394,6 @@ static int __init fmi_init(void)
391 } 394 }
392 395
393 v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io); 396 v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io);
394 /* mute card - prevents noisy bootups */
395 fmi_mute(fmi);
396 return 0; 397 return 0;
397} 398}
398 399
diff --git a/drivers/media/radio/radio-sf16fmr2.c b/drivers/media/radio/radio-sf16fmr2.c
index 52c7bbb32b8b..dc3f04c52d5e 100644
--- a/drivers/media/radio/radio-sf16fmr2.c
+++ b/drivers/media/radio/radio-sf16fmr2.c
@@ -376,7 +376,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
376 376
377static const struct v4l2_file_operations fmr2_fops = { 377static const struct v4l2_file_operations fmr2_fops = {
378 .owner = THIS_MODULE, 378 .owner = THIS_MODULE,
379 .ioctl = video_ioctl2, 379 .unlocked_ioctl = video_ioctl2,
380}; 380};
381 381
382static const struct v4l2_ioctl_ops fmr2_ioctl_ops = { 382static const struct v4l2_ioctl_ops fmr2_ioctl_ops = {
@@ -424,6 +424,10 @@ static int __init fmr2_init(void)
424 fmr2->vdev.release = video_device_release_empty; 424 fmr2->vdev.release = video_device_release_empty;
425 video_set_drvdata(&fmr2->vdev, fmr2); 425 video_set_drvdata(&fmr2->vdev, fmr2);
426 426
427 /* mute card - prevents noisy bootups */
428 fmr2_mute(fmr2->io);
429 fmr2_product_info(fmr2);
430
427 if (video_register_device(&fmr2->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 431 if (video_register_device(&fmr2->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
428 v4l2_device_unregister(v4l2_dev); 432 v4l2_device_unregister(v4l2_dev);
429 release_region(fmr2->io, 2); 433 release_region(fmr2->io, 2);
@@ -431,11 +435,6 @@ static int __init fmr2_init(void)
431 } 435 }
432 436
433 v4l2_info(v4l2_dev, "SF16FMR2 radio card driver at 0x%x.\n", fmr2->io); 437 v4l2_info(v4l2_dev, "SF16FMR2 radio card driver at 0x%x.\n", fmr2->io);
434 /* mute card - prevents noisy bootups */
435 mutex_lock(&fmr2->lock);
436 fmr2_mute(fmr2->io);
437 fmr2_product_info(fmr2);
438 mutex_unlock(&fmr2->lock);
439 debug_print((KERN_DEBUG "card_type %d\n", fmr2->card_type)); 438 debug_print((KERN_DEBUG "card_type %d\n", fmr2->card_type));
440 return 0; 439 return 0;
441} 440}
diff --git a/drivers/media/radio/radio-si4713.c b/drivers/media/radio/radio-si4713.c
index 03829e6818bd..726d367ad8d0 100644
--- a/drivers/media/radio/radio-si4713.c
+++ b/drivers/media/radio/radio-si4713.c
@@ -53,7 +53,8 @@ struct radio_si4713_device {
53/* radio_si4713_fops - file operations interface */ 53/* radio_si4713_fops - file operations interface */
54static const struct v4l2_file_operations radio_si4713_fops = { 54static const struct v4l2_file_operations radio_si4713_fops = {
55 .owner = THIS_MODULE, 55 .owner = THIS_MODULE,
56 .ioctl = video_ioctl2, 56 /* Note: locking is done at the subdev level in the i2c driver. */
57 .unlocked_ioctl = video_ioctl2,
57}; 58};
58 59
59/* Video4Linux Interface */ 60/* Video4Linux Interface */
diff --git a/drivers/media/radio/radio-tea5764.c b/drivers/media/radio/radio-tea5764.c
index 789d2ec66e19..0e71d816c725 100644
--- a/drivers/media/radio/radio-tea5764.c
+++ b/drivers/media/radio/radio-tea5764.c
@@ -142,7 +142,6 @@ struct tea5764_device {
142 struct video_device *videodev; 142 struct video_device *videodev;
143 struct tea5764_regs regs; 143 struct tea5764_regs regs;
144 struct mutex mutex; 144 struct mutex mutex;
145 int users;
146}; 145};
147 146
148/* I2C code related */ 147/* I2C code related */
@@ -458,41 +457,10 @@ static int vidioc_s_audio(struct file *file, void *priv,
458 return 0; 457 return 0;
459} 458}
460 459
461static int tea5764_open(struct file *file)
462{
463 /* Currently we support only one device */
464 struct tea5764_device *radio = video_drvdata(file);
465
466 mutex_lock(&radio->mutex);
467 /* Only exclusive access */
468 if (radio->users) {
469 mutex_unlock(&radio->mutex);
470 return -EBUSY;
471 }
472 radio->users++;
473 mutex_unlock(&radio->mutex);
474 file->private_data = radio;
475 return 0;
476}
477
478static int tea5764_close(struct file *file)
479{
480 struct tea5764_device *radio = video_drvdata(file);
481
482 if (!radio)
483 return -ENODEV;
484 mutex_lock(&radio->mutex);
485 radio->users--;
486 mutex_unlock(&radio->mutex);
487 return 0;
488}
489
490/* File system interface */ 460/* File system interface */
491static const struct v4l2_file_operations tea5764_fops = { 461static const struct v4l2_file_operations tea5764_fops = {
492 .owner = THIS_MODULE, 462 .owner = THIS_MODULE,
493 .open = tea5764_open, 463 .unlocked_ioctl = video_ioctl2,
494 .release = tea5764_close,
495 .ioctl = video_ioctl2,
496}; 464};
497 465
498static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { 466static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
@@ -527,7 +495,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
527 int ret; 495 int ret;
528 496
529 PDEBUG("probe"); 497 PDEBUG("probe");
530 radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL); 498 radio = kzalloc(sizeof(struct tea5764_device), GFP_KERNEL);
531 if (!radio) 499 if (!radio)
532 return -ENOMEM; 500 return -ENOMEM;
533 501
@@ -555,12 +523,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
555 523
556 i2c_set_clientdata(client, radio); 524 i2c_set_clientdata(client, radio);
557 video_set_drvdata(radio->videodev, radio); 525 video_set_drvdata(radio->videodev, radio);
558 526 radio->videodev->lock = &radio->mutex;
559 ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
560 if (ret < 0) {
561 PWARN("Could not register video device!");
562 goto errrel;
563 }
564 527
565 /* initialize and power off the chip */ 528 /* initialize and power off the chip */
566 tea5764_i2c_read(radio); 529 tea5764_i2c_read(radio);
@@ -568,6 +531,12 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
568 tea5764_mute(radio, 1); 531 tea5764_mute(radio, 1);
569 tea5764_power_down(radio); 532 tea5764_power_down(radio);
570 533
534 ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
535 if (ret < 0) {
536 PWARN("Could not register video device!");
537 goto errrel;
538 }
539
571 PINFO("registered."); 540 PINFO("registered.");
572 return 0; 541 return 0;
573errrel: 542errrel:
diff --git a/drivers/media/radio/radio-terratec.c b/drivers/media/radio/radio-terratec.c
index fc1c860fd438..a32663917059 100644
--- a/drivers/media/radio/radio-terratec.c
+++ b/drivers/media/radio/radio-terratec.c
@@ -338,7 +338,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
338 338
339static const struct v4l2_file_operations terratec_fops = { 339static const struct v4l2_file_operations terratec_fops = {
340 .owner = THIS_MODULE, 340 .owner = THIS_MODULE,
341 .ioctl = video_ioctl2, 341 .unlocked_ioctl = video_ioctl2,
342}; 342};
343 343
344static const struct v4l2_ioctl_ops terratec_ioctl_ops = { 344static const struct v4l2_ioctl_ops terratec_ioctl_ops = {
@@ -389,6 +389,9 @@ static int __init terratec_init(void)
389 389
390 mutex_init(&tt->lock); 390 mutex_init(&tt->lock);
391 391
392 /* mute card - prevents noisy bootups */
393 tt_write_vol(tt, 0);
394
392 if (video_register_device(&tt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 395 if (video_register_device(&tt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
393 v4l2_device_unregister(&tt->v4l2_dev); 396 v4l2_device_unregister(&tt->v4l2_dev);
394 release_region(tt->io, 2); 397 release_region(tt->io, 2);
@@ -396,9 +399,6 @@ static int __init terratec_init(void)
396 } 399 }
397 400
398 v4l2_info(v4l2_dev, "TERRATEC ActivRadio Standalone card driver.\n"); 401 v4l2_info(v4l2_dev, "TERRATEC ActivRadio Standalone card driver.\n");
399
400 /* mute card - prevents noisy bootups */
401 tt_write_vol(tt, 0);
402 return 0; 402 return 0;
403} 403}
404 404
diff --git a/drivers/media/radio/radio-timb.c b/drivers/media/radio/radio-timb.c
index b8bb3ef47df5..a185610b376b 100644
--- a/drivers/media/radio/radio-timb.c
+++ b/drivers/media/radio/radio-timb.c
@@ -34,6 +34,7 @@ struct timbradio {
34 struct v4l2_subdev *sd_dsp; 34 struct v4l2_subdev *sd_dsp;
35 struct video_device video_dev; 35 struct video_device video_dev;
36 struct v4l2_device v4l2_dev; 36 struct v4l2_device v4l2_dev;
37 struct mutex lock;
37}; 38};
38 39
39 40
@@ -142,7 +143,7 @@ static const struct v4l2_ioctl_ops timbradio_ioctl_ops = {
142 143
143static const struct v4l2_file_operations timbradio_fops = { 144static const struct v4l2_file_operations timbradio_fops = {
144 .owner = THIS_MODULE, 145 .owner = THIS_MODULE,
145 .ioctl = video_ioctl2, 146 .unlocked_ioctl = video_ioctl2,
146}; 147};
147 148
148static int __devinit timbradio_probe(struct platform_device *pdev) 149static int __devinit timbradio_probe(struct platform_device *pdev)
@@ -164,6 +165,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
164 } 165 }
165 166
166 tr->pdata = *pdata; 167 tr->pdata = *pdata;
168 mutex_init(&tr->lock);
167 169
168 strlcpy(tr->video_dev.name, "Timberdale Radio", 170 strlcpy(tr->video_dev.name, "Timberdale Radio",
169 sizeof(tr->video_dev.name)); 171 sizeof(tr->video_dev.name));
@@ -171,6 +173,7 @@ static int __devinit timbradio_probe(struct platform_device *pdev)
171 tr->video_dev.ioctl_ops = &timbradio_ioctl_ops; 173 tr->video_dev.ioctl_ops = &timbradio_ioctl_ops;
172 tr->video_dev.release = video_device_release_empty; 174 tr->video_dev.release = video_device_release_empty;
173 tr->video_dev.minor = -1; 175 tr->video_dev.minor = -1;
176 tr->video_dev.lock = &tr->lock;
174 177
175 strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name)); 178 strlcpy(tr->v4l2_dev.name, DRIVER_NAME, sizeof(tr->v4l2_dev.name));
176 err = v4l2_device_register(NULL, &tr->v4l2_dev); 179 err = v4l2_device_register(NULL, &tr->v4l2_dev);
diff --git a/drivers/media/radio/radio-trust.c b/drivers/media/radio/radio-trust.c
index 9d6dcf8af5b0..22fa9cc28abe 100644
--- a/drivers/media/radio/radio-trust.c
+++ b/drivers/media/radio/radio-trust.c
@@ -344,7 +344,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
344 344
345static const struct v4l2_file_operations trust_fops = { 345static const struct v4l2_file_operations trust_fops = {
346 .owner = THIS_MODULE, 346 .owner = THIS_MODULE,
347 .ioctl = video_ioctl2, 347 .unlocked_ioctl = video_ioctl2,
348}; 348};
349 349
350static const struct v4l2_ioctl_ops trust_ioctl_ops = { 350static const struct v4l2_ioctl_ops trust_ioctl_ops = {
@@ -396,14 +396,6 @@ static int __init trust_init(void)
396 tr->vdev.release = video_device_release_empty; 396 tr->vdev.release = video_device_release_empty;
397 video_set_drvdata(&tr->vdev, tr); 397 video_set_drvdata(&tr->vdev, tr);
398 398
399 if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
400 v4l2_device_unregister(v4l2_dev);
401 release_region(tr->io, 2);
402 return -EINVAL;
403 }
404
405 v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");
406
407 write_i2c(tr, 2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */ 399 write_i2c(tr, 2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */
408 write_i2c(tr, 2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */ 400 write_i2c(tr, 2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */
409 write_i2c(tr, 2, TDA7318_ADDR, 0xc0); /* speaker att. LR = 0 dB */ 401 write_i2c(tr, 2, TDA7318_ADDR, 0xc0); /* speaker att. LR = 0 dB */
@@ -418,6 +410,14 @@ static int __init trust_init(void)
418 /* mute card - prevents noisy bootups */ 410 /* mute card - prevents noisy bootups */
419 tr_setmute(tr, 1); 411 tr_setmute(tr, 1);
420 412
413 if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
414 v4l2_device_unregister(v4l2_dev);
415 release_region(tr->io, 2);
416 return -EINVAL;
417 }
418
419 v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");
420
421 return 0; 421 return 0;
422} 422}
423 423
diff --git a/drivers/media/radio/radio-typhoon.c b/drivers/media/radio/radio-typhoon.c
index b1f630527dc1..8dbbf08f2207 100644
--- a/drivers/media/radio/radio-typhoon.c
+++ b/drivers/media/radio/radio-typhoon.c
@@ -317,7 +317,7 @@ static int vidioc_log_status(struct file *file, void *priv)
317 317
318static const struct v4l2_file_operations typhoon_fops = { 318static const struct v4l2_file_operations typhoon_fops = {
319 .owner = THIS_MODULE, 319 .owner = THIS_MODULE,
320 .ioctl = video_ioctl2, 320 .unlocked_ioctl = video_ioctl2,
321}; 321};
322 322
323static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { 323static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
@@ -344,18 +344,18 @@ static int __init typhoon_init(void)
344 344
345 strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name)); 345 strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name));
346 dev->io = io; 346 dev->io = io;
347 dev->curfreq = dev->mutefreq = mutefreq;
348 347
349 if (dev->io == -1) { 348 if (dev->io == -1) {
350 v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n"); 349 v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n");
351 return -EINVAL; 350 return -EINVAL;
352 } 351 }
353 352
354 if (dev->mutefreq < 87000 || dev->mutefreq > 108500) { 353 if (mutefreq < 87000 || mutefreq > 108500) {
355 v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n"); 354 v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n");
356 v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n"); 355 v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n");
357 return -EINVAL; 356 return -EINVAL;
358 } 357 }
358 dev->curfreq = dev->mutefreq = mutefreq << 4;
359 359
360 mutex_init(&dev->lock); 360 mutex_init(&dev->lock);
361 if (!request_region(dev->io, 8, "typhoon")) { 361 if (!request_region(dev->io, 8, "typhoon")) {
@@ -378,17 +378,17 @@ static int __init typhoon_init(void)
378 dev->vdev.ioctl_ops = &typhoon_ioctl_ops; 378 dev->vdev.ioctl_ops = &typhoon_ioctl_ops;
379 dev->vdev.release = video_device_release_empty; 379 dev->vdev.release = video_device_release_empty;
380 video_set_drvdata(&dev->vdev, dev); 380 video_set_drvdata(&dev->vdev, dev);
381
382 /* mute card - prevents noisy bootups */
383 typhoon_mute(dev);
384
381 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { 385 if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
382 v4l2_device_unregister(&dev->v4l2_dev); 386 v4l2_device_unregister(&dev->v4l2_dev);
383 release_region(dev->io, 8); 387 release_region(dev->io, 8);
384 return -EINVAL; 388 return -EINVAL;
385 } 389 }
386 v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io); 390 v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io);
387 v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", dev->mutefreq); 391 v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", mutefreq);
388 dev->mutefreq <<= 4;
389
390 /* mute card - prevents noisy bootups */
391 typhoon_mute(dev);
392 392
393 return 0; 393 return 0;
394} 394}
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c
index f31eab99c943..af99c5bd88c1 100644
--- a/drivers/media/radio/radio-zoltrix.c
+++ b/drivers/media/radio/radio-zoltrix.c
@@ -377,7 +377,7 @@ static int vidioc_s_audio(struct file *file, void *priv,
377static const struct v4l2_file_operations zoltrix_fops = 377static const struct v4l2_file_operations zoltrix_fops =
378{ 378{
379 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
380 .ioctl = video_ioctl2, 380 .unlocked_ioctl = video_ioctl2,
381}; 381};
382 382
383static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = { 383static const struct v4l2_ioctl_ops zoltrix_ioctl_ops = {
@@ -424,20 +424,6 @@ static int __init zoltrix_init(void)
424 return res; 424 return res;
425 } 425 }
426 426
427 strlcpy(zol->vdev.name, v4l2_dev->name, sizeof(zol->vdev.name));
428 zol->vdev.v4l2_dev = v4l2_dev;
429 zol->vdev.fops = &zoltrix_fops;
430 zol->vdev.ioctl_ops = &zoltrix_ioctl_ops;
431 zol->vdev.release = video_device_release_empty;
432 video_set_drvdata(&zol->vdev, zol);
433
434 if (video_register_device(&zol->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
435 v4l2_device_unregister(v4l2_dev);
436 release_region(zol->io, 2);
437 return -EINVAL;
438 }
439 v4l2_info(v4l2_dev, "Zoltrix Radio Plus card driver.\n");
440
441 mutex_init(&zol->lock); 427 mutex_init(&zol->lock);
442 428
443 /* mute card - prevents noisy bootups */ 429 /* mute card - prevents noisy bootups */
@@ -452,6 +438,20 @@ static int __init zoltrix_init(void)
452 zol->curvol = 0; 438 zol->curvol = 0;
453 zol->stereo = 1; 439 zol->stereo = 1;
454 440
441 strlcpy(zol->vdev.name, v4l2_dev->name, sizeof(zol->vdev.name));
442 zol->vdev.v4l2_dev = v4l2_dev;
443 zol->vdev.fops = &zoltrix_fops;
444 zol->vdev.ioctl_ops = &zoltrix_ioctl_ops;
445 zol->vdev.release = video_device_release_empty;
446 video_set_drvdata(&zol->vdev, zol);
447
448 if (video_register_device(&zol->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
449 v4l2_device_unregister(v4l2_dev);
450 release_region(zol->io, 2);
451 return -EINVAL;
452 }
453 v4l2_info(v4l2_dev, "Zoltrix Radio Plus card driver.\n");
454
455 return 0; 455 return 0;
456} 456}
457 457