This patch adds poll functionality for end-point 0. This
allows to use select/poll/epoll instead of signals.

Feedback and comments are highly appreciated.

Signed-off-by: Milan Svoboda <[EMAIL PROTECTED]>
---

diff -uprN -X orig/Documentation/dontdiff orig/drivers/usb/gadget/inode.c 
new_gadget/drivers/usb/gadget/inode.c
--- orig/drivers/usb/gadget/inode.c     2006-06-19 10:42:37.000000000 +0000
+++ new_gadget/drivers/usb/gadget/inode.c       2006-06-23 10:01:04.000000000 
+0000
@@ -1230,6 +1230,35 @@ dev_release (struct inode *inode, struct
        return 0;
 }
 
+static unsigned int
+ep0_poll (struct file *fd, poll_table *wait)
+{
+       struct dev_data         *dev = fd->private_data;
+       int                     mask = 0;
+
+       spin_lock_irq (&dev->lock);
+
+       /* report fd mode change before acting on it */
+       if (dev->setup_abort) {
+               dev->setup_abort = 0;
+               mask = POLLNVAL;
+               goto out;
+       }
+
+       if (dev->state == STATE_SETUP) {
+               if (dev->setup_in || dev->setup_can_stall)
+                       mask = POLLOUT;
+       } else {
+               if (dev->ev_next != 0)
+                       mask = POLLIN;
+       }
+
+       poll_wait(fd, &dev->wait, wait);
+out:
+       spin_unlock_irq(&dev->lock);
+       return mask;
+}
+
 static int dev_ioctl (struct inode *inode, struct file *fd,
                unsigned code, unsigned long value)
 {
@@ -1249,7 +1278,7 @@ static struct file_operations ep0_io_ope
        .read =         ep0_read,
        .write =        ep0_write,
        .fasync =       ep0_fasync,
-       // .poll =      ep0_poll,
+       .poll =         ep0_poll,
        .ioctl =        dev_ioctl,
        .release =      dev_release,
 };
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to