[media] stk-webcam: fix read() handling when reqbufs was already called
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Tested-by: Arvydas Sidorenko <asido4@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Родитель
f80daa2d7d
Коммит
1b499fe506
|
@ -654,7 +654,7 @@ static ssize_t stk_read(struct file *fp, char __user *buf,
|
||||||
|
|
||||||
if (!is_present(dev))
|
if (!is_present(dev))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
if (dev->owner && dev->owner != fp)
|
if (dev->owner && (!dev->reading || dev->owner != fp))
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
dev->owner = fp;
|
dev->owner = fp;
|
||||||
if (!is_streaming(dev)) {
|
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_allocate_buffers(dev, 3)
|
||||||
|| stk_start_stream(dev))
|
|| stk_start_stream(dev))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
dev->reading = 1;
|
||||||
spin_lock_irqsave(&dev->spinlock, flags);
|
spin_lock_irqsave(&dev->spinlock, flags);
|
||||||
for (i = 0; i < dev->n_sbufs; i++) {
|
for (i = 0; i < dev->n_sbufs; i++) {
|
||||||
list_add_tail(&dev->sio_bufs[i].list, &dev->sio_avail);
|
list_add_tail(&dev->sio_bufs[i].list, &dev->sio_avail);
|
||||||
|
|
|
@ -118,6 +118,7 @@ struct stk_camera {
|
||||||
|
|
||||||
int frame_size;
|
int frame_size;
|
||||||
/* Streaming buffers */
|
/* Streaming buffers */
|
||||||
|
int reading;
|
||||||
unsigned int n_sbufs;
|
unsigned int n_sbufs;
|
||||||
struct stk_sio_buffer *sio_bufs;
|
struct stk_sio_buffer *sio_bufs;
|
||||||
struct list_head sio_avail;
|
struct list_head sio_avail;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче