V4L/DVB (11230): hdpvr: return immediately from hdpvr_poll if data is available

simplifies check for available data with hdpvr_get_next_buffer

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Janne Grunau 2009-03-26 14:32:54 -03:00 committed by Mauro Carvalho Chehab
parent a50ab29185
commit d2ff3ec816

View file

@ -479,6 +479,7 @@ err:
static unsigned int hdpvr_poll(struct file *filp, poll_table *wait) static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
{ {
struct hdpvr_buffer *buf = NULL;
struct hdpvr_fh *fh = (struct hdpvr_fh *)filp->private_data; struct hdpvr_fh *fh = (struct hdpvr_fh *)filp->private_data;
struct hdpvr_device *dev = fh->dev; struct hdpvr_device *dev = fh->dev;
unsigned int mask = 0; unsigned int mask = 0;
@ -499,19 +500,14 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait)
} }
mutex_unlock(&dev->io_mutex); mutex_unlock(&dev->io_mutex);
poll_wait(filp, &dev->wait_data, wait); buf = hdpvr_get_next_buffer(dev);
/* only wait if no data is available */
mutex_lock(&dev->io_mutex); if (!buf || buf->status != BUFSTAT_READY) {
if (!list_empty(&dev->rec_buff_list)) { poll_wait(filp, &dev->wait_data, wait);
buf = hdpvr_get_next_buffer(dev);
struct hdpvr_buffer *buf = list_entry(dev->rec_buff_list.next,
struct hdpvr_buffer,
buff_list);
if (buf->status == BUFSTAT_READY)
mask |= POLLIN | POLLRDNORM;
} }
mutex_unlock(&dev->io_mutex); if (buf && buf->status == BUFSTAT_READY)
mask |= POLLIN | POLLRDNORM;
return mask; return mask;
} }