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

USB: gadget: Push BKL down into drivers

This keeps the gadget ioctl method wrapped but pushes the BKL down into
the gadget code so we can use unlocked_ioctl().

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
44c389a0 0391c828

+16 -14
+13 -10
drivers/usb/gadget/inode.c
··· 32 32 #include <asm/uaccess.h> 33 33 #include <linux/slab.h> 34 34 #include <linux/poll.h> 35 + #include <linux/smp_lock.h> 35 36 36 37 #include <linux/device.h> 37 38 #include <linux/moduleparam.h> ··· 484 483 return 0; 485 484 } 486 485 487 - static int ep_ioctl (struct inode *inode, struct file *fd, 488 - unsigned code, unsigned long value) 486 + static long ep_ioctl(struct file *fd, unsigned code, unsigned long value) 489 487 { 490 488 struct ep_data *data = fd->private_data; 491 489 int status; ··· 740 740 741 741 .read = ep_read, 742 742 .write = ep_write, 743 - .ioctl = ep_ioctl, 743 + .unlocked_ioctl = ep_ioctl, 744 744 .release = ep_release, 745 745 746 746 .aio_read = ep_aio_read, ··· 1294 1294 return mask; 1295 1295 } 1296 1296 1297 - static int dev_ioctl (struct inode *inode, struct file *fd, 1298 - unsigned code, unsigned long value) 1297 + static long dev_ioctl (struct file *fd, unsigned code, unsigned long value) 1299 1298 { 1300 1299 struct dev_data *dev = fd->private_data; 1301 1300 struct usb_gadget *gadget = dev->gadget; 1301 + long ret = -ENOTTY; 1302 1302 1303 - if (gadget->ops->ioctl) 1304 - return gadget->ops->ioctl (gadget, code, value); 1305 - return -ENOTTY; 1303 + if (gadget->ops->ioctl) { 1304 + lock_kernel(); 1305 + ret = gadget->ops->ioctl (gadget, code, value); 1306 + unlock_kernel(); 1307 + } 1308 + return ret; 1306 1309 } 1307 1310 1308 1311 /* used after device configuration */ ··· 1317 1314 .write = ep0_write, 1318 1315 .fasync = ep0_fasync, 1319 1316 .poll = ep0_poll, 1320 - .ioctl = dev_ioctl, 1317 + .unlocked_ioctl = dev_ioctl, 1321 1318 .release = dev_release, 1322 1319 }; 1323 1320 ··· 1967 1964 .open = dev_open, 1968 1965 .write = dev_config, 1969 1966 .fasync = ep0_fasync, 1970 - .ioctl = dev_ioctl, 1967 + .unlocked_ioctl = dev_ioctl, 1971 1968 .release = dev_release, 1972 1969 }; 1973 1970
+3 -4
drivers/usb/gadget/printer.c
··· 828 828 return status; 829 829 } 830 830 831 - static int 832 - printer_ioctl(struct inode *inode, struct file *fd, unsigned int code, 833 - unsigned long arg) 831 + static long 832 + printer_ioctl(struct file *fd, unsigned int code, unsigned long arg) 834 833 { 835 834 struct printer_dev *dev = fd->private_data; 836 835 unsigned long flags; ··· 868 869 .write = printer_write, 869 870 .fsync = printer_fsync, 870 871 .poll = printer_poll, 871 - .ioctl = printer_ioctl, 872 + .unlocked_ioctl = printer_ioctl, 872 873 .release = printer_close 873 874 }; 874 875