From 63b0d5ad20365edf8baf96cdbb8e7faf62501286 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 10 Dec 2009 11:44:04 -0200 Subject: 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: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/cx25821/cx25821-vidups9.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'drivers/staging/cx25821/cx25821-vidups9.c') diff --git a/drivers/staging/cx25821/cx25821-vidups9.c b/drivers/staging/cx25821/cx25821-vidups9.c index 75c8c1eed2d..67fc082e308 100644 --- a/drivers/staging/cx25821/cx25821-vidups9.c +++ b/drivers/staging/cx25821/cx25821-vidups9.c @@ -95,35 +95,18 @@ static struct videobuf_queue_ops cx25821_video_qops = { static int video_open(struct file *file) { int minor = video_devdata(file)->minor; - struct cx25821_dev *h, *dev = NULL; + struct cx25821_dev *dev = video_drvdata(file); struct cx25821_fh *fh; - struct list_head *list; - enum v4l2_buf_type type = 0; - - lock_kernel(); - list_for_each(list, &cx25821_devlist) { - h = list_entry(list, struct cx25821_dev, devlist); - - if (h->video_dev[SRAM_CH09] - && h->video_dev[SRAM_CH09]->minor == minor) { - dev = h; - type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - } - } - - if (NULL == dev) { - unlock_kernel(); - return -ENODEV; - } + enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); /* allocate + initialize per filehandle data */ fh = kzalloc(sizeof(*fh), GFP_KERNEL); - if (NULL == fh) { - unlock_kernel(); + if (NULL == fh) return -ENOMEM; - } + + lock_kernel(); file->private_data = fh; fh->dev = dev; -- cgit v1.2.3 From 50462eb065e12f45851a9959a90d46b758944552 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 10 Dec 2009 11:47:13 -0200 Subject: V4L/DVB (13555): v4l: Use video_device_node_name() instead of the minor number Instead of using the minor number in kernel log messages, use the device node name as returned by the video_device_node_name() function. This makes debug, informational and error messages easier to understand for end users. [mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging] Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/cx25821/cx25821-vidups9.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/staging/cx25821/cx25821-vidups9.c') diff --git a/drivers/staging/cx25821/cx25821-vidups9.c b/drivers/staging/cx25821/cx25821-vidups9.c index 67fc082e308..d06054f7e5a 100644 --- a/drivers/staging/cx25821/cx25821-vidups9.c +++ b/drivers/staging/cx25821/cx25821-vidups9.c @@ -94,12 +94,13 @@ static struct videobuf_queue_ops cx25821_video_qops = { static int video_open(struct file *file) { - int minor = video_devdata(file)->minor; + struct video_device *vdev = video_devdata(file); struct cx25821_dev *dev = video_drvdata(file); struct cx25821_fh *fh; enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - printk("open minor=%d type=%s\n", minor, v4l2_type_names[type]); + printk("open dev=%s type=%s\n", video_device_node_name(vdev), + v4l2_type_names[type]); /* allocate + initialize per filehandle data */ fh = kzalloc(sizeof(*fh), GFP_KERNEL); -- cgit v1.2.3 From 46b21094cee16bc7e531d7d6cd66fb5ea05065d4 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 10 Dec 2009 11:51:38 -0200 Subject: V4L/DVB (13556): v4l: Remove unneeded video_device::minor assignments Now that the video_device registration is tested using video_is_registered(), drivers don't need to initialize the video_device::minor field to -1 anymore. Remove those unneeded assignments. [mchehab.redhat.com: removed tm6000 changes as tm6000 is not ready yet for submission even on staging] Signed-off-by: Laurent Pinchart Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/cx25821/cx25821-vidups9.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging/cx25821/cx25821-vidups9.c') diff --git a/drivers/staging/cx25821/cx25821-vidups9.c b/drivers/staging/cx25821/cx25821-vidups9.c index d06054f7e5a..1580da3b29a 100644 --- a/drivers/staging/cx25821/cx25821-vidups9.c +++ b/drivers/staging/cx25821/cx25821-vidups9.c @@ -410,7 +410,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = { struct video_device cx25821_video_template9 = { .name = "cx25821-upstream9", .fops = &video_fops, - .minor = -1, .ioctl_ops = &video_ioctl_ops, .tvnorms = CX25821_NORMS, .current_norm = V4L2_STD_NTSC_M, -- cgit v1.2.3