diff options
Diffstat (limited to 'drivers/usb/misc/usblcd.c')
| -rw-r--r-- | drivers/usb/misc/usblcd.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 7828c764b323..d00dde19194c 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/smp_lock.h> | ||
| 20 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
| 21 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
| 22 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
| @@ -30,6 +29,7 @@ | |||
| 30 | #define IOCTL_GET_DRV_VERSION 2 | 29 | #define IOCTL_GET_DRV_VERSION 2 |
| 31 | 30 | ||
| 32 | 31 | ||
| 32 | static DEFINE_MUTEX(lcd_mutex); | ||
| 33 | static const struct usb_device_id id_table[] = { | 33 | static const struct usb_device_id id_table[] = { |
| 34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, | 34 | { .idVendor = 0x10D2, .match_flags = USB_DEVICE_ID_MATCH_VENDOR, }, |
| 35 | { }, | 35 | { }, |
| @@ -74,12 +74,12 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
| 74 | struct usb_interface *interface; | 74 | struct usb_interface *interface; |
| 75 | int subminor, r; | 75 | int subminor, r; |
| 76 | 76 | ||
| 77 | lock_kernel(); | 77 | mutex_lock(&lcd_mutex); |
| 78 | subminor = iminor(inode); | 78 | subminor = iminor(inode); |
| 79 | 79 | ||
| 80 | interface = usb_find_interface(&lcd_driver, subminor); | 80 | interface = usb_find_interface(&lcd_driver, subminor); |
| 81 | if (!interface) { | 81 | if (!interface) { |
| 82 | unlock_kernel(); | 82 | mutex_unlock(&lcd_mutex); |
| 83 | err ("USBLCD: %s - error, can't find device for minor %d", | 83 | err ("USBLCD: %s - error, can't find device for minor %d", |
| 84 | __func__, subminor); | 84 | __func__, subminor); |
| 85 | return -ENODEV; | 85 | return -ENODEV; |
| @@ -89,7 +89,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
| 89 | dev = usb_get_intfdata(interface); | 89 | dev = usb_get_intfdata(interface); |
| 90 | if (!dev) { | 90 | if (!dev) { |
| 91 | mutex_unlock(&open_disc_mutex); | 91 | mutex_unlock(&open_disc_mutex); |
| 92 | unlock_kernel(); | 92 | mutex_unlock(&lcd_mutex); |
| 93 | return -ENODEV; | 93 | return -ENODEV; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| @@ -101,13 +101,13 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
| 101 | r = usb_autopm_get_interface(interface); | 101 | r = usb_autopm_get_interface(interface); |
| 102 | if (r < 0) { | 102 | if (r < 0) { |
| 103 | kref_put(&dev->kref, lcd_delete); | 103 | kref_put(&dev->kref, lcd_delete); |
| 104 | unlock_kernel(); | 104 | mutex_unlock(&lcd_mutex); |
| 105 | return r; | 105 | return r; |
| 106 | } | 106 | } |
| 107 | 107 | ||
| 108 | /* save our object in the file's private structure */ | 108 | /* save our object in the file's private structure */ |
| 109 | file->private_data = dev; | 109 | file->private_data = dev; |
| 110 | unlock_kernel(); | 110 | mutex_unlock(&lcd_mutex); |
| 111 | 111 | ||
| 112 | return 0; | 112 | return 0; |
| 113 | } | 113 | } |
| @@ -116,7 +116,7 @@ static int lcd_release(struct inode *inode, struct file *file) | |||
| 116 | { | 116 | { |
| 117 | struct usb_lcd *dev; | 117 | struct usb_lcd *dev; |
| 118 | 118 | ||
| 119 | dev = (struct usb_lcd *)file->private_data; | 119 | dev = file->private_data; |
| 120 | if (dev == NULL) | 120 | if (dev == NULL) |
| 121 | return -ENODEV; | 121 | return -ENODEV; |
| 122 | 122 | ||
| @@ -132,7 +132,7 @@ static ssize_t lcd_read(struct file *file, char __user * buffer, size_t count, l | |||
| 132 | int retval = 0; | 132 | int retval = 0; |
| 133 | int bytes_read; | 133 | int bytes_read; |
| 134 | 134 | ||
| 135 | dev = (struct usb_lcd *)file->private_data; | 135 | dev = file->private_data; |
| 136 | 136 | ||
| 137 | /* do a blocking bulk read to get data from the device */ | 137 | /* do a blocking bulk read to get data from the device */ |
| 138 | retval = usb_bulk_msg(dev->udev, | 138 | retval = usb_bulk_msg(dev->udev, |
| @@ -158,20 +158,20 @@ static long lcd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 158 | u16 bcdDevice; | 158 | u16 bcdDevice; |
| 159 | char buf[30]; | 159 | char buf[30]; |
| 160 | 160 | ||
| 161 | dev = (struct usb_lcd *)file->private_data; | 161 | dev = file->private_data; |
| 162 | if (dev == NULL) | 162 | if (dev == NULL) |
| 163 | return -ENODEV; | 163 | return -ENODEV; |
| 164 | 164 | ||
| 165 | switch (cmd) { | 165 | switch (cmd) { |
| 166 | case IOCTL_GET_HARD_VERSION: | 166 | case IOCTL_GET_HARD_VERSION: |
| 167 | lock_kernel(); | 167 | mutex_lock(&lcd_mutex); |
| 168 | bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); | 168 | bcdDevice = le16_to_cpu((dev->udev)->descriptor.bcdDevice); |
| 169 | sprintf(buf,"%1d%1d.%1d%1d", | 169 | sprintf(buf,"%1d%1d.%1d%1d", |
| 170 | (bcdDevice & 0xF000)>>12, | 170 | (bcdDevice & 0xF000)>>12, |
| 171 | (bcdDevice & 0xF00)>>8, | 171 | (bcdDevice & 0xF00)>>8, |
| 172 | (bcdDevice & 0xF0)>>4, | 172 | (bcdDevice & 0xF0)>>4, |
| 173 | (bcdDevice & 0xF)); | 173 | (bcdDevice & 0xF)); |
| 174 | unlock_kernel(); | 174 | mutex_unlock(&lcd_mutex); |
| 175 | if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) | 175 | if (copy_to_user((void __user *)arg,buf,strlen(buf))!=0) |
| 176 | return -EFAULT; | 176 | return -EFAULT; |
| 177 | break; | 177 | break; |
| @@ -217,7 +217,7 @@ static ssize_t lcd_write(struct file *file, const char __user * user_buffer, siz | |||
| 217 | struct urb *urb = NULL; | 217 | struct urb *urb = NULL; |
| 218 | char *buf = NULL; | 218 | char *buf = NULL; |
| 219 | 219 | ||
| 220 | dev = (struct usb_lcd *)file->private_data; | 220 | dev = file->private_data; |
| 221 | 221 | ||
| 222 | /* verify that we actually have some data to write */ | 222 | /* verify that we actually have some data to write */ |
| 223 | if (count == 0) | 223 | if (count == 0) |
