diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-01-11 09:55:29 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-20 17:49:55 -0500 |
commit | 4186ecf8ad16dd05759a09594de6a87e48759ba6 (patch) | |
tree | 3ee5292d9f4a36e3eb359b586289ec972bcbaf39 /drivers/usb/misc | |
parent | 35cce732d9d4d9af6b4ad4d26d8f8c0eddb573a2 (diff) |
[PATCH] USB: convert a bunch of USB semaphores to mutexes
the patch below converts a bunch of semaphores-used-as-mutex in the USB
code to mutexes
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r-- | drivers/usb/misc/idmouse.c | 25 | ||||
-rw-r--r-- | drivers/usb/misc/ldusb.c | 11 | ||||
-rw-r--r-- | drivers/usb/misc/legousbtower.c | 11 |
3 files changed, 25 insertions, 22 deletions
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index b3aca5124339..d0b167256699 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> |
27 | #include <linux/completion.h> | 27 | #include <linux/completion.h> |
28 | #include <linux/mutex.h> | ||
28 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
29 | #include <linux/usb.h> | 30 | #include <linux/usb.h> |
30 | 31 | ||
@@ -121,7 +122,7 @@ static struct usb_driver idmouse_driver = { | |||
121 | }; | 122 | }; |
122 | 123 | ||
123 | /* prevent races between open() and disconnect() */ | 124 | /* prevent races between open() and disconnect() */ |
124 | static DECLARE_MUTEX(disconnect_sem); | 125 | static DEFINE_MUTEX(disconnect_mutex); |
125 | 126 | ||
126 | static int idmouse_create_image(struct usb_idmouse *dev) | 127 | static int idmouse_create_image(struct usb_idmouse *dev) |
127 | { | 128 | { |
@@ -213,18 +214,18 @@ static int idmouse_open(struct inode *inode, struct file *file) | |||
213 | int result = 0; | 214 | int result = 0; |
214 | 215 | ||
215 | /* prevent disconnects */ | 216 | /* prevent disconnects */ |
216 | down(&disconnect_sem); | 217 | mutex_lock(&disconnect_mutex); |
217 | 218 | ||
218 | /* get the interface from minor number and driver information */ | 219 | /* get the interface from minor number and driver information */ |
219 | interface = usb_find_interface (&idmouse_driver, iminor (inode)); | 220 | interface = usb_find_interface (&idmouse_driver, iminor (inode)); |
220 | if (!interface) { | 221 | if (!interface) { |
221 | up(&disconnect_sem); | 222 | mutex_unlock(&disconnect_mutex); |
222 | return -ENODEV; | 223 | return -ENODEV; |
223 | } | 224 | } |
224 | /* get the device information block from the interface */ | 225 | /* get the device information block from the interface */ |
225 | dev = usb_get_intfdata(interface); | 226 | dev = usb_get_intfdata(interface); |
226 | if (!dev) { | 227 | if (!dev) { |
227 | up(&disconnect_sem); | 228 | mutex_unlock(&disconnect_mutex); |
228 | return -ENODEV; | 229 | return -ENODEV; |
229 | } | 230 | } |
230 | 231 | ||
@@ -258,7 +259,7 @@ error: | |||
258 | up(&dev->sem); | 259 | up(&dev->sem); |
259 | 260 | ||
260 | /* unlock the disconnect semaphore */ | 261 | /* unlock the disconnect semaphore */ |
261 | up(&disconnect_sem); | 262 | mutex_unlock(&disconnect_mutex); |
262 | return result; | 263 | return result; |
263 | } | 264 | } |
264 | 265 | ||
@@ -267,12 +268,12 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
267 | struct usb_idmouse *dev; | 268 | struct usb_idmouse *dev; |
268 | 269 | ||
269 | /* prevent a race condition with open() */ | 270 | /* prevent a race condition with open() */ |
270 | down(&disconnect_sem); | 271 | mutex_lock(&disconnect_mutex); |
271 | 272 | ||
272 | dev = (struct usb_idmouse *) file->private_data; | 273 | dev = (struct usb_idmouse *) file->private_data; |
273 | 274 | ||
274 | if (dev == NULL) { | 275 | if (dev == NULL) { |
275 | up(&disconnect_sem); | 276 | mutex_unlock(&disconnect_mutex); |
276 | return -ENODEV; | 277 | return -ENODEV; |
277 | } | 278 | } |
278 | 279 | ||
@@ -282,7 +283,7 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
282 | /* are we really open? */ | 283 | /* are we really open? */ |
283 | if (dev->open <= 0) { | 284 | if (dev->open <= 0) { |
284 | up(&dev->sem); | 285 | up(&dev->sem); |
285 | up(&disconnect_sem); | 286 | mutex_unlock(&disconnect_mutex); |
286 | return -ENODEV; | 287 | return -ENODEV; |
287 | } | 288 | } |
288 | 289 | ||
@@ -292,12 +293,12 @@ static int idmouse_release(struct inode *inode, struct file *file) | |||
292 | /* the device was unplugged before the file was released */ | 293 | /* the device was unplugged before the file was released */ |
293 | up(&dev->sem); | 294 | up(&dev->sem); |
294 | idmouse_delete(dev); | 295 | idmouse_delete(dev); |
295 | up(&disconnect_sem); | 296 | mutex_unlock(&disconnect_mutex); |
296 | return 0; | 297 | return 0; |
297 | } | 298 | } |
298 | 299 | ||
299 | up(&dev->sem); | 300 | up(&dev->sem); |
300 | up(&disconnect_sem); | 301 | mutex_unlock(&disconnect_mutex); |
301 | return 0; | 302 | return 0; |
302 | } | 303 | } |
303 | 304 | ||
@@ -399,7 +400,7 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
399 | struct usb_idmouse *dev; | 400 | struct usb_idmouse *dev; |
400 | 401 | ||
401 | /* prevent races with open() */ | 402 | /* prevent races with open() */ |
402 | down(&disconnect_sem); | 403 | mutex_lock(&disconnect_mutex); |
403 | 404 | ||
404 | /* get device structure */ | 405 | /* get device structure */ |
405 | dev = usb_get_intfdata(interface); | 406 | dev = usb_get_intfdata(interface); |
@@ -421,7 +422,7 @@ static void idmouse_disconnect(struct usb_interface *interface) | |||
421 | if (!dev->open) | 422 | if (!dev->open) |
422 | idmouse_delete(dev); | 423 | idmouse_delete(dev); |
423 | 424 | ||
424 | up(&disconnect_sem); | 425 | mutex_unlock(&disconnect_mutex); |
425 | 426 | ||
426 | info("%s disconnected", DRIVER_DESC); | 427 | info("%s disconnected", DRIVER_DESC); |
427 | } | 428 | } |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index f6bdaf08a80f..966acb474f67 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
36 | #include <linux/mutex.h> | ||
36 | 37 | ||
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | #include <linux/input.h> | 39 | #include <linux/input.h> |
@@ -172,7 +173,7 @@ struct ld_usb { | |||
172 | }; | 173 | }; |
173 | 174 | ||
174 | /* prevent races between open() and disconnect() */ | 175 | /* prevent races between open() and disconnect() */ |
175 | static DECLARE_MUTEX(disconnect_sem); | 176 | static DEFINE_MUTEX(disconnect_mutex); |
176 | 177 | ||
177 | static struct usb_driver ld_usb_driver; | 178 | static struct usb_driver ld_usb_driver; |
178 | 179 | ||
@@ -293,7 +294,7 @@ static int ld_usb_open(struct inode *inode, struct file *file) | |||
293 | nonseekable_open(inode, file); | 294 | nonseekable_open(inode, file); |
294 | subminor = iminor(inode); | 295 | subminor = iminor(inode); |
295 | 296 | ||
296 | down(&disconnect_sem); | 297 | mutex_lock(&disconnect_mutex); |
297 | 298 | ||
298 | interface = usb_find_interface(&ld_usb_driver, subminor); | 299 | interface = usb_find_interface(&ld_usb_driver, subminor); |
299 | 300 | ||
@@ -355,7 +356,7 @@ unlock_exit: | |||
355 | up(&dev->sem); | 356 | up(&dev->sem); |
356 | 357 | ||
357 | unlock_disconnect_exit: | 358 | unlock_disconnect_exit: |
358 | up(&disconnect_sem); | 359 | mutex_unlock(&disconnect_mutex); |
359 | 360 | ||
360 | return retval; | 361 | return retval; |
361 | } | 362 | } |
@@ -740,7 +741,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) | |||
740 | struct ld_usb *dev; | 741 | struct ld_usb *dev; |
741 | int minor; | 742 | int minor; |
742 | 743 | ||
743 | down(&disconnect_sem); | 744 | mutex_lock(&disconnect_mutex); |
744 | 745 | ||
745 | dev = usb_get_intfdata(intf); | 746 | dev = usb_get_intfdata(intf); |
746 | usb_set_intfdata(intf, NULL); | 747 | usb_set_intfdata(intf, NULL); |
@@ -761,7 +762,7 @@ static void ld_usb_disconnect(struct usb_interface *intf) | |||
761 | up(&dev->sem); | 762 | up(&dev->sem); |
762 | } | 763 | } |
763 | 764 | ||
764 | up(&disconnect_sem); | 765 | mutex_unlock(&disconnect_mutex); |
765 | 766 | ||
766 | dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", | 767 | dev_info(&intf->dev, "LD USB Device #%d now disconnected\n", |
767 | (minor - USB_LD_MINOR_BASE)); | 768 | (minor - USB_LD_MINOR_BASE)); |
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c index 1336745b8f55..779bcf0373ad 100644 --- a/drivers/usb/misc/legousbtower.c +++ b/drivers/usb/misc/legousbtower.c | |||
@@ -83,6 +83,7 @@ | |||
83 | #include <linux/module.h> | 83 | #include <linux/module.h> |
84 | #include <linux/smp_lock.h> | 84 | #include <linux/smp_lock.h> |
85 | #include <linux/completion.h> | 85 | #include <linux/completion.h> |
86 | #include <linux/mutex.h> | ||
86 | #include <asm/uaccess.h> | 87 | #include <asm/uaccess.h> |
87 | #include <linux/usb.h> | 88 | #include <linux/usb.h> |
88 | #include <linux/poll.h> | 89 | #include <linux/poll.h> |
@@ -256,7 +257,7 @@ static void tower_disconnect (struct usb_interface *interface); | |||
256 | 257 | ||
257 | 258 | ||
258 | /* prevent races between open() and disconnect */ | 259 | /* prevent races between open() and disconnect */ |
259 | static DECLARE_MUTEX (disconnect_sem); | 260 | static DEFINE_MUTEX (disconnect_mutex); |
260 | 261 | ||
261 | /* file operations needed when we register this driver */ | 262 | /* file operations needed when we register this driver */ |
262 | static struct file_operations tower_fops = { | 263 | static struct file_operations tower_fops = { |
@@ -349,7 +350,7 @@ static int tower_open (struct inode *inode, struct file *file) | |||
349 | nonseekable_open(inode, file); | 350 | nonseekable_open(inode, file); |
350 | subminor = iminor(inode); | 351 | subminor = iminor(inode); |
351 | 352 | ||
352 | down (&disconnect_sem); | 353 | mutex_lock (&disconnect_mutex); |
353 | 354 | ||
354 | interface = usb_find_interface (&tower_driver, subminor); | 355 | interface = usb_find_interface (&tower_driver, subminor); |
355 | 356 | ||
@@ -427,7 +428,7 @@ unlock_exit: | |||
427 | up (&dev->sem); | 428 | up (&dev->sem); |
428 | 429 | ||
429 | unlock_disconnect_exit: | 430 | unlock_disconnect_exit: |
430 | up (&disconnect_sem); | 431 | mutex_unlock (&disconnect_mutex); |
431 | 432 | ||
432 | dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); | 433 | dbg(2, "%s: leave, return value %d ", __FUNCTION__, retval); |
433 | 434 | ||
@@ -1005,7 +1006,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1005 | 1006 | ||
1006 | dbg(2, "%s: enter", __FUNCTION__); | 1007 | dbg(2, "%s: enter", __FUNCTION__); |
1007 | 1008 | ||
1008 | down (&disconnect_sem); | 1009 | mutex_lock (&disconnect_mutex); |
1009 | 1010 | ||
1010 | dev = usb_get_intfdata (interface); | 1011 | dev = usb_get_intfdata (interface); |
1011 | usb_set_intfdata (interface, NULL); | 1012 | usb_set_intfdata (interface, NULL); |
@@ -1027,7 +1028,7 @@ static void tower_disconnect (struct usb_interface *interface) | |||
1027 | up (&dev->sem); | 1028 | up (&dev->sem); |
1028 | } | 1029 | } |
1029 | 1030 | ||
1030 | up (&disconnect_sem); | 1031 | mutex_unlock (&disconnect_mutex); |
1031 | 1032 | ||
1032 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); | 1033 | info("LEGO USB Tower #%d now disconnected", (minor - LEGO_USB_TOWER_MINOR_BASE)); |
1033 | 1034 | ||