/* cx231xx_v4l2_read() will allocate buffers when called for the first time  */
static ssize_t cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, loff_t *pos)
/* cx231xx_v4l2_read() will allocate buffers when called for the first time  */
static ssize_t cx231xx_v4l2_read(struct file *filp, char __user *buf, size_t count, loff_t *pos)
{
	struct cx231xx_fh *fh = filp->private_data;
	struct cx231xx *dev = fh->dev;
	int rc;
	rc = check_dev(dev);
	if (rc < 0)
		return rc;
	if ((fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) ||
	    (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE)) {
		mutex_lock(&dev->lock);
		rc = res_get(fh);
		mutex_unlock(&dev->lock);
		if (unlikely(rc < 0))
			return rc;
		return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0,
					    filp->f_flags & O_NONBLOCK);
	}
	return 0;
}