diff options
Diffstat (limited to 'drivers/usb/misc/usblcd.c')
-rw-r--r-- | drivers/usb/misc/usblcd.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c index 12bad8a205a7..6e093c2aac2c 100644 --- a/drivers/usb/misc/usblcd.c +++ b/drivers/usb/misc/usblcd.c | |||
@@ -51,7 +51,6 @@ struct usb_lcd { | |||
51 | #define USB_LCD_CONCURRENT_WRITES 5 | 51 | #define USB_LCD_CONCURRENT_WRITES 5 |
52 | 52 | ||
53 | static struct usb_driver lcd_driver; | 53 | static struct usb_driver lcd_driver; |
54 | static DEFINE_MUTEX(usb_lcd_open_mutex); | ||
55 | 54 | ||
56 | 55 | ||
57 | static void lcd_delete(struct kref *kref) | 56 | static void lcd_delete(struct kref *kref) |
@@ -69,24 +68,19 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
69 | struct usb_lcd *dev; | 68 | struct usb_lcd *dev; |
70 | struct usb_interface *interface; | 69 | struct usb_interface *interface; |
71 | int subminor; | 70 | int subminor; |
72 | int retval = 0; | ||
73 | 71 | ||
74 | subminor = iminor(inode); | 72 | subminor = iminor(inode); |
75 | 73 | ||
76 | mutex_lock(&usb_lcd_open_mutex); | ||
77 | interface = usb_find_interface(&lcd_driver, subminor); | 74 | interface = usb_find_interface(&lcd_driver, subminor); |
78 | if (!interface) { | 75 | if (!interface) { |
79 | err ("USBLCD: %s - error, can't find device for minor %d", | 76 | err ("USBLCD: %s - error, can't find device for minor %d", |
80 | __FUNCTION__, subminor); | 77 | __FUNCTION__, subminor); |
81 | retval = -ENODEV; | 78 | return -ENODEV; |
82 | goto exit; | ||
83 | } | 79 | } |
84 | 80 | ||
85 | dev = usb_get_intfdata(interface); | 81 | dev = usb_get_intfdata(interface); |
86 | if (!dev) { | 82 | if (!dev) |
87 | retval = -ENODEV; | 83 | return -ENODEV; |
88 | goto exit; | ||
89 | } | ||
90 | 84 | ||
91 | /* increment our usage count for the device */ | 85 | /* increment our usage count for the device */ |
92 | kref_get(&dev->kref); | 86 | kref_get(&dev->kref); |
@@ -94,9 +88,7 @@ static int lcd_open(struct inode *inode, struct file *file) | |||
94 | /* save our object in the file's private structure */ | 88 | /* save our object in the file's private structure */ |
95 | file->private_data = dev; | 89 | file->private_data = dev; |
96 | 90 | ||
97 | exit: | 91 | return 0; |
98 | mutex_unlock(&usb_lcd_open_mutex); | ||
99 | return retval; | ||
100 | } | 92 | } |
101 | 93 | ||
102 | static int lcd_release(struct inode *inode, struct file *file) | 94 | static int lcd_release(struct inode *inode, struct file *file) |
@@ -363,17 +355,12 @@ static void lcd_disconnect(struct usb_interface *interface) | |||
363 | struct usb_lcd *dev; | 355 | struct usb_lcd *dev; |
364 | int minor = interface->minor; | 356 | int minor = interface->minor; |
365 | 357 | ||
366 | /* prevent skel_open() from racing skel_disconnect() */ | ||
367 | mutex_lock(&usb_lcd_open_mutex); | ||
368 | |||
369 | dev = usb_get_intfdata(interface); | 358 | dev = usb_get_intfdata(interface); |
370 | usb_set_intfdata(interface, NULL); | 359 | usb_set_intfdata(interface, NULL); |
371 | 360 | ||
372 | /* give back our minor */ | 361 | /* give back our minor */ |
373 | usb_deregister_dev(interface, &lcd_class); | 362 | usb_deregister_dev(interface, &lcd_class); |
374 | 363 | ||
375 | mutex_unlock(&usb_lcd_open_mutex); | ||
376 | |||
377 | /* decrement our usage count */ | 364 | /* decrement our usage count */ |
378 | kref_put(&dev->kref, lcd_delete); | 365 | kref_put(&dev->kref, lcd_delete); |
379 | 366 | ||