]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (11230): hdpvr: return immediately from hdpvr_poll if data is available
authorJanne Grunau <j@jannau.net>
Thu, 26 Mar 2009 17:32:54 +0000 (14:32 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:42 +0000 (12:43 -0300)
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>
drivers/media/video/hdpvr/hdpvr-video.c

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