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

Commit 63b0d5ad authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (13554a): v4l: Use the video_drvdata function in drivers



Fix all device drivers to use the video_drvdata function instead of
maintaining a local list of minor to private data mappings. Call
video_set_drvdata to register the driver private pointer when not
already done.

Where applicable, the local list of mappings is completely removed when
it becomes unused.

[mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging]

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent f0813b4c
Loading
Loading
Loading
Loading
+7 −25
Original line number Diff line number Diff line
@@ -195,42 +195,24 @@ void saa7146_buffer_timeout(unsigned long data)
static int fops_open(struct file *file)
{
	unsigned int minor = video_devdata(file)->minor;
	struct saa7146_dev *h = NULL, *dev = NULL;
	struct list_head *list;
	struct video_device *vdev = video_devdata(file);
	struct saa7146_dev *dev = video_drvdata(file);
	struct saa7146_fh *fh = NULL;
	int result = 0;

	enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	enum v4l2_buf_type type;

	DEB_EE(("file:%p, minor:%d\n", file, minor));

	if (mutex_lock_interruptible(&saa7146_devices_lock))
		return -ERESTARTSYS;

	list_for_each(list,&saa7146_devices) {
		h = list_entry(list, struct saa7146_dev, item);
		if( NULL == h->vv_data ) {
			DEB_D(("device %p has not registered video devices.\n",h));
			continue;
		}
		DEB_D(("trying: %p @ major %d,%d\n",h,h->vv_data->video_minor,h->vv_data->vbi_minor));

		if (h->vv_data->video_minor == minor) {
			dev = h;
		}
		if (h->vv_data->vbi_minor == minor) {
			type = V4L2_BUF_TYPE_VBI_CAPTURE;
			dev = h;
		}
	}
	if (NULL == dev) {
		DEB_S(("no such video device.\n"));
		result = -ENODEV;
		goto out;
	}

	DEB_D(("using: %p\n",dev));

	type = vdev->vfl_type == VFL_TYPE_GRABBER
	     ? V4L2_BUF_TYPE_VIDEO_CAPTURE
	     : V4L2_BUF_TYPE_VBI_CAPTURE;

	/* check if an extension is registered */
	if( NULL == dev->ext ) {
		DEB_S(("no extension registered for this device.\n"));
+8 −27
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include "au0828.h"
#include "au0828-reg.h"

static LIST_HEAD(au0828_devlist);
static DEFINE_MUTEX(au0828_sysfs_lock);

#define AU0828_VERSION_CODE KERNEL_VERSION(0, 0, 1)
@@ -693,10 +692,8 @@ void au0828_analog_unregister(struct au0828_dev *dev)
	dprintk(1, "au0828_release_resources called\n");
	mutex_lock(&au0828_sysfs_lock);

	if (dev->vdev) {
		list_del(&dev->au0828list);
	if (dev->vdev)
		video_unregister_device(dev->vdev);
	}
	if (dev->vbi_dev)
		video_unregister_device(dev->vbi_dev);

@@ -737,29 +734,15 @@ static void res_free(struct au0828_fh *fh)

static int au0828_v4l2_open(struct file *filp)
{
	int minor = video_devdata(filp)->minor;
	int ret = 0;
	struct au0828_dev *h, *dev = NULL;
	struct au0828_dev *dev = video_drvdata(filp);
	struct au0828_fh *fh;
	int type = 0;
	struct list_head *list;
	int type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

	list_for_each(list, &au0828_devlist) {
		h = list_entry(list, struct au0828_dev, au0828list);
		if (h->vdev->minor == minor) {
			dev = h;
			type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		}
#ifdef VBI_IS_WORKING
		if (h->vbi_dev->minor == minor) {
			dev = h;
	if (video_devdata(filp)->vfl_type == VFL_TYPE_GRABBER)
		type = V4L2_BUF_TYPE_VBI_CAPTURE;
		}
#endif
	}

	if (NULL == dev)
		return -ENODEV;

	fh = kzalloc(sizeof(struct au0828_fh), GFP_KERNEL);
	if (NULL == fh) {
@@ -1676,25 +1659,23 @@ int au0828_analog_register(struct au0828_dev *dev,
	strcpy(dev->vbi_dev->name, "au0828a vbi");
#endif

	list_add_tail(&dev->au0828list, &au0828_devlist);

	/* Register the v4l2 device */
	video_set_drvdata(dev->vdev, dev);
	retval = video_register_device(dev->vdev, VFL_TYPE_GRABBER, -1);
	if (retval != 0) {
		dprintk(1, "unable to register video device (error = %d).\n",
			retval);
		list_del(&dev->au0828list);
		video_device_release(dev->vdev);
		return -ENODEV;
	}

#ifdef VBI_IS_WORKING
	/* Register the vbi device */
	video_set_drvdata(dev->vbi_dev, dev);
	retval = video_register_device(dev->vbi_dev, VFL_TYPE_VBI, -1);
	if (retval != 0) {
		dprintk(1, "unable to register vbi device (error = %d).\n",
			retval);
		list_del(&dev->au0828list);
		video_device_release(dev->vbi_dev);
		video_device_release(dev->vdev);
		return -ENODEV;
+0 −1
Original line number Diff line number Diff line
@@ -192,7 +192,6 @@ struct au0828_dev {
	struct au0828_dvb		dvb;

	/* Analog */
	struct list_head au0828list;
	struct v4l2_device v4l2_dev;
	int users;
	unsigned int stream_on:1;	/* Locks streams */
+0 −26
Original line number Diff line number Diff line
@@ -66,32 +66,6 @@ MODULE_PARM_DESC(alt, "alternate setting to use for video endpoint");
static LIST_HEAD(cx231xx_devlist);
static DEFINE_MUTEX(cx231xx_devlist_mutex);

struct cx231xx *cx231xx_get_device(int minor,
				   enum v4l2_buf_type *fh_type, int *has_radio)
{
	struct cx231xx *h, *dev = NULL;

	*fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	*has_radio = 0;

	mutex_lock(&cx231xx_devlist_mutex);
	list_for_each_entry(h, &cx231xx_devlist, devlist) {
		if (h->vdev->minor == minor)
			dev = h;
		if (h->vbi_dev->minor == minor) {
			dev = h;
			*fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
		}
		if (h->radio_dev && h->radio_dev->minor == minor) {
			dev = h;
			*has_radio = 1;
		}
	}
	mutex_unlock(&cx231xx_devlist_mutex);

	return dev;
}

/*
 * cx231xx_realease_resources()
 * unregisters the v4l2,i2c and usb devices
+14 −4
Original line number Diff line number Diff line
@@ -1918,13 +1918,22 @@ static int cx231xx_v4l2_open(struct file *filp)
{
	int minor = video_devdata(filp)->minor;
	int errCode = 0, radio = 0;
	struct cx231xx *dev = NULL;
	struct video_device *vdev = video_devdata(filp);
	struct cx231xx *dev = video_drvdata(filp);
	struct cx231xx_fh *fh;
	enum v4l2_buf_type fh_type = 0;

	dev = cx231xx_get_device(minor, &fh_type, &radio);
	if (NULL == dev)
		return -ENODEV;
	switch (vdev->vfl_type) {
	case VFL_TYPE_GRABBER:
		fh_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		break;
	case VFL_TYPE_VBI:
		fh_type = V4L2_BUF_TYPE_VBI_CAPTURE;
		break;
	case VFL_TYPE_RADIO:
		radio = 1;
		break;
	}

	mutex_lock(&dev->lock);

@@ -2326,6 +2335,7 @@ static struct video_device *cx231xx_vdev_init(struct cx231xx *dev,

	snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name);

	video_set_drvdata(vfd, dev);
	return vfd;
}

Loading