diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-12 19:46:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-12 19:46:58 -0400 |
commit | 9374430a52dfae5c013b88f7f030c04a6774d410 (patch) | |
tree | ce1ee8eee4e79fbb9486e810278d1092afc74a44 /drivers/usb/misc/legousbtower.c | |
parent | 66f49739fe1591197364f2dad1b67b975e8f5e85 (diff) | |
parent | 13f9966b3ba5b45f47f2ea0eb0a90afceedfbb1f (diff) |
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/usb-2.6: (149 commits)
USB: ohci-pnx4008: Remove unnecessary cast of return value of kzalloc
USB: additions to the quirk list
usb-storage: implement autosuspend
USB: cdc-acm: add new device id to option driver
USB: goku_udc trivial cleanups
USB: usb gadget stack can now -DDEBUG with Kconfig
usb gadget stack: remove usb_ep_*_buffer(), part 2
usb gadget stack: remove usb_ep_*_buffer(), part 1
USB: pxa2xx_udc -- cleanups, mostly removing dma hooks
USB: pxa2xx_udc: use generic gpio layer
USB: quirk for samsung printer
USB: usb/dma doc updates
USB: drivers/usb/storage/unusual_devs.h whitespace cleanup
USB: remove Makefile reference to obsolete OHCI_AT91
USB: io_*: remove bogus termios no change checks
USB: mos7720: remove bogus no termios change check
USB: visor and whiteheat: remove bogus termios change checks
USB: pl2303: remove bogus checks and fix speed support to use tty_get_baud_rate()
USB: mos7840.c: turn this into a serial driver
USB: make the usb_device numa_node get assigned from controller
...
Diffstat (limited to 'drivers/usb/misc/legousbtower.c')
-rw-r--r-- | drivers/usb/misc/legousbtower.c | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 1713e19a7899..2ed0daea894c 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -254,9 +254,6 @@ static int tower_probe (struct usb_interface *interface, const struct usb_devic | |||
254 | static void tower_disconnect (struct usb_interface *interface); | 254 | static void tower_disconnect (struct usb_interface *interface); |
255 | 255 | ||
256 | 256 | ||
257 | /* prevent races between open() and disconnect */ | ||
258 | static DEFINE_MUTEX (disconnect_mutex); | ||
259 | |||
260 | /* file operations needed when we register this driver */ | 257 | /* file operations needed when we register this driver */ |
261 | static const struct file_operations tower_fops = { | 258 | static const struct file_operations tower_fops = { |
262 | .owner = THIS_MODULE, | 259 | .owner = THIS_MODULE, |
@@ -344,28 +341,26 @@ static int tower_open (struct inode *inode, struct file *file) | |||
344 | nonseekable_open(inode, file); | 341 | nonseekable_open(inode, file); |
345 | subminor = iminor(inode); | 342 | subminor = iminor(inode); |
346 | 343 | ||
347 | mutex_lock (&disconnect_mutex); | ||
348 | |||
349 | interface = usb_find_interface (&tower_driver, subminor); | 344 | interface = usb_find_interface (&tower_driver, subminor); |
350 | 345 | ||
351 | if (!interface) { | 346 | if (!interface) { |
352 | err ("%s - error, can't find device for minor %d", | 347 | err ("%s - error, can't find device for minor %d", |
353 | __FUNCTION__, subminor); | 348 | __FUNCTION__, subminor); |
354 | retval = -ENODEV; | 349 | retval = -ENODEV; |
355 | goto unlock_disconnect_exit; | 350 | goto exit; |
356 | } | 351 | } |
357 | 352 | ||
358 | dev = usb_get_intfdata(interface); | 353 | dev = usb_get_intfdata(interface); |
359 | 354 | ||
360 | if (!dev) { | 355 | if (!dev) { |
361 | retval = -ENODEV; | 356 | retval = -ENODEV; |
362 | goto unlock_disconnect_exit; | 357 | goto exit; |
363 | } | 358 | } |
364 | 359 | ||
365 | /* lock this device */ | 360 | /* lock this device */ |
366 | if (down_interruptible (&dev->sem)) { | 361 | if (down_interruptible (&dev->sem)) { |
367 | retval = -ERESTARTSYS; | 362 | retval = -ERESTARTSYS; |
368 | goto unlock_disconnect_exit; | 363 | goto exit; |
369 | } | 364 | } |
370 | 365 | ||
371 | /* allow opening only once */ | 366 | /* allow opening only once */ |
@@ -421,9 +416,7 @@ static int tower_open (struct inode *inode, struct file *file) | |||
421 | unlock_exit: | 416 | unlock_exit: |
422 | up (&dev->sem); | 417 | up (&dev->sem); |
423 | 418 | ||
424 | unlock_disconnect_exit: | 419 | exit: |
425 | mutex_unlock (&disconnect_mutex); | ||
426 | |||
427 | dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); | 420 | dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); |
428 | 421 | ||
429 | return retval; | 422 | return retval; |
@@ -993,19 +986,16 @@ static void tower_disconnect (struct usb_interface *interface) | |||
993 | 986 | ||
994 | dbg(2, "%s: enter", __FUNCTION__); | 987 | dbg(2, "%s: enter", __FUNCTION__); |
995 | 988 | ||
996 | mutex_lock (&disconnect_mutex); | ||
997 | |||
998 | dev = usb_get_intfdata (interface); | 989 | dev = usb_get_intfdata (interface); |
999 | usb_set_intfdata (interface, NULL); | 990 | usb_set_intfdata (interface, NULL); |
1000 | 991 | ||
1001 | |||
1002 | down (&dev->sem); | ||
1003 | |||
1004 | minor = dev->minor; | 992 | minor = dev->minor; |
1005 | 993 | ||
1006 | /* give back our minor */ | 994 | /* give back our minor */ |
1007 | usb_deregister_dev (interface, &tower_class); | 995 | usb_deregister_dev (interface, &tower_class); |
1008 | 996 | ||
997 | down (&dev->sem); | ||
998 | |||
1009 | /* if the device is not opened, then we clean up right now */ | 999 | /* if the device is not opened, then we clean up right now */ |
1010 | if (!dev->open_count) { | 1000 | if (!dev->open_count) { |
1011 | up (&dev->sem); | 1001 | up (&dev->sem); |
@@ -1015,8 +1005,6 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1015 | up (&dev->sem); | 1005 | up (&dev->sem); |
1016 | } | 1006 | } |
1017 | 1007 | ||
1018 | mutex_unlock (&disconnect_mutex); | ||
1019 | |||
1020 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); | 1008 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); |
1021 | 1009 | ||
1022 | dbg(2, "%s: leave", __FUNCTION__); | 1010 | dbg(2, "%s: leave", __FUNCTION__); |