[PATCH 5/12] meye: implement non blocking access using poll()

From: Stelian Pop
Date: Thu Nov 04 2004 - 06:33:53 EST


===================================================================

ChangeSet@xxxxxx, 2004-11-02 15:54:01+01:00, stelian@xxxxxxxxxx
meye: implement non blocking access using poll()

Signed-off-by: Stelian Pop <stelian@xxxxxxxxxx>

===================================================================

meye.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+)

===================================================================

diff -Nru a/drivers/media/video/meye.c b/drivers/media/video/meye.c
--- a/drivers/media/video/meye.c 2004-11-04 11:25:29 +01:00
+++ b/drivers/media/video/meye.c 2004-11-04 11:25:29 +01:00
@@ -937,6 +937,10 @@
up(&meye.lock);
return -EINVAL;
case MEYE_BUF_USING:
+ if (file->f_flags & O_NONBLOCK) {
+ up(&meye.lock);
+ return -EAGAIN;
+ }
if (wait_event_interruptible(meye.proc_list,
(meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
up(&meye.lock);
@@ -1072,6 +1076,10 @@
up(&meye.lock);
return -EINVAL;
case MEYE_BUF_USING:
+ if (file->f_flags & O_NONBLOCK) {
+ up(&meye.lock);
+ return -EAGAIN;
+ }
if (wait_event_interruptible(meye.proc_list,
(meye.grab_buffer[*i].state != MEYE_BUF_USING))) {
up(&meye.lock);
@@ -1137,6 +1145,18 @@
return video_usercopy(inode, file, cmd, arg, meye_do_ioctl);
}

+static unsigned int meye_poll(struct file *file, poll_table *wait)
+{
+ unsigned int res = 0;
+
+ down(&meye.lock);
+ poll_wait(file, &meye.proc_list, wait);
+ if (kfifo_len(meye.doneq))
+ res = POLLIN | POLLRDNORM;
+ up(&meye.lock);
+ return res;
+}
+
static int meye_mmap(struct file *file, struct vm_area_struct *vma) {
unsigned long start = vma->vm_start;
unsigned long size = vma->vm_end - vma->vm_start;
@@ -1178,6 +1198,7 @@
.release = meye_release,
.mmap = meye_mmap,
.ioctl = meye_ioctl,
+ .poll = meye_poll,
.llseek = no_llseek,
};

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/