Commit a991f44b authored by Trent Piepho's avatar Trent Piepho Committed by Mauro Carvalho Chehab

V4L/DVB (6316): Change list_for_each+list_entry to list_for_each_entry

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: default avatarTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent e77e2c2f
...@@ -106,11 +106,9 @@ int bttv_sub_add_device(struct bttv_core *core, char *name) ...@@ -106,11 +106,9 @@ int bttv_sub_add_device(struct bttv_core *core, char *name)
int bttv_sub_del_devices(struct bttv_core *core) int bttv_sub_del_devices(struct bttv_core *core)
{ {
struct bttv_sub_device *sub; struct bttv_sub_device *sub, *save;
struct list_head *item,*save;
list_for_each_safe(item,save,&core->subs) { list_for_each_entry_safe(sub, save, &core->subs, list) {
sub = list_entry(item,struct bttv_sub_device,list);
list_del(&sub->list); list_del(&sub->list);
device_unregister(&sub->dev); device_unregister(&sub->dev);
} }
......
...@@ -1100,7 +1100,6 @@ static int cx23885_restart_queue(struct cx23885_tsport *port, ...@@ -1100,7 +1100,6 @@ static int cx23885_restart_queue(struct cx23885_tsport *port,
{ {
struct cx23885_dev *dev = port->dev; struct cx23885_dev *dev = port->dev;
struct cx23885_buffer *buf; struct cx23885_buffer *buf;
struct list_head *item;
dprintk(5, "%s()\n", __FUNCTION__); dprintk(5, "%s()\n", __FUNCTION__);
if (list_empty(&q->active)) if (list_empty(&q->active))
...@@ -1148,10 +1147,8 @@ static int cx23885_restart_queue(struct cx23885_tsport *port, ...@@ -1148,10 +1147,8 @@ static int cx23885_restart_queue(struct cx23885_tsport *port,
dprintk(2, "restart_queue [%p/%d]: restart dma\n", dprintk(2, "restart_queue [%p/%d]: restart dma\n",
buf, buf->vb.i); buf, buf->vb.i);
cx23885_start_dma(port, q, buf); cx23885_start_dma(port, q, buf);
list_for_each(item, &q->active) { list_for_each_entry(buf, &q->active, vb.queue)
buf = list_entry(item, struct cx23885_buffer, vb.queue);
buf->count = q->count++; buf->count = q->count++;
}
mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT); mod_timer(&q->timeout, jiffies + BUFFER_TIMEOUT);
return 0; return 0;
} }
......
...@@ -92,7 +92,6 @@ static int dpc_probe(struct saa7146_dev* dev) ...@@ -92,7 +92,6 @@ static int dpc_probe(struct saa7146_dev* dev)
{ {
struct dpc* dpc = NULL; struct dpc* dpc = NULL;
struct i2c_client *client; struct i2c_client *client;
struct list_head *item;
dpc = kzalloc(sizeof(struct dpc), GFP_KERNEL); dpc = kzalloc(sizeof(struct dpc), GFP_KERNEL);
if( NULL == dpc ) { if( NULL == dpc ) {
...@@ -116,11 +115,9 @@ static int dpc_probe(struct saa7146_dev* dev) ...@@ -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 */ /* loop through all i2c-devices on the bus and look who is there */
list_for_each(item,&dpc->i2c_adapter.clients) { list_for_each_entry(client, &dpc->i2c_adapter.clients, list)
client = list_entry(item, struct i2c_client, list);
if( I2C_SAA7111A == client->addr ) if( I2C_SAA7111A == client->addr )
dpc->saa7111a = client; dpc->saa7111a = client;
}
/* check if all devices are present */ /* check if all devices are present */
if( 0 == dpc->saa7111a ) { if( 0 == dpc->saa7111a ) {
......
...@@ -252,10 +252,8 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp) ...@@ -252,10 +252,8 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
int minor = iminor(inode); int minor = iminor(inode);
int errCode = 0; int errCode = 0;
struct em28xx *h,*dev = NULL; struct em28xx *h,*dev = NULL;
struct list_head *list;
list_for_each(list,&em28xx_devlist) { list_for_each_entry(h, &em28xx_devlist, devlist) {
h = list_entry(list, struct em28xx, devlist);
if (h->vdev->minor == minor) { if (h->vdev->minor == minor) {
dev = h; dev = h;
dev->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; dev->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
......
...@@ -153,7 +153,6 @@ static int mxb_probe(struct saa7146_dev* dev) ...@@ -153,7 +153,6 @@ static int mxb_probe(struct saa7146_dev* dev)
{ {
struct mxb* mxb = NULL; struct mxb* mxb = NULL;
struct i2c_client *client; struct i2c_client *client;
struct list_head *item;
int result; int result;
if ((result = request_module("saa7111")) < 0) { if ((result = request_module("saa7111")) < 0) {
...@@ -196,8 +195,7 @@ static int mxb_probe(struct saa7146_dev* dev) ...@@ -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 */ /* loop through all i2c-devices on the bus and look who is there */
list_for_each(item,&mxb->i2c_adapter.clients) { list_for_each_entry(client, &mxb->i2c_adapter.clients, list) {
client = list_entry(item, struct i2c_client, list);
if( I2C_ADDR_TEA6420_1 == client->addr ) if( I2C_ADDR_TEA6420_1 == client->addr )
mxb->tea6420_1 = client; mxb->tea6420_1 = client;
if( I2C_ADDR_TEA6420_2 == client->addr ) if( I2C_ADDR_TEA6420_2 == client->addr )
......
...@@ -237,13 +237,10 @@ static const struct file_operations tvmixer_fops = { ...@@ -237,13 +237,10 @@ static const struct file_operations tvmixer_fops = {
static int tvmixer_adapters(struct i2c_adapter *adap) static int tvmixer_adapters(struct i2c_adapter *adap)
{ {
struct list_head *item;
struct i2c_client *client; struct i2c_client *client;
list_for_each(item,&adap->clients) { list_for_each_entry(client, &adap->clients, list)
client = list_entry(item, struct i2c_client, list);
tvmixer_clients(client); tvmixer_clients(client);
}
return 0; return 0;
} }
......
...@@ -34,21 +34,13 @@ static LIST_HEAD(int_list); ...@@ -34,21 +34,13 @@ static LIST_HEAD(int_list);
static void v4l2_int_device_try_attach_all(void) static void v4l2_int_device_try_attach_all(void)
{ {
struct list_head *head_master; struct v4l2_int_device *m, *s;
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);
list_for_each_entry(m, &int_list, head) {
if (m->type != v4l2_int_type_master) if (m->type != v4l2_int_type_master)
continue; continue;
list_for_each(head_slave, &int_list) { list_for_each_entry(s, &int_list, head) {
struct v4l2_int_device *s =
list_entry(head_slave,
struct v4l2_int_device, head);
if (s->type != v4l2_int_type_slave) if (s->type != v4l2_int_type_slave)
continue; continue;
......
...@@ -517,7 +517,6 @@ int videobuf_dqbuf(struct videobuf_queue *q, ...@@ -517,7 +517,6 @@ int videobuf_dqbuf(struct videobuf_queue *q,
int videobuf_streamon(struct videobuf_queue *q) int videobuf_streamon(struct videobuf_queue *q)
{ {
struct videobuf_buffer *buf; struct videobuf_buffer *buf;
struct list_head *list;
unsigned long flags=0; unsigned long flags=0;
int retval; int retval;
...@@ -531,11 +530,9 @@ int videobuf_streamon(struct videobuf_queue *q) ...@@ -531,11 +530,9 @@ int videobuf_streamon(struct videobuf_queue *q)
q->streaming = 1; q->streaming = 1;
if (q->irqlock) if (q->irqlock)
spin_lock_irqsave(q->irqlock,flags); spin_lock_irqsave(q->irqlock,flags);
list_for_each(list,&q->stream) { list_for_each_entry(buf, &q->stream, stream)
buf = list_entry(list, struct videobuf_buffer, stream);
if (buf->state == STATE_PREPARED) if (buf->state == STATE_PREPARED)
q->ops->buf_queue(q,buf); q->ops->buf_queue(q,buf);
}
if (q->irqlock) if (q->irqlock)
spin_unlock_irqrestore(q->irqlock,flags); spin_unlock_irqrestore(q->irqlock,flags);
......
...@@ -507,7 +507,6 @@ static void vivi_stop_thread(struct vivi_dmaqueue *dma_q) ...@@ -507,7 +507,6 @@ static void vivi_stop_thread(struct vivi_dmaqueue *dma_q)
static int restart_video_queue(struct vivi_dmaqueue *dma_q) static int restart_video_queue(struct vivi_dmaqueue *dma_q)
{ {
struct vivi_buffer *buf, *prev; struct vivi_buffer *buf, *prev;
struct list_head *item;
dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q); 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) ...@@ -521,9 +520,7 @@ static int restart_video_queue(struct vivi_dmaqueue *dma_q)
// vivi_start_thread(dma_q); // vivi_start_thread(dma_q);
/* cancel all outstanding capture / vbi requests */ /* cancel all outstanding capture / vbi requests */
list_for_each(item,&dma_q->active) { list_for_each_entry_safe(buf, prev, &dma_q->active, vb.queue) {
buf = list_entry(item, struct vivi_buffer, vb.queue);
list_del(&buf->vb.queue); list_del(&buf->vb.queue);
buf->vb.state = STATE_ERROR; buf->vb.state = STATE_ERROR;
wake_up(&buf->vb.done); wake_up(&buf->vb.done);
...@@ -982,31 +979,25 @@ static int vidioc_s_ctrl (struct file *file, void *priv, ...@@ -982,31 +979,25 @@ static int vidioc_s_ctrl (struct file *file, void *priv,
static int vivi_open(struct inode *inode, struct file *file) static int vivi_open(struct inode *inode, struct file *file)
{ {
int minor = iminor(inode); int minor = iminor(inode);
struct vivi_dev *h,*dev = NULL; struct vivi_dev *dev;
struct vivi_fh *fh; struct vivi_fh *fh;
struct list_head *list;
enum v4l2_buf_type type = 0;
int i; int i;
printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor); printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
list_for_each(list,&vivi_devlist) { list_for_each_entry(dev, &vivi_devlist, vivi_devlist)
h = list_entry(list, struct vivi_dev, vivi_devlist); if (dev->vfd.minor == minor)
if (h->vfd.minor == minor) { goto found;
dev = h; return -ENODEV;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE; found:
}
}
if (NULL == dev)
return -ENODEV;
/* If more than one user, mutex should be added */ /* If more than one user, mutex should be added */
dev->users++; dev->users++;
dprintk(1,"open minor=%d type=%s users=%d\n", dprintk(1, "open minor=%d type=%s users=%d\n", minor,
minor,v4l2_type_names[type],dev->users); v4l2_type_names[V4L2_BUF_TYPE_VIDEO_CAPTURE], dev->users);
/* allocate + initialize per filehandle data */ /* allocate + initialize per filehandle data */
fh = kzalloc(sizeof(*fh),GFP_KERNEL); fh = kzalloc(sizeof(*fh),GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment