sync: add poll support
authorErik Gilling <konkers@android.com>
Tue, 20 Mar 2012 00:28:32 +0000 (17:28 -0700)
committerErik Gilling <konkers@android.com>
Wed, 18 Apr 2012 21:11:52 +0000 (14:11 -0700)
Change-Id: I294e481bba92658e6dd26f157ddbf0e9ff4ce8a5
Signed-off-by: Erik Gilling <konkers@android.com>
drivers/base/sync.c

index 2abb3d3ff1e06ab92adcac7e03428dd6f0af0078..d6913f8e194e8e1d6e613ea04d72c81ac56e27ae 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)
 {
        __u32 value;