Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32958fdd authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

[media] BKL: trivial BKL removal from V4L2 radio drivers



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: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent e53beacd
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -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 = {
@@ -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);
@@ -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;
}

+3 −3
Original line number Diff line number Diff line
@@ -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 = {
@@ -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);
@@ -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;
}

+3 −3
Original line number Diff line number Diff line
@@ -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 = {
@@ -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);

+7 −7
Original line number Diff line number Diff line
@@ -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,
@@ -577,12 +577,6 @@ 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;
@@ -590,6 +584,12 @@ static int __init gemtek_init(void)
	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;
}

+6 −8
Original line number Diff line number Diff line
@@ -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 = {
@@ -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:
Loading