Skip to content

Commit

Permalink
[media] BKL: trivial BKL removal from V4L2 radio drivers
Browse files Browse the repository at this point in the history
The patch converts a bunch of V4L2 radio drivers to unlocked_ioctl.

These are all simple conversions: most already had a lock and so the ioctl
fop could simply be replaced by unlocked_ioctl.

radio-miropcm20.c was converted to use the new V4L2 core lock.

While doing this work I noticed that many of these drivers initialized
some more fields or muted audio or something like that *after* creating
the device node. This should be done before the device node is created
to prevent problems. Especially hal tends to grab a device node as soon
as it is created.

In one or two cases the mutex_init was even done after the device creation!

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Dec 1, 2010
1 parent e53beac commit 32958fd
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 74 deletions.
16 changes: 8 additions & 8 deletions drivers/media/radio/radio-aimslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations rtrack_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops rtrack_ioctl_ops = {
Expand Down Expand Up @@ -412,13 +412,6 @@ static int __init rtrack_init(void)
rt->vdev.release = video_device_release_empty;
video_set_drvdata(&rt->vdev, rt);

if (video_register_device(&rt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(&rt->v4l2_dev);
release_region(rt->io, 2);
return -EINVAL;
}
v4l2_info(v4l2_dev, "AIMSlab RadioTrack/RadioReveal card driver.\n");

/* Set up the I/O locking */

mutex_init(&rt->lock);
Expand All @@ -430,6 +423,13 @@ static int __init rtrack_init(void)
sleep_delay(2000000); /* make sure it's totally down */
outb(0xc0, rt->io); /* steady volume, mute card */

if (video_register_device(&rt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(&rt->v4l2_dev);
release_region(rt->io, 2);
return -EINVAL;
}
v4l2_info(v4l2_dev, "AIMSlab RadioTrack/RadioReveal card driver.\n");

return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/media/radio/radio-aztech.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

static const struct v4l2_file_operations aztech_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops aztech_ioctl_ops = {
Expand Down Expand Up @@ -375,6 +375,8 @@ static int __init aztech_init(void)
az->vdev.ioctl_ops = &aztech_ioctl_ops;
az->vdev.release = video_device_release_empty;
video_set_drvdata(&az->vdev, az);
/* mute card - prevents noisy bootups */
outb(0, az->io);

if (video_register_device(&az->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
Expand All @@ -383,8 +385,6 @@ static int __init aztech_init(void)
}

v4l2_info(v4l2_dev, "Aztech radio card driver v1.00/19990224 rkroll@exploits.org\n");
/* mute card - prevents noisy bootups */
outb(0, az->io);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions drivers/media/radio/radio-gemtek-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ MODULE_DEVICE_TABLE(pci, gemtek_pci_id);

static const struct v4l2_file_operations gemtek_pci_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops gemtek_pci_ioctl_ops = {
Expand Down Expand Up @@ -422,11 +422,11 @@ static int __devinit gemtek_pci_probe(struct pci_dev *pdev, const struct pci_dev
card->vdev.release = video_device_release_empty;
video_set_drvdata(&card->vdev, card);

gemtek_pci_mute(card);

if (video_register_device(&card->vdev, VFL_TYPE_RADIO, nr_radio) < 0)
goto err_video;

gemtek_pci_mute(card);

v4l2_info(v4l2_dev, "Gemtek PCI Radio (rev. %d) found at 0x%04x-0x%04x.\n",
pdev->revision, card->iobase, card->iobase + card->length - 1);

Expand Down
14 changes: 7 additions & 7 deletions drivers/media/radio/radio-gemtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static int gemtek_probe(struct gemtek *gt)

static const struct v4l2_file_operations gemtek_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static int vidioc_querycap(struct file *file, void *priv,
Expand Down Expand Up @@ -577,19 +577,19 @@ static int __init gemtek_init(void)
gt->vdev.release = video_device_release_empty;
video_set_drvdata(&gt->vdev, gt);

if (video_register_device(&gt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
release_region(gt->io, 1);
return -EBUSY;
}

/* Set defaults */
gt->lastfreq = GEMTEK_LOWFREQ;
gt->bu2614data = 0;

if (initmute)
gemtek_mute(gt);

if (video_register_device(&gt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
release_region(gt->io, 1);
return -EBUSY;
}

return 0;
}

Expand Down
14 changes: 6 additions & 8 deletions drivers/media/radio/radio-maestro.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations maestro_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops maestro_ioctl_ops = {
Expand Down Expand Up @@ -383,22 +383,20 @@ static int __devinit maestro_probe(struct pci_dev *pdev,
dev->vdev.release = video_device_release_empty;
video_set_drvdata(&dev->vdev, dev);

if (!radio_power_on(dev)) {
retval = -EIO;
goto errfr1;
}

retval = video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr);
if (retval) {
v4l2_err(v4l2_dev, "can't register video device!\n");
goto errfr1;
}

if (!radio_power_on(dev)) {
retval = -EIO;
goto errunr;
}

v4l2_info(v4l2_dev, "version " DRIVER_VERSION "\n");

return 0;
errunr:
video_unregister_device(&dev->vdev);
errfr1:
v4l2_device_unregister(v4l2_dev);
errfr:
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/radio-maxiradio.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,

static const struct v4l2_file_operations maxiradio_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops maxiradio_ioctl_ops = {
Expand Down
6 changes: 4 additions & 2 deletions drivers/media/radio/radio-miropcm20.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ struct pcm20 {
unsigned long freq;
int muted;
struct snd_miro_aci *aci;
struct mutex lock;
};

static struct pcm20 pcm20_card = {
Expand Down Expand Up @@ -72,7 +73,7 @@ static int pcm20_setfreq(struct pcm20 *dev, unsigned long freq)

static const struct v4l2_file_operations pcm20_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static int vidioc_querycap(struct file *file, void *priv,
Expand Down Expand Up @@ -229,7 +230,7 @@ static int __init pcm20_init(void)
return -ENODEV;
}
strlcpy(v4l2_dev->name, "miropcm20", sizeof(v4l2_dev->name));

mutex_init(&dev->lock);

res = v4l2_device_register(NULL, v4l2_dev);
if (res < 0) {
Expand All @@ -242,6 +243,7 @@ static int __init pcm20_init(void)
dev->vdev.fops = &pcm20_fops;
dev->vdev.ioctl_ops = &pcm20_ioctl_ops;
dev->vdev.release = video_device_release_empty;
dev->vdev.lock = &dev->lock;
video_set_drvdata(&dev->vdev, dev);

if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0)
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/radio/radio-rtrack2.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations rtrack2_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops rtrack2_ioctl_ops = {
Expand Down Expand Up @@ -315,6 +315,10 @@ static int __init rtrack2_init(void)
dev->vdev.release = video_device_release_empty;
video_set_drvdata(&dev->vdev, dev);

/* mute card - prevents noisy bootups */
outb(1, dev->io);
dev->muted = 1;

mutex_init(&dev->lock);
if (video_register_device(&dev->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
Expand All @@ -324,10 +328,6 @@ static int __init rtrack2_init(void)

v4l2_info(v4l2_dev, "AIMSlab Radiotrack II card driver.\n");

/* mute card - prevents noisy bootups */
outb(1, dev->io);
dev->muted = 1;

return 0;
}

Expand Down
7 changes: 4 additions & 3 deletions drivers/media/radio/radio-sf16fmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations fmi_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops fmi_ioctl_ops = {
Expand Down Expand Up @@ -382,6 +382,9 @@ static int __init fmi_init(void)

mutex_init(&fmi->lock);

/* mute card - prevents noisy bootups */
fmi_mute(fmi);

if (video_register_device(&fmi->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
release_region(fmi->io, 2);
Expand All @@ -391,8 +394,6 @@ static int __init fmi_init(void)
}

v4l2_info(v4l2_dev, "card driver at 0x%x\n", fmi->io);
/* mute card - prevents noisy bootups */
fmi_mute(fmi);
return 0;
}

Expand Down
11 changes: 5 additions & 6 deletions drivers/media/radio/radio-sf16fmr2.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations fmr2_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops fmr2_ioctl_ops = {
Expand Down Expand Up @@ -424,18 +424,17 @@ static int __init fmr2_init(void)
fmr2->vdev.release = video_device_release_empty;
video_set_drvdata(&fmr2->vdev, fmr2);

/* mute card - prevents noisy bootups */
fmr2_mute(fmr2->io);
fmr2_product_info(fmr2);

if (video_register_device(&fmr2->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
release_region(fmr2->io, 2);
return -EINVAL;
}

v4l2_info(v4l2_dev, "SF16FMR2 radio card driver at 0x%x.\n", fmr2->io);
/* mute card - prevents noisy bootups */
mutex_lock(&fmr2->lock);
fmr2_mute(fmr2->io);
fmr2_product_info(fmr2);
mutex_unlock(&fmr2->lock);
debug_print((KERN_DEBUG "card_type %d\n", fmr2->card_type));
return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions drivers/media/radio/radio-terratec.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations terratec_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops terratec_ioctl_ops = {
Expand Down Expand Up @@ -389,16 +389,16 @@ static int __init terratec_init(void)

mutex_init(&tt->lock);

/* mute card - prevents noisy bootups */
tt_write_vol(tt, 0);

if (video_register_device(&tt->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(&tt->v4l2_dev);
release_region(tt->io, 2);
return -EINVAL;
}

v4l2_info(v4l2_dev, "TERRATEC ActivRadio Standalone card driver.\n");

/* mute card - prevents noisy bootups */
tt_write_vol(tt, 0);
return 0;
}

Expand Down
18 changes: 9 additions & 9 deletions drivers/media/radio/radio-trust.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ static int vidioc_s_audio(struct file *file, void *priv,

static const struct v4l2_file_operations trust_fops = {
.owner = THIS_MODULE,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
};

static const struct v4l2_ioctl_ops trust_ioctl_ops = {
Expand Down Expand Up @@ -396,14 +396,6 @@ static int __init trust_init(void)
tr->vdev.release = video_device_release_empty;
video_set_drvdata(&tr->vdev, tr);

if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
release_region(tr->io, 2);
return -EINVAL;
}

v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");

write_i2c(tr, 2, TDA7318_ADDR, 0x80); /* speaker att. LF = 0 dB */
write_i2c(tr, 2, TDA7318_ADDR, 0xa0); /* speaker att. RF = 0 dB */
write_i2c(tr, 2, TDA7318_ADDR, 0xc0); /* speaker att. LR = 0 dB */
Expand All @@ -418,6 +410,14 @@ static int __init trust_init(void)
/* mute card - prevents noisy bootups */
tr_setmute(tr, 1);

if (video_register_device(&tr->vdev, VFL_TYPE_RADIO, radio_nr) < 0) {
v4l2_device_unregister(v4l2_dev);
release_region(tr->io, 2);
return -EINVAL;
}

v4l2_info(v4l2_dev, "Trust FM Radio card driver v1.0.\n");

return 0;
}

Expand Down
Loading

0 comments on commit 32958fd

Please sign in to comment.