diff options
Diffstat (limited to 'drivers/usb/gadget/inode.c')
-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 @@ | |||
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 | ||
1239 | static unsigned int | ||
1240 | ep0_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 | } | ||
1263 | out: | ||
1264 | spin_unlock_irq(&dev->lock); | ||
1265 | return mask; | ||
1266 | } | ||
1267 | |||
1238 | static int dev_ioctl (struct inode *inode, struct file *fd, | 1268 | static 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 | }; |