staging: sync: Add poll support
authorErik Gilling <konkers@android.com>
Fri, 1 Mar 2013 00:43:04 +0000 (16:43 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Mar 2013 09:40:08 +0000 (17:40 +0800)
Support poll on sync fence

Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Erik Gilling <konkers@android.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Rob Clark <robclark@gmail.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: dri-devel@lists.freedesktop.org
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Erik Gilling <konkers@android.com>
[jstultz: Add commit message]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/sync.c

index f84caad35d6809b27211f8f1fa8eec688309b230..9e35ea3e73dae18d69a54c643ebe8de4806b80a1 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/file.h>
 #include <linux/fs.h>
 #include <linux/kernel.h>
+#include <linux/poll.h>
 #include <linux/sched.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
@@ -221,12 +222,14 @@ out:
 }
 
 static int sync_fence_release(struct inode *inode, struct file *file);
+static unsigned int sync_fence_poll(struct file *file, poll_table *wait);
 static long sync_fence_ioctl(struct file *file, unsigned int cmd,
                             unsigned long arg);
 
 
 static const struct file_operations sync_fence_fops = {
        .release = sync_fence_release,
+       .poll = sync_fence_poll,
        .unlocked_ioctl = sync_fence_ioctl,
 };
 
@@ -497,6 +500,20 @@ static int sync_fence_release(struct inode *inode, struct file *file)
        return 0;
 }
 
+static unsigned int sync_fence_poll(struct file *file, poll_table *wait)
+{
+       struct sync_fence *fence = file->private_data;
+
+       poll_wait(file, &fence->wq, wait);
+
+       if (fence->status == 1)
+               return POLLIN;
+       else if (fence->status < 0)
+               return POLLERR;
+       else
+               return 0;
+}
+
 static long sync_fence_ioctl_wait(struct sync_fence *fence, unsigned long arg)
 {
        __s32 value;