Commit d046fd5e authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: usblcd: drop redundant lcd mutex

Drop the redundant lcd mutex introduced by commit 925ce689 ("USB:
autoconvert trivial BKL users to private mutex") which replaced an
earlier BKL use.

The lock serialised calls to open() against other open() and a custom
ioctl() returning the bcdDevice (sic!), but neither is needed.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20190926091228.24634-9-johan@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 61991d02
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#define IOCTL_GET_DRV_VERSION 2 #define IOCTL_GET_DRV_VERSION 2
static DEFINE_MUTEX(lcd_mutex);
static const struct usb_device_id id_table[] = { static const struct usb_device_id id_table[] = {
{ .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, },
{ }, { },
...@@ -81,12 +80,10 @@ static int lcd_open(struct inode *inode, struct file *file) ...@@ -81,12 +80,10 @@ static int lcd_open(struct inode *inode, struct file *file)
struct usb_interface *interface; struct usb_interface *interface;
int subminor, r; int subminor, r;
mutex_lock(&lcd_mutex);
subminor = iminor(inode); subminor = iminor(inode);
interface = usb_find_interface(&lcd_driver, subminor); interface = usb_find_interface(&lcd_driver, subminor);
if (!interface) { if (!interface) {
mutex_unlock(&lcd_mutex);
printk(KERN_ERR "USBLCD: %s - error, can't find device for minor %d\n", printk(KERN_ERR "USBLCD: %s - error, can't find device for minor %d\n",
__func__, subminor); __func__, subminor);
return -ENODEV; return -ENODEV;
...@@ -101,13 +98,11 @@ static int lcd_open(struct inode *inode, struct file *file) ...@@ -101,13 +98,11 @@ static int lcd_open(struct inode *inode, struct file *file)
r = usb_autopm_get_interface(interface); r = usb_autopm_get_interface(interface);
if (r < 0) { if (r < 0) {
kref_put(&dev->kref, lcd_delete); kref_put(&dev->kref, lcd_delete);
mutex_unlock(&lcd_mutex);
return r; return r;
} }
/* save our object in the file's private structure */ /* save our object in the file's private structure */
file->private_data = dev; file->private_data = dev;
mutex_unlock(&lcd_mutex);
return 0; return 0;
} }
...@@ -176,14 +171,12 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -176,14 +171,12 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
switch (cmd) { switch (cmd) {
case IOCTL_GET_HARD_VERSION: case IOCTL_GET_HARD_VERSION:
mutex_lock(&lcd_mutex);
bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice);
sprintf(buf, "%1d%1d.%1d%1d", sprintf(buf, "%1d%1d.%1d%1d",
(bcdDevice & 0xF000)>>12, (bcdDevice & 0xF000)>>12,
(bcdDevice & 0xF00)>>8, (bcdDevice & 0xF00)>>8,
(bcdDevice & 0xF0)>>4, (bcdDevice & 0xF0)>>4,
(bcdDevice & 0xF)); (bcdDevice & 0xF));
mutex_unlock(&lcd_mutex);
if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0) if (copy_to_user((void __user *)arg, buf, strlen(buf)) != 0)
return -EFAULT; return -EFAULT;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment