Commit a2d887c5 authored by Hans de Goede's avatar Hans de Goede Committed by Mauro Carvalho Chehab

[media] gspca: Use req_events in poll

So that we don't start a read stream when an app is only polling for control
events.
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 9a190c85
...@@ -2030,31 +2030,39 @@ static int read_alloc(struct gspca_dev *gspca_dev, ...@@ -2030,31 +2030,39 @@ static int read_alloc(struct gspca_dev *gspca_dev,
static unsigned int dev_poll(struct file *file, poll_table *wait) static unsigned int dev_poll(struct file *file, poll_table *wait)
{ {
struct gspca_dev *gspca_dev = video_drvdata(file); struct gspca_dev *gspca_dev = video_drvdata(file);
int ret; unsigned long req_events = poll_requested_events(wait);
int ret = 0;
PDEBUG(D_FRAM, "poll"); PDEBUG(D_FRAM, "poll");
poll_wait(file, &gspca_dev->wq, wait); if (req_events & POLLPRI)
ret |= v4l2_ctrl_poll(file, wait);
/* if reqbufs is not done, the user would use read() */ if (req_events & (POLLIN | POLLRDNORM)) {
if (gspca_dev->memory == GSPCA_MEMORY_NO) { /* if reqbufs is not done, the user would use read() */
ret = read_alloc(gspca_dev, file); if (gspca_dev->memory == GSPCA_MEMORY_NO) {
if (ret != 0) if (read_alloc(gspca_dev, file) != 0) {
return POLLERR; ret |= POLLERR;
} goto out;
}
}
if (mutex_lock_interruptible(&gspca_dev->queue_lock) != 0) poll_wait(file, &gspca_dev->wq, wait);
return POLLERR;
/* check if an image has been received */ /* check if an image has been received */
if (gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i)) if (mutex_lock_interruptible(&gspca_dev->queue_lock) != 0) {
ret = POLLIN | POLLRDNORM; /* yes */ ret |= POLLERR;
else goto out;
ret = 0; }
ret |= v4l2_ctrl_poll(file, wait); if (gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i))
mutex_unlock(&gspca_dev->queue_lock); ret |= POLLIN | POLLRDNORM;
mutex_unlock(&gspca_dev->queue_lock);
}
out:
if (!gspca_dev->present) if (!gspca_dev->present)
return POLLHUP; ret |= POLLHUP;
return ret; return ret;
} }
......
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