[media] typhoon: convert to unlocked_ioctl

Convert the typhoon driver from ioctl to unlocked_ioctl.

When doing this I noticed a bug where curfreq was not initialized correctly
to mutefreq (it wasn't multiplied by 16).

The initialization is now also done before the device node is created.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Hans Verkuil 2010-11-14 09:49:34 -03:00 committed by Mauro Carvalho Chehab
parent 725ea8cf1c
commit d2c998f745

View File

@ -317,7 +317,7 @@ static int vidioc_log_status(struct file *file, void *priv)
static const struct v4l2_file_operations typhoon_fops = { static const struct v4l2_file_operations typhoon_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.ioctl = video_ioctl2, .unlocked_ioctl = video_ioctl2,
}; };
static const struct v4l2_ioctl_ops typhoon_ioctl_ops = { static const struct v4l2_ioctl_ops typhoon_ioctl_ops = {
@ -344,18 +344,18 @@ static int __init typhoon_init(void)
strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name)); strlcpy(v4l2_dev->name, "typhoon", sizeof(v4l2_dev->name));
dev->io = io; dev->io = io;
dev->curfreq = dev->mutefreq = mutefreq;
if (dev->io == -1) { if (dev->io == -1) {
v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n"); v4l2_err(v4l2_dev, "You must set an I/O address with io=0x316 or io=0x336\n");
return -EINVAL; return -EINVAL;
} }
if (dev->mutefreq < 87000 || dev->mutefreq > 108500) { if (mutefreq < 87000 || mutefreq > 108500) {
v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n"); v4l2_err(v4l2_dev, "You must set a frequency (in kHz) used when muting the card,\n");
v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n"); v4l2_err(v4l2_dev, "e.g. with \"mutefreq=87500\" (87000 <= mutefreq <= 108500)\n");
return -EINVAL; return -EINVAL;
} }
dev->curfreq = dev->mutefreq = mutefreq << 4;
mutex_init(&dev->lock); mutex_init(&dev->lock);
if (!request_region(dev->io, 8, "typhoon")) { if (!request_region(dev->io, 8, "typhoon")) {
@ -378,17 +378,17 @@ static int __init typhoon_init(void)
dev->vdev.ioctl_ops = &typhoon_ioctl_ops; dev->vdev.ioctl_ops = &typhoon_ioctl_ops;
dev->vdev.release = video_device_release_empty; dev->vdev.release = video_device_release_empty;
video_set_drvdata(&dev->vdev, dev); video_set_drvdata(&dev->vdev, dev);
/* mute card - prevents noisy bootups */
typhoon_mute(dev);
if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) { if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
release_region(dev->io, 8); release_region(dev->io, 8);
return -EINVAL; return -EINVAL;
} }
v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io); v4l2_info(v4l2_dev, "port 0x%x.\n", dev->io);
v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", dev->mutefreq); v4l2_info(v4l2_dev, "mute frequency is %lu kHz.\n", mutefreq);
dev->mutefreq <<= 4;
/* mute card - prevents noisy bootups */
typhoon_mute(dev);
return 0; return 0;
} }