提交 a991f44b 编写于 作者: T Trent Piepho 提交者: 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: NTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 e77e2c2f
......@@ -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);
}
......
......@@ -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;
}
......
......@@ -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 ) {
......
......@@ -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;
......
......@@ -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 )
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册