]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
[media] saa7164: fix poll bugs
authorHans Verkuil <hans.verkuil@cisco.com>
Fri, 28 Aug 2015 11:48:28 +0000 (08:48 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 1 Oct 2015 11:22:41 +0000 (08:22 -0300)
- poll doesn't return negative values, so you can't return -EINVAL.
  Instead return POLLERR.
- poll can't be called if !video_is_registered(), so this test can
  be dropped.
- poll can never do a blocking wait, so remove that check.
- poll shouldn't attempt to start streaming if the caller isn't interested
  in read events.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/pci/saa7164/saa7164-encoder.c

index 96dd1e483c793bca3ed74d6c958f498a5a1061f6..fd32fa0c8cb7fa0795ea7f60deba48bf2f7a144b 100644 (file)
@@ -915,6 +915,7 @@ static ssize_t fops_read(struct file *file, char __user *buffer,
 
 static unsigned int fops_poll(struct file *file, poll_table *wait)
 {
+       unsigned long req_events = poll_requested_events(wait);
        struct saa7164_encoder_fh *fh =
                (struct saa7164_encoder_fh *)file->private_data;
        struct saa7164_port *port = fh->port;
@@ -928,26 +929,18 @@ static unsigned int fops_poll(struct file *file, poll_table *wait)
        saa7164_histogram_update(&port->poll_interval,
                port->last_poll_msecs_diff);
 
-       if (!video_is_registered(port->v4l_device))
-               return -EIO;
+       if (!(req_events & (POLLIN | POLLRDNORM)))
+               return mask;
 
        if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) {
                if (atomic_inc_return(&port->v4l_reader_count) == 1) {
                        if (saa7164_encoder_initialize(port) < 0)
-                               return -EINVAL;
+                               return POLLERR;
                        saa7164_encoder_start_streaming(port);
                        msleep(200);
                }
        }
 
-       /* blocking wait for buffer */
-       if ((file->f_flags & O_NONBLOCK) == 0) {
-               if (wait_event_interruptible(port->wait_read,
-                       saa7164_enc_next_buf(port))) {
-                               return -ERESTARTSYS;
-               }
-       }
-
        /* Pull the first buffer from the used list */
        if (!list_empty(&port->list_buf_used.list))
                mask |= POLLIN | POLLRDNORM;