> 
> On Monday 26 June 2006 3:53 am, Milan Svoboda wrote:
> > +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);
> 
> It'd probably be better to call poll_wait() to add this to
> the waitqueue _before_ grabbing the spinlock ... even if
> that's safe, it looks dubious and other drivers avoid doing
> such waitqueue updates while irqs are disabled.
> 

OK.

> > +       /* report fd mode change before acting on it */
> > +       if (dev->setup_abort) {
> > +               dev->setup_abort = 0;
> > +               mask = POLLNVAL;
> 
> Man page says POLLNVAL means invalid, "fd not open"; so it
> does not apply here ... POLLHUP makes more sense as a way
> to indicate that the previous SETUP request was aborted,
> or even POLLERR.
> 

OK, I use POLLHUP.

Thank you for review, there is updated version:

Signed-off-by: Milan Svoboda <[EMAIL PROTECTED]>
---
diff -uprN -X ../../le/2.6/orig.bak.never.touch/Documentation/dontdiff 
../../le/2.6/orig.bak.never.touch/drivers/usb/gadget/inode.c 
test/drivers/usb/gadget/inode.c
--- ../../le/2.6/orig.bak.never.touch/drivers/usb/gadget/inode.c 
2006-06-19 14:48:25.000000000 +0000
+++ test/drivers/usb/gadget/inode.c     2006-06-28 13:19:14.000000000 
+0000
@@ -32,6 +32,7 @@
 #include <linux/compiler.h>
 #include <asm/uaccess.h>
 #include <linux/slab.h>
+#include <linux/poll.h>
 
 #include <linux/device.h>
 #include <linux/moduleparam.h>
@@ -1230,6 +1237,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;
+
+       poll_wait(fd, &dev->wait, wait);
+
+       spin_lock_irq (&dev->lock);
+
+       /* report fd mode change before acting on it */
+       if (dev->setup_abort) {
+               dev->setup_abort = 0;
+               mask = POLLHUP;
+               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;
+       }
+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 +1285,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