retval = videobuf_waiton(q->read_buf, nonblocking, 1); 
retval = videobuf_waiton(q->read_buf, nonblocking, 1); 
ssize_t videobuf_read_one(struct videobuf_queue *q,			  char __user *data, size_t count, loff_t *ppos,			  int nonblocking){	enum v4l2_field field;	unsigned long flags;	unsigned size, nbufs, bytes;	int retval;	down(&q->lock);	nbufs = 1; size = 0;	q->ops->buf_setup(q,&nbufs,&size);	if (NULL == q->read_buf  &&	    count >= size        &&	    !nonblocking) {		retval = videobuf_read_zerocopy(q,data,count,ppos);		if (retval >= 0  ||  retval == -EIO)			/* ok, all done */			goto done;		/* fallback to kernel bounce buffer on failures */	}	if (NULL == q->read_buf) {		/* need to capture a new frame */		retval = -ENOMEM;		q->read_buf = videobuf_alloc(q->msize);		if (NULL == q->read_buf)			goto done;		q->read_buf->memory = V4L2_MEMORY_USERPTR;		field = videobuf_next_field(q);		retval = q->ops->buf_prepare(q,q->read_buf,field);		if (0 != retval)			goto done;		spin_lock_irqsave(q->irqlock,flags);		q->ops->buf_queue(q,q->read_buf);		spin_unlock_irqrestore(q->irqlock,flags);		q->read_off = 0;	}	/* wait until capture is done */        retval = videobuf_waiton(q->read_buf, nonblocking, 1);	if (0 != retval)		goto done;	videobuf_dma_pci_sync(q->pci,&q->read_buf->dma);	if (STATE_ERROR == q->read_buf->state) {		/* catch I/O errors */		q->ops->buf_release(q,q->read_buf);		kfree(q->read_buf);		q->read_buf = NULL;		retval = -EIO;		goto done;	}	/* copy to userspace */	bytes = count;	if (bytes > q->read_buf->size - q->read_off)		bytes = q->read_buf->size - q->read_off;	retval = -EFAULT;	if (copy_to_user(data, q->read_buf->dma.vmalloc+q->read_off, bytes))		goto done;	retval = bytes;	q->read_off += bytes;	if (q->read_off == q->read_buf->size) {		/* all data copied, cleanup */		q->ops->buf_release(q,q->read_buf);		kfree(q->read_buf);		q->read_buf = NULL;	} done:	up(&q->lock);	return retval;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/4ac97914c6c35f6bf132071c718e034d0846b9f5/video-buf.c/buggy/drivers/media/video/video-buf.c