aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2015-03-04 10:31:50 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-03-08 15:19:03 -0400
commit96b62a57193494010eed66ca0739c93eb4653162 (patch)
tree08bf091d434585988e6c52340f9d9ed5bec07433 /drivers/usb
parentd4461a602cf39c59f32817162539f4e723621865 (diff)
gadgetfs: really get rid of switching ->f_op
... for ep0 as well Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/gadget/legacy/inode.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/usb/gadget/legacy/inode.c b/drivers/usb/gadget/legacy/inode.c
index c0e25320a3c4..200f9a584064 100644
--- a/drivers/usb/gadget/legacy/inode.c
+++ b/drivers/usb/gadget/legacy/inode.c
@@ -909,6 +909,10 @@ ep0_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
909 enum ep0_state state; 909 enum ep0_state state;
910 910
911 spin_lock_irq (&dev->lock); 911 spin_lock_irq (&dev->lock);
912 if (dev->state <= STATE_DEV_OPENED) {
913 retval = -EINVAL;
914 goto done;
915 }
912 916
913 /* report fd mode change before acting on it */ 917 /* report fd mode change before acting on it */
914 if (dev->setup_abort) { 918 if (dev->setup_abort) {
@@ -1107,8 +1111,6 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1107 struct dev_data *dev = fd->private_data; 1111 struct dev_data *dev = fd->private_data;
1108 ssize_t retval = -ESRCH; 1112 ssize_t retval = -ESRCH;
1109 1113
1110 spin_lock_irq (&dev->lock);
1111
1112 /* report fd mode change before acting on it */ 1114 /* report fd mode change before acting on it */
1113 if (dev->setup_abort) { 1115 if (dev->setup_abort) {
1114 dev->setup_abort = 0; 1116 dev->setup_abort = 0;
@@ -1154,7 +1156,6 @@ ep0_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1154 } else 1156 } else
1155 DBG (dev, "fail %s, state %d\n", __func__, dev->state); 1157 DBG (dev, "fail %s, state %d\n", __func__, dev->state);
1156 1158
1157 spin_unlock_irq (&dev->lock);
1158 return retval; 1159 return retval;
1159} 1160}
1160 1161
@@ -1201,6 +1202,9 @@ ep0_poll (struct file *fd, poll_table *wait)
1201 struct dev_data *dev = fd->private_data; 1202 struct dev_data *dev = fd->private_data;
1202 int mask = 0; 1203 int mask = 0;
1203 1204
1205 if (dev->state <= STATE_DEV_OPENED)
1206 return DEFAULT_POLLMASK;
1207
1204 poll_wait(fd, &dev->wait, wait); 1208 poll_wait(fd, &dev->wait, wait);
1205 1209
1206 spin_lock_irq (&dev->lock); 1210 spin_lock_irq (&dev->lock);
@@ -1236,19 +1240,6 @@ static long dev_ioctl (struct file *fd, unsigned code, unsigned long value)
1236 return ret; 1240 return ret;
1237} 1241}
1238 1242
1239/* used after device configuration */
1240static const struct file_operations ep0_io_operations = {
1241 .owner = THIS_MODULE,
1242 .llseek = no_llseek,
1243
1244 .read = ep0_read,
1245 .write = ep0_write,
1246 .fasync = ep0_fasync,
1247 .poll = ep0_poll,
1248 .unlocked_ioctl = dev_ioctl,
1249 .release = dev_release,
1250};
1251
1252/*----------------------------------------------------------------------*/ 1243/*----------------------------------------------------------------------*/
1253 1244
1254/* The in-kernel gadget driver handles most ep0 issues, in particular 1245/* The in-kernel gadget driver handles most ep0 issues, in particular
@@ -1772,6 +1763,14 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1772 u32 tag; 1763 u32 tag;
1773 char *kbuf; 1764 char *kbuf;
1774 1765
1766 spin_lock_irq(&dev->lock);
1767 if (dev->state > STATE_DEV_OPENED) {
1768 value = ep0_write(fd, buf, len, ptr);
1769 spin_unlock_irq(&dev->lock);
1770 return value;
1771 }
1772 spin_unlock_irq(&dev->lock);
1773
1775 if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4)) 1774 if (len < (USB_DT_CONFIG_SIZE + USB_DT_DEVICE_SIZE + 4))
1776 return -EINVAL; 1775 return -EINVAL;
1777 1776
@@ -1845,7 +1844,6 @@ dev_config (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
1845 * on, they can work ... except in cleanup paths that 1844 * on, they can work ... except in cleanup paths that
1846 * kick in after the ep0 descriptor is closed. 1845 * kick in after the ep0 descriptor is closed.
1847 */ 1846 */
1848 fd->f_op = &ep0_io_operations;
1849 value = len; 1847 value = len;
1850 } 1848 }
1851 return value; 1849 return value;
@@ -1876,12 +1874,14 @@ dev_open (struct inode *inode, struct file *fd)
1876 return value; 1874 return value;
1877} 1875}
1878 1876
1879static const struct file_operations dev_init_operations = { 1877static const struct file_operations ep0_operations = {
1880 .llseek = no_llseek, 1878 .llseek = no_llseek,
1881 1879
1882 .open = dev_open, 1880 .open = dev_open,
1881 .read = ep0_read,
1883 .write = dev_config, 1882 .write = dev_config,
1884 .fasync = ep0_fasync, 1883 .fasync = ep0_fasync,
1884 .poll = ep0_poll,
1885 .unlocked_ioctl = dev_ioctl, 1885 .unlocked_ioctl = dev_ioctl,
1886 .release = dev_release, 1886 .release = dev_release,
1887}; 1887};
@@ -1997,7 +1997,7 @@ gadgetfs_fill_super (struct super_block *sb, void *opts, int silent)
1997 goto Enomem; 1997 goto Enomem;
1998 1998
1999 dev->sb = sb; 1999 dev->sb = sb;
2000 dev->dentry = gadgetfs_create_file(sb, CHIP, dev, &dev_init_operations); 2000 dev->dentry = gadgetfs_create_file(sb, CHIP, dev, &ep0_operations);
2001 if (!dev->dentry) { 2001 if (!dev->dentry) {
2002 put_dev(dev); 2002 put_dev(dev);
2003 goto Enomem; 2003 goto Enomem;