Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 306308
b: refs/heads/master
c: a2d887c
h: refs/heads/master
v: v3
  • Loading branch information
Hans de Goede authored and Mauro Carvalho Chehab committed May 14, 2012
1 parent 2b6140f commit a1034b4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9a190c858cacd4b0110fefda5046ade8cd726261
refs/heads/master: a2d887c5fea33f341fd0d2a1487150473cf69014
44 changes: 26 additions & 18 deletions trunk/drivers/media/video/gspca/gspca.c
Original file line number Diff line number Diff line change
Expand Up @@ -2030,31 +2030,39 @@ static int read_alloc(struct gspca_dev *gspca_dev,
static unsigned int dev_poll(struct file *file, poll_table *wait)
{
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");

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 (gspca_dev->memory == GSPCA_MEMORY_NO) {
ret = read_alloc(gspca_dev, file);
if (ret != 0)
return POLLERR;
}
if (req_events & (POLLIN | POLLRDNORM)) {
/* if reqbufs is not done, the user would use read() */
if (gspca_dev->memory == GSPCA_MEMORY_NO) {
if (read_alloc(gspca_dev, file) != 0) {
ret |= POLLERR;
goto out;
}
}

if (mutex_lock_interruptible(&gspca_dev->queue_lock) != 0)
return POLLERR;
poll_wait(file, &gspca_dev->wq, wait);

/* check if an image has been received */
if (gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i))
ret = POLLIN | POLLRDNORM; /* yes */
else
ret = 0;
ret |= v4l2_ctrl_poll(file, wait);
mutex_unlock(&gspca_dev->queue_lock);
/* check if an image has been received */
if (mutex_lock_interruptible(&gspca_dev->queue_lock) != 0) {
ret |= POLLERR;
goto out;
}
if (gspca_dev->fr_o != atomic_read(&gspca_dev->fr_i))
ret |= POLLIN | POLLRDNORM;
mutex_unlock(&gspca_dev->queue_lock);
}

out:
if (!gspca_dev->present)
return POLLHUP;
ret |= POLLHUP;

return ret;
}

Expand Down

0 comments on commit a1034b4

Please sign in to comment.