diff options
author | Milan Svoboda <msvoboda@ra.rockwell.com> | 2006-08-08 22:23:12 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-27 11:58:54 -0700 |
commit | e22fc27c87b41bda1b0daf8436224b0f79853482 (patch) | |
tree | c4067db8d26ddff8939892cefeb2af600bca90e8 /drivers/usb/gadget | |
parent | 9bcbcf4d00cd2400e655a738e77f0d21b69c6771 (diff) | |
download | linux-e22fc27c87b41bda1b0daf8436224b0f79853482.tar.gz linux-e22fc27c87b41bda1b0daf8436224b0f79853482.tar.bz2 linux-e22fc27c87b41bda1b0daf8436224b0f79853482.zip |
USB: add poll to gadgetfs's endpoint zero
Add poll() support to gadgetfs ep0
Signed-off-by: Milan Svoboda <msvoboda@ra.rockwell.com>
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/inode.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 1072e987ff21..ed9b404e5f5a 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c @@ -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> @@ -1235,6 +1236,35 @@ dev_release (struct inode *inode, struct file *fd) 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) { @@ -1254,7 +1284,7 @@ static const struct file_operations ep0_io_operations = { .read = ep0_read, .write = ep0_write, .fasync = ep0_fasync, - // .poll = ep0_poll, + .poll = ep0_poll, .ioctl = dev_ioctl, .release = dev_release, }; |