From: Hans Verkuil Date: Wed, 6 Feb 2013 07:23:01 +0000 (-0300) Subject: [media] stk-webcam: fix read() handling when reqbufs was already called X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=1b499fe506257369fd6059422989e36c71b99897;p=openwrt%2Fstaging%2Fblogic.git [media] stk-webcam: fix read() handling when reqbufs was already called Signed-off-by: Hans Verkuil Tested-by: Arvydas Sidorenko Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c index 2f1a09db1135..a8fdbaf34720 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c @@ -654,7 +654,7 @@ static ssize_t stk_read(struct file *fp, char __user *buf, if (!is_present(dev)) return -EIO; - if (dev->owner && dev->owner != fp) + if (dev->owner && (!dev->reading || dev->owner != fp)) return -EBUSY; dev->owner = fp; if (!is_streaming(dev)) { @@ -662,6 +662,7 @@ static ssize_t stk_read(struct file *fp, char __user *buf, || stk_allocate_buffers(dev, 3) || stk_start_stream(dev)) return -ENOMEM; + dev->reading = 1; spin_lock_irqsave(&dev->spinlock, flags); for (i = 0; i < dev->n_sbufs; i++) { list_add_tail(&dev->sio_bufs[i].list, &dev->sio_avail); diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h index 03550cf60dcd..9bbfa3d9bfdd 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.h +++ b/drivers/media/usb/stkwebcam/stk-webcam.h @@ -118,6 +118,7 @@ struct stk_camera { int frame_size; /* Streaming buffers */ + int reading; unsigned int n_sbufs; struct stk_sio_buffer *sio_bufs; struct list_head sio_avail;