V4L/DVB (13554a): v4l: Use the video_drvdata function in drivers
authorMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 18 May 2010 07:27:27 +0000 (04:27 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 19 May 2010 15:59:18 +0000 (12:59 -0300)
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: patch broke into two. This one changes just tm6000]

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/tm6000/tm6000-cards.c
drivers/staging/tm6000/tm6000-video.c
drivers/staging/tm6000/tm6000.h

index 160b4d714898ce0c1bb344b7345d402866306b37..6143e20d139da525178dcab356109582d5a8ebf8 100644 (file)
@@ -791,7 +791,6 @@ static int tm6000_usb_probe(struct usb_interface *interface,
        if ((card[nr] >= 0) && (card[nr] < ARRAY_SIZE(tm6000_boards)))
                dev->model = card[nr];
 
-       INIT_LIST_HEAD(&dev->tm6000_corelist);
        dev->udev = usbdev;
        dev->devno = nr;
 
index 7828030c4f33ce6536d9573c13592ea7129a2814..f2b7fe4a3581e5da6acd72ae040a66a5d35f6a72 100644 (file)
@@ -116,8 +116,6 @@ static struct tm6000_fmt format[] = {
        }
 };
 
-static LIST_HEAD(tm6000_corelist);
-
 /* ------------------------------------------------------------------
        DMA and thread functions
    ------------------------------------------------------------------*/
@@ -1321,8 +1319,7 @@ static int tm6000_open(struct file *file)
        struct video_device *vdev = video_devdata(file);
        struct tm6000_core *dev = video_drvdata(file);
        struct tm6000_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
+       enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        int i,rc;
 
        printk(KERN_INFO "tm6000: open called (dev=%s)\n",
@@ -1331,16 +1328,6 @@ static int tm6000_open(struct file *file)
        dprintk(dev, V4L2_DEBUG_OPEN, "tm6000: open called (dev=%s)\n",
                video_device_node_name(vdev));
 
-       list_for_each(list,&tm6000_corelist) {
-               h = list_entry(list, struct tm6000_core, tm6000_corelist);
-               if (h->vfd->minor == minor) {
-                       dev  = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-       if (NULL == dev)
-               return -ENODEV;
-
 
        /* If more than one user, mutex should be added */
        dev->users++;
@@ -1533,8 +1520,6 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
        }
        dev->vfd = vfd;
 
-       list_add_tail(&dev->tm6000_corelist,&tm6000_corelist);
-
        /* init video dma queues */
        INIT_LIST_HEAD(&dev->vidq.active);
        INIT_LIST_HEAD(&dev->vidq.queued);
@@ -1542,6 +1527,7 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
        memcpy (dev->vfd, &tm6000_template, sizeof(*(dev->vfd)));
        dev->vfd->debug=tm6000_debug;
        vfd->v4l2_dev = &dev->v4l2_dev;
+       video_set_drvdata(vfd, dev);
 
        ret = video_register_device(dev->vfd, VFL_TYPE_GRABBER, video_nr);
        printk(KERN_INFO "Trident TVMaster TM5600/TM6000/TM6010 USB2 board (Load status: %d)\n", ret);
@@ -1550,18 +1536,8 @@ int tm6000_v4l2_register(struct tm6000_core *dev)
 
 int tm6000_v4l2_unregister(struct tm6000_core *dev)
 {
-       struct tm6000_core *h;
-       struct list_head *pos, *tmp;
-
        video_unregister_device(dev->vfd);
 
-       list_for_each_safe(pos, tmp, &tm6000_corelist) {
-               h = list_entry(pos, struct tm6000_core, tm6000_corelist);
-               if (h == dev) {
-                       list_del(pos);
-               }
-       }
-
        return 0;
 }
 
index b49c139c6b558bee56e391f0ef345dcf091cc563..6812d6867d578e5fde797935bbaf89db1b25e0fd 100644 (file)
@@ -169,7 +169,6 @@ struct tm6000_core {
        struct i2c_client               i2c_client;
 
        /* video for linux */
-       struct list_head                tm6000_corelist;
        int                             users;
 
        /* various device info */