Commit 45053edc authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

[media] saa7164: fix poll bugs

- 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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent d6d3fe2f
...@@ -915,6 +915,7 @@ static ssize_t fops_read(struct file *file, char __user *buffer, ...@@ -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) 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 *fh =
(struct saa7164_encoder_fh *)file->private_data; (struct saa7164_encoder_fh *)file->private_data;
struct saa7164_port *port = fh->port; struct saa7164_port *port = fh->port;
...@@ -928,26 +929,18 @@ static unsigned int fops_poll(struct file *file, poll_table *wait) ...@@ -928,26 +929,18 @@ static unsigned int fops_poll(struct file *file, poll_table *wait)
saa7164_histogram_update(&port->poll_interval, saa7164_histogram_update(&port->poll_interval,
port->last_poll_msecs_diff); port->last_poll_msecs_diff);
if (!video_is_registered(port->v4l_device)) if (!(req_events & (POLLIN | POLLRDNORM)))
return -EIO; return mask;
if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) {
if (atomic_inc_return(&port->v4l_reader_count) == 1) { if (atomic_inc_return(&port->v4l_reader_count) == 1) {
if (saa7164_encoder_initialize(port) < 0) if (saa7164_encoder_initialize(port) < 0)
return -EINVAL; return POLLERR;
saa7164_encoder_start_streaming(port); saa7164_encoder_start_streaming(port);
msleep(200); 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 */ /* Pull the first buffer from the used list */
if (!list_empty(&port->list_buf_used.list)) if (!list_empty(&port->list_buf_used.list))
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment