diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-24 15:02:38 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2012-01-24 15:02:38 -0500 |
commit | 52a749992ca6a0fd304609af40ed3bfd6cef4660 (patch) | |
tree | 713e871865a8f2cee8d6a3aebca2f4513d797f3b /drivers/usb/usb-skeleton.c | |
parent | d1620ca9e7bb0030068c3b45b653defde8839dac (diff) |
Revert "USB: usb-skeleton.c: fix open/disconnect race"
This reverts commit 26c71a79cade5ccad80e0752cd82f3518df48fb3.
It's not needed, to quote Ming Lei:
Looks you have queued the patch into your tree, but just now I
find the patch is not needed at all, since we have had
minor_rwsem(drivers/usb/core/file.c) for this purpose, please
drop the patch, sorry for it.
Cc: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/usb-skeleton.c')
-rw-r--r-- | drivers/usb/usb-skeleton.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c index 8efeae24764f..b4a71679c933 100644 --- a/drivers/usb/usb-skeleton.c +++ b/drivers/usb/usb-skeleton.c | |||
@@ -27,8 +27,6 @@ | |||
27 | #define USB_SKEL_VENDOR_ID 0xfff0 | 27 | #define USB_SKEL_VENDOR_ID 0xfff0 |
28 | #define USB_SKEL_PRODUCT_ID 0xfff0 | 28 | #define USB_SKEL_PRODUCT_ID 0xfff0 |
29 | 29 | ||
30 | static DEFINE_MUTEX(skel_mutex); | ||
31 | |||
32 | /* table of devices that work with this driver */ | 30 | /* table of devices that work with this driver */ |
33 | static const struct usb_device_id skel_table[] = { | 31 | static const struct usb_device_id skel_table[] = { |
34 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, | 32 | { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, |
@@ -101,25 +99,18 @@ static int skel_open(struct inode *inode, struct file *file) | |||
101 | goto exit; | 99 | goto exit; |
102 | } | 100 | } |
103 | 101 | ||
104 | mutex_lock(&skel_mutex); | ||
105 | dev = usb_get_intfdata(interface); | 102 | dev = usb_get_intfdata(interface); |
106 | if (!dev) { | 103 | if (!dev) { |
107 | mutex_unlock(&skel_mutex); | ||
108 | retval = -ENODEV; | 104 | retval = -ENODEV; |
109 | goto exit; | 105 | goto exit; |
110 | } | 106 | } |
111 | 107 | ||
112 | /* increment our usage count for the device */ | 108 | /* increment our usage count for the device */ |
113 | kref_get(&dev->kref); | 109 | kref_get(&dev->kref); |
114 | mutex_unlock(&skel_mutex); | ||
115 | 110 | ||
116 | /* lock the device to allow correctly handling errors | 111 | /* lock the device to allow correctly handling errors |
117 | * in resumption */ | 112 | * in resumption */ |
118 | mutex_lock(&dev->io_mutex); | 113 | mutex_lock(&dev->io_mutex); |
119 | if (!dev->interface) { | ||
120 | retval = -ENODEV; | ||
121 | goto out_err; | ||
122 | } | ||
123 | 114 | ||
124 | retval = usb_autopm_get_interface(interface); | 115 | retval = usb_autopm_get_interface(interface); |
125 | if (retval) | 116 | if (retval) |
@@ -127,11 +118,7 @@ static int skel_open(struct inode *inode, struct file *file) | |||
127 | 118 | ||
128 | /* save our object in the file's private structure */ | 119 | /* save our object in the file's private structure */ |
129 | file->private_data = dev; | 120 | file->private_data = dev; |
130 | |||
131 | out_err: | ||
132 | mutex_unlock(&dev->io_mutex); | 121 | mutex_unlock(&dev->io_mutex); |
133 | if (retval) | ||
134 | kref_put(&dev->kref, skel_delete); | ||
135 | 122 | ||
136 | exit: | 123 | exit: |
137 | return retval; | 124 | return retval; |
@@ -611,6 +598,7 @@ static void skel_disconnect(struct usb_interface *interface) | |||
611 | int minor = interface->minor; | 598 | int minor = interface->minor; |
612 | 599 | ||
613 | dev = usb_get_intfdata(interface); | 600 | dev = usb_get_intfdata(interface); |
601 | usb_set_intfdata(interface, NULL); | ||
614 | 602 | ||
615 | /* give back our minor */ | 603 | /* give back our minor */ |
616 | usb_deregister_dev(interface, &skel_class); | 604 | usb_deregister_dev(interface, &skel_class); |
@@ -622,12 +610,8 @@ static void skel_disconnect(struct usb_interface *interface) | |||
622 | 610 | ||
623 | usb_kill_anchored_urbs(&dev->submitted); | 611 | usb_kill_anchored_urbs(&dev->submitted); |
624 | 612 | ||
625 | mutex_lock(&skel_mutex); | ||
626 | usb_set_intfdata(interface, NULL); | ||
627 | |||
628 | /* decrement our usage count */ | 613 | /* decrement our usage count */ |
629 | kref_put(&dev->kref, skel_delete); | 614 | kref_put(&dev->kref, skel_delete); |
630 | mutex_unlock(&skel_mutex); | ||
631 | 615 | ||
632 | dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); | 616 | dev_info(&interface->dev, "USB Skeleton #%d now disconnected", minor); |
633 | } | 617 | } |