[media] stk-webcam: fix read() handling when reqbufs was already called
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 6 Feb 2013 07:23:01 +0000 (04:23 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 5 Mar 2013 17:43:41 +0000 (14:43 -0300)
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>
drivers/media/usb/stkwebcam/stk-webcam.c
drivers/media/usb/stkwebcam/stk-webcam.h

index 2f1a09db11353c5d5d0e83393c957467f870b9d8..a8fdbaf3472012ba2f2efe2da058aaafb50f3ad0 100644 (file)
@@ -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);
index 03550cf60dcdbf381997ddd3de7682f956cd137b..9bbfa3d9bfdda3a41a26ed05427f05aae3ba68c1 100644 (file)
@@ -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;