diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2010-11-14 07:46:23 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-01 17:10:07 -0500 |
commit | ee71e42321cced11fecb989d743ad9cdb0c384ea (patch) | |
tree | b96d1b778ab0e45f9ef2db766ee6489cad6de06d /drivers/media | |
parent | 1cccee0b84e3445a142d0e9edcbf66b677b2e7e5 (diff) |
[media] tea5764: convert to unlocked_ioctl
Convert from ioctl to unlocked_ioctl using the v4l2 core lock.
Also removed the 'exclusive access' limitation. There was no need for it
and it violates the v4l2 spec as well.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/radio/radio-tea5764.c | 49 |
1 files changed, 9 insertions, 40 deletions
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 | ||
461 | static 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 | |||
478 | static 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 */ |
491 | static const struct v4l2_file_operations tea5764_fops = { | 461 | static 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 | ||
498 | static const struct v4l2_ioctl_ops tea5764_ioctl_ops = { | 466 | static 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; |
573 | errrel: | 542 | errrel: |