aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2015-08-28 07:48:28 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-10-01 07:22:41 -0400
commit45053edc054ac9467adfdaf4f8a39db15af22b37 (patch)
treea6955a24f14419f083f8479b28b1d3cbda6f9d40 /drivers/media/pci
parentd6d3fe2fe118ad13ac3a24c1e45a37312b44c462 (diff)
[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: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/saa7164/saa7164-encoder.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/media/pci/saa7164/saa7164-encoder.c b/drivers/media/pci/saa7164/saa7164-encoder.c
index 96dd1e483c79..fd32fa0c8cb7 100644
--- a/drivers/media/pci/saa7164/saa7164-encoder.c
+++ b/drivers/media/pci/saa7164/saa7164-encoder.c
@@ -915,6 +915,7 @@ err:
915 915
916static unsigned int fops_poll(struct file *file, poll_table *wait) 916static unsigned int fops_poll(struct file *file, poll_table *wait)
917{ 917{
918 unsigned long req_events = poll_requested_events(wait);
918 struct saa7164_encoder_fh *fh = 919 struct saa7164_encoder_fh *fh =
919 (struct saa7164_encoder_fh *)file->private_data; 920 (struct saa7164_encoder_fh *)file->private_data;
920 struct saa7164_port *port = fh->port; 921 struct saa7164_port *port = fh->port;
@@ -928,26 +929,18 @@ static unsigned int fops_poll(struct file *file, poll_table *wait)
928 saa7164_histogram_update(&port->poll_interval, 929 saa7164_histogram_update(&port->poll_interval,
929 port->last_poll_msecs_diff); 930 port->last_poll_msecs_diff);
930 931
931 if (!video_is_registered(port->v4l_device)) 932 if (!(req_events & (POLLIN | POLLRDNORM)))
932 return -EIO; 933 return mask;
933 934
934 if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) { 935 if (atomic_cmpxchg(&fh->v4l_reading, 0, 1) == 0) {
935 if (atomic_inc_return(&port->v4l_reader_count) == 1) { 936 if (atomic_inc_return(&port->v4l_reader_count) == 1) {
936 if (saa7164_encoder_initialize(port) < 0) 937 if (saa7164_encoder_initialize(port) < 0)
937 return -EINVAL; 938 return POLLERR;
938 saa7164_encoder_start_streaming(port); 939 saa7164_encoder_start_streaming(port);
939 msleep(200); 940 msleep(200);
940 } 941 }
941 } 942 }
942 943
943 /* blocking wait for buffer */
944 if ((file->f_flags & O_NONBLOCK) == 0) {
945 if (wait_event_interruptible(port->wait_read,
946 saa7164_enc_next_buf(port))) {
947 return -ERESTARTSYS;
948 }
949 }
950
951 /* Pull the first buffer from the used list */ 944 /* Pull the first buffer from the used list */
952 if (!list_empty(&port->list_buf_used.list)) 945 if (!list_empty(&port->list_buf_used.list))
953 mask |= POLLIN | POLLRDNORM; 946 mask |= POLLIN | POLLRDNORM;