aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorMilan Svoboda <msvoboda@ra.rockwell.com>2006-08-09 01:23:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-09-27 14:58:54 -0400
commite22fc27c87b41bda1b0daf8436224b0f79853482 (patch)
treec4067db8d26ddff8939892cefeb2af600bca90e8 /drivers/usb/gadget
parent9bcbcf4d00cd2400e655a738e77f0d21b69c6771 (diff)
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.c32
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 @@
32#include <linux/compiler.h> 32#include <linux/compiler.h>
33#include <asm/uaccess.h> 33#include <asm/uaccess.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/poll.h>
35 36
36#include <linux/device.h> 37#include <linux/device.h>
37#include <linux/moduleparam.h> 38#include <linux/moduleparam.h>
@@ -1235,6 +1236,35 @@ dev_release (struct inode *inode, struct file *fd)
1235 return 0; 1236 return 0;
1236} 1237}
1237 1238
1239static unsigned int
1240ep0_poll (struct file *fd, poll_table *wait)
1241{
1242 struct dev_data *dev = fd->private_data;
1243 int mask = 0;
1244
1245 poll_wait(fd, &dev->wait, wait);
1246
1247 spin_lock_irq (&dev->lock);
1248
1249 /* report fd mode change before acting on it */
1250 if (dev->setup_abort) {
1251 dev->setup_abort = 0;
1252 mask = POLLHUP;
1253 goto out;
1254 }
1255
1256 if (dev->state == STATE_SETUP) {
1257 if (dev->setup_in || dev->setup_can_stall)
1258 mask = POLLOUT;
1259 } else {
1260 if (dev->ev_next != 0)
1261 mask = POLLIN;
1262 }
1263out:
1264 spin_unlock_irq(&dev->lock);
1265 return mask;
1266}
1267
1238static int dev_ioctl (struct inode *inode, struct file *fd, 1268static int dev_ioctl (struct inode *inode, struct file *fd,
1239 unsigned code, unsigned long value) 1269 unsigned code, unsigned long value)
1240{ 1270{
@@ -1254,7 +1284,7 @@ static const struct file_operations ep0_io_operations = {
1254 .read = ep0_read, 1284 .read = ep0_read,
1255 .write = ep0_write, 1285 .write = ep0_write,
1256 .fasync = ep0_fasync, 1286 .fasync = ep0_fasync,
1257 // .poll = ep0_poll, 1287 .poll = ep0_poll,
1258 .ioctl = dev_ioctl, 1288 .ioctl = dev_ioctl,
1259 .release = dev_release, 1289 .release = dev_release,
1260}; 1290};