Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Milan Svoboda and committed by
Greg Kroah-Hartman
e22fc27c 9bcbcf4d

+31 -1
+31 -1
drivers/usb/gadget/inode.c
··· 32 32 #include <linux/compiler.h> 33 33 #include <asm/uaccess.h> 34 34 #include <linux/slab.h> 35 + #include <linux/poll.h> 35 36 36 37 #include <linux/device.h> 37 38 #include <linux/moduleparam.h> ··· 1236 1235 return 0; 1237 1236 } 1238 1237 1238 + static unsigned int 1239 + ep0_poll (struct file *fd, poll_table *wait) 1240 + { 1241 + struct dev_data *dev = fd->private_data; 1242 + int mask = 0; 1243 + 1244 + poll_wait(fd, &dev->wait, wait); 1245 + 1246 + spin_lock_irq (&dev->lock); 1247 + 1248 + /* report fd mode change before acting on it */ 1249 + if (dev->setup_abort) { 1250 + dev->setup_abort = 0; 1251 + mask = POLLHUP; 1252 + goto out; 1253 + } 1254 + 1255 + if (dev->state == STATE_SETUP) { 1256 + if (dev->setup_in || dev->setup_can_stall) 1257 + mask = POLLOUT; 1258 + } else { 1259 + if (dev->ev_next != 0) 1260 + mask = POLLIN; 1261 + } 1262 + out: 1263 + spin_unlock_irq(&dev->lock); 1264 + return mask; 1265 + } 1266 + 1239 1267 static int dev_ioctl (struct inode *inode, struct file *fd, 1240 1268 unsigned code, unsigned long value) 1241 1269 { ··· 1284 1254 .read = ep0_read, 1285 1255 .write = ep0_write, 1286 1256 .fasync = ep0_fasync, 1287 - // .poll = ep0_poll, 1257 + .poll = ep0_poll, 1288 1258 .ioctl = dev_ioctl, 1289 1259 .release = dev_release, 1290 1260 };