]> err.no Git - linux-2.6/commitdiff
V4L/DVB (6316): Change list_for_each+list_entry to list_for_each_entry
authorTrent Piepho <xyzzy@speakeasy.org>
Wed, 10 Oct 2007 08:37:43 +0000 (05:37 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Wed, 10 Oct 2007 16:35:29 +0000 (13:35 -0300)
The rest of V4L files.

There is one list_for_each+list_entry in cpia_pp.c that
wasn't changed because it expects the loop iterator to remain NULL if
the list is empty.

A bug in vivi is fixed; the 'safe' version needs to be used because the loop
deletes the list entries.

Simplify a second loop in vivi and get rid if an un-used variable in that loop.

Signed-off-by: Trent Piepho <xyzzy@speakeasy.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/video/bt8xx/bttv-gpio.c
drivers/media/video/cx23885/cx23885-core.c
drivers/media/video/dpc7146.c
drivers/media/video/em28xx/em28xx-video.c
drivers/media/video/mxb.c
drivers/media/video/tvmixer.c
drivers/media/video/v4l2-int-device.c
drivers/media/video/videobuf-core.c
drivers/media/video/vivi.c

index 84154c26f9c5fb3c4bed9d1a099073260e9ff0c8..dce6dae5740efa55586cd9bf88e24a675e0cd41e 100644 (file)
@@ -106,11 +106,9 @@ int bttv_sub_add_device(struct bttv_core *core, char *name)
 
 int bttv_sub_del_devices(struct bttv_core *core)
 {
-       struct bttv_sub_device *sub;
-       struct list_head *item,*save;
+       struct bttv_sub_device *sub, *save;
 
-       list_for_each_safe(item,save,&core->subs) {
-               sub = list_entry(item,struct bttv_sub_device,list);
+       list_for_each_entry_safe(sub, save, &core->subs, list) {
                list_del(&sub->list);
                device_unregister(&sub->dev);
        }
index 4d0614093ad658ec8aed345989ae7eb17bd04663..af16505bd2e0516a743d213c6924f57d5a3390f0 100644 (file)
@@ -1100,7 +1100,6 @@ static int cx23885_restart_queue(struct cx23885_tsport *port,
 {
        struct cx23885_dev *dev = port->dev;
        struct cx23885_buffer *buf;
-       struct list_head *item;
 
        dprintk(5, "%s()\n", __FUNCTION__);
        if (list_empty(&q->active))
@@ -1148,10 +1147,8 @@ static int cx23885_restart_queue(struct cx23885_tsport *port,
        dprintk(2, "restart_queue [%p/%d]: restart dma\n",
                buf, buf->vb.i);
        cx23885_start_dma(port, q, buf);
-       list_for_each(item, &q->active) {
-               buf = list_entry(item, struct cx23885_buffer, vb.queue);
+       list_for_each_entry(buf, &q->active, vb.queue)
                buf->count = q->count++;
-       }
        mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT);
        return 0;
 }
index 0fcc935828f8e8a23e4f90523e3a54abfc3727a9..255dae303708d3b98142f33e850e48a8b8f1209f 100644 (file)
@@ -92,7 +92,6 @@ static int dpc_probe(struct saa7146_dev* dev)
 {
        struct dpc* dpc = NULL;
        struct i2c_client *client;
-       struct list_head *item;
 
        dpc = kzalloc(sizeof(struct dpc), GFP_KERNEL);
        if( NULL == dpc ) {
@@ -116,11 +115,9 @@ static int dpc_probe(struct saa7146_dev* dev)
        }
 
        /* loop through all i2c-devices on the bus and look who is there */
-       list_for_each(item,&dpc->i2c_adapter.clients) {
-               client = list_entry(item, struct i2c_client, list);
+       list_for_each_entry(client, &dpc->i2c_adapter.clients, list)
                if( I2C_SAA7111A == client->addr )
                        dpc->saa7111a = client;
-       }
 
        /* check if all devices are present */
        if( 0 == dpc->saa7111a ) {
index e4fba906833628b5984c139734fa8b7d8ce6dbb6..b8d5327c438ded1e879216b485f7d1ac0ea2a82d 100644 (file)
@@ -252,10 +252,8 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
        int minor = iminor(inode);
        int errCode = 0;
        struct em28xx *h,*dev = NULL;
-       struct list_head *list;
 
-       list_for_each(list,&em28xx_devlist) {
-               h = list_entry(list, struct em28xx, devlist);
+       list_for_each_entry(h, &em28xx_devlist, devlist) {
                if (h->vdev->minor == minor) {
                        dev  = h;
                        dev->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
index 152cc6b3e1521232a510442a8e6b980585c6ec75..98ad3092a079cb7659c1f8c6c29c1e6bc3b1f557 100644 (file)
@@ -153,7 +153,6 @@ static int mxb_probe(struct saa7146_dev* dev)
 {
        struct mxb* mxb = NULL;
        struct i2c_client *client;
-       struct list_head *item;
        int result;
 
        if ((result = request_module("saa7111")) < 0) {
@@ -196,8 +195,7 @@ static int mxb_probe(struct saa7146_dev* dev)
        }
 
        /* loop through all i2c-devices on the bus and look who is there */
-       list_for_each(item,&mxb->i2c_adapter.clients) {
-               client = list_entry(item, struct i2c_client, list);
+       list_for_each_entry(client, &mxb->i2c_adapter.clients, list) {
                if( I2C_ADDR_TEA6420_1 == client->addr )
                        mxb->tea6420_1 = client;
                if( I2C_ADDR_TEA6420_2 == client->addr )
index 544a4ae7d2ed97bc32fdaa8c167cf26c550cd5d5..9fa5b702e0736ddfc99b26177bae0c547aefd70d 100644 (file)
@@ -237,13 +237,10 @@ static const struct file_operations tvmixer_fops = {
 
 static int tvmixer_adapters(struct i2c_adapter *adap)
 {
-       struct list_head  *item;
        struct i2c_client *client;
 
-       list_for_each(item,&adap->clients) {
-               client = list_entry(item, struct i2c_client, list);
+       list_for_each_entry(client, &adap->clients, list)
                tvmixer_clients(client);
-       }
        return 0;
 }
 
index f497c9458344e36eeaf32026a0e440414b5b5496..8b4ef530a3a8a60c58013e5a865efaac9776d578 100644 (file)
@@ -34,21 +34,13 @@ static LIST_HEAD(int_list);
 
 static void v4l2_int_device_try_attach_all(void)
 {
-       struct list_head *head_master;
-
-       list_for_each(head_master, &int_list) {
-               struct list_head *head_slave;
-               struct v4l2_int_device *m =
-                       list_entry(head_master, struct v4l2_int_device, head);
+       struct v4l2_int_device *m, *s;
 
+       list_for_each_entry(m, &int_list, head) {
                if (m->type != v4l2_int_type_master)
                        continue;
 
-               list_for_each(head_slave, &int_list) {
-                       struct v4l2_int_device *s =
-                               list_entry(head_slave,
-                                          struct v4l2_int_device, head);
-
+               list_for_each_entry(s, &int_list, head) {
                        if (s->type != v4l2_int_type_slave)
                                continue;
 
index 25a98496e3db6cf27c68a3e35441174d747276a6..c606332512b60e9edf01382591da8206eb64497e 100644 (file)
@@ -517,7 +517,6 @@ int videobuf_dqbuf(struct videobuf_queue *q,
 int videobuf_streamon(struct videobuf_queue *q)
 {
        struct videobuf_buffer *buf;
-       struct list_head *list;
        unsigned long flags=0;
        int retval;
 
@@ -531,11 +530,9 @@ int videobuf_streamon(struct videobuf_queue *q)
        q->streaming = 1;
        if (q->irqlock)
                spin_lock_irqsave(q->irqlock,flags);
-       list_for_each(list,&q->stream) {
-               buf = list_entry(list, struct videobuf_buffer, stream);
+       list_for_each_entry(buf, &q->stream, stream)
                if (buf->state == STATE_PREPARED)
                        q->ops->buf_queue(q,buf);
-       }
        if (q->irqlock)
                spin_unlock_irqrestore(q->irqlock,flags);
 
index 61a6608d6e612c0c49fe7a613ff78c34381de691..b532aa280a1be1b4b509b0f184de25e59b92d5df 100644 (file)
@@ -507,7 +507,6 @@ static void vivi_stop_thread(struct vivi_dmaqueue  *dma_q)
 static int restart_video_queue(struct vivi_dmaqueue *dma_q)
 {
        struct vivi_buffer *buf, *prev;
-       struct list_head *item;
 
        dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
 
@@ -521,9 +520,7 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
 //             vivi_start_thread(dma_q);
 
                /* cancel all outstanding capture / vbi requests */
-               list_for_each(item,&dma_q->active) {
-                       buf = list_entry(item, struct vivi_buffer, vb.queue);
-
+               list_for_each_entry_safe(buf, prev, &dma_q->active, vb.queue) {
                        list_del(&buf->vb.queue);
                        buf->vb.state = STATE_ERROR;
                        wake_up(&buf->vb.done);
@@ -982,31 +979,25 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
 static int vivi_open(struct inode *inode, struct file *file)
 {
        int minor = iminor(inode);
-       struct vivi_dev *h,*dev = NULL;
+       struct vivi_dev *dev;
        struct vivi_fh *fh;
-       struct list_head *list;
-       enum v4l2_buf_type type = 0;
        int i;
 
        printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
 
-       list_for_each(list,&vivi_devlist) {
-               h = list_entry(list, struct vivi_dev, vivi_devlist);
-               if (h->vfd.minor == minor) {
-                       dev  = h;
-                       type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-               }
-       }
-       if (NULL == dev)
-               return -ENODEV;
+       list_for_each_entry(dev, &vivi_devlist, vivi_devlist)
+               if (dev->vfd.minor == minor)
+                       goto found;
+       return -ENODEV;
+found:
 
 
 
        /* If more than one user, mutex should be added */
        dev->users++;
 
-       dprintk(1,"open minor=%d type=%s users=%d\n",
-                               minor,v4l2_type_names[type],dev->users);
+       dprintk(1, "open minor=%d type=%s users=%d\n", minor,
+               v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users);
 
        /* allocate + initialize per filehandle data */
        fh = kzalloc(sizeof(*fh),GFP_KERNEL);