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/class | |
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/class')
-rw-r--r-- | drivers/usb/class/cdc-acm.c | 23 | ||||
-rw-r--r-- | drivers/usb/class/usblp.c | 15 |
2 files changed, 20 insertions, 18 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index 97bdeb1c2181..6dd339f4c0fc 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c | |||
@@ -60,6 +60,7 @@ | |||
60 | #include <linux/tty_flip.h> | 60 | #include <linux/tty_flip.h> |
61 | #include <linux/module.h> | 61 | #include <linux/module.h> |
62 | #include <linux/smp_lock.h> | 62 | #include <linux/smp_lock.h> |
63 | #include <linux/mutex.h> | ||
63 | #include <asm/uaccess.h> | 64 | #include <asm/uaccess.h> |
64 | #include <linux/usb.h> | 65 | #include <linux/usb.h> |
65 | #include <linux/usb_cdc.h> | 66 | #include <linux/usb_cdc.h> |
@@ -80,7 +81,7 @@ static struct usb_driver acm_driver; | |||
80 | static struct tty_driver *acm_tty_driver; | 81 | static struct tty_driver *acm_tty_driver; |
81 | static struct acm *acm_table[ACM_TTY_MINORS]; | 82 | static struct acm *acm_table[ACM_TTY_MINORS]; |
82 | 83 | ||
83 | static DECLARE_MUTEX(open_sem); | 84 | static DEFINE_MUTEX(open_mutex); |
84 | 85 | ||
85 | #define ACM_READY(acm) (acm && acm->dev && acm->used) | 86 | #define ACM_READY(acm) (acm && acm->dev && acm->used) |
86 | 87 | ||
@@ -431,8 +432,8 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
431 | int rv = -EINVAL; | 432 | int rv = -EINVAL; |
432 | int i; | 433 | int i; |
433 | dbg("Entering acm_tty_open.\n"); | 434 | dbg("Entering acm_tty_open.\n"); |
434 | 435 | ||
435 | down(&open_sem); | 436 | mutex_lock(&open_mutex); |
436 | 437 | ||
437 | acm = acm_table[tty->index]; | 438 | acm = acm_table[tty->index]; |
438 | if (!acm || !acm->dev) | 439 | if (!acm || !acm->dev) |
@@ -474,14 +475,14 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp) | |||
474 | 475 | ||
475 | done: | 476 | done: |
476 | err_out: | 477 | err_out: |
477 | up(&open_sem); | 478 | mutex_unlock(&open_mutex); |
478 | return rv; | 479 | return rv; |
479 | 480 | ||
480 | full_bailout: | 481 | full_bailout: |
481 | usb_kill_urb(acm->ctrlurb); | 482 | usb_kill_urb(acm->ctrlurb); |
482 | bail_out: | 483 | bail_out: |
483 | acm->used--; | 484 | acm->used--; |
484 | up(&open_sem); | 485 | mutex_unlock(&open_mutex); |
485 | return -EIO; | 486 | return -EIO; |
486 | } | 487 | } |
487 | 488 | ||
@@ -507,7 +508,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) | |||
507 | if (!acm || !acm->used) | 508 | if (!acm || !acm->used) |
508 | return; | 509 | return; |
509 | 510 | ||
510 | down(&open_sem); | 511 | mutex_lock(&open_mutex); |
511 | if (!--acm->used) { | 512 | if (!--acm->used) { |
512 | if (acm->dev) { | 513 | if (acm->dev) { |
513 | acm_set_control(acm, acm->ctrlout = 0); | 514 | acm_set_control(acm, acm->ctrlout = 0); |
@@ -518,7 +519,7 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp) | |||
518 | } else | 519 | } else |
519 | acm_tty_unregister(acm); | 520 | acm_tty_unregister(acm); |
520 | } | 521 | } |
521 | up(&open_sem); | 522 | mutex_unlock(&open_mutex); |
522 | } | 523 | } |
523 | 524 | ||
524 | static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) | 525 | static int acm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) |
@@ -1013,9 +1014,9 @@ static void acm_disconnect(struct usb_interface *intf) | |||
1013 | return; | 1014 | return; |
1014 | } | 1015 | } |
1015 | 1016 | ||
1016 | down(&open_sem); | 1017 | mutex_lock(&open_mutex); |
1017 | if (!usb_get_intfdata(intf)) { | 1018 | if (!usb_get_intfdata(intf)) { |
1018 | up(&open_sem); | 1019 | mutex_unlock(&open_mutex); |
1019 | return; | 1020 | return; |
1020 | } | 1021 | } |
1021 | acm->dev = NULL; | 1022 | acm->dev = NULL; |
@@ -1045,11 +1046,11 @@ static void acm_disconnect(struct usb_interface *intf) | |||
1045 | 1046 | ||
1046 | if (!acm->used) { | 1047 | if (!acm->used) { |
1047 | acm_tty_unregister(acm); | 1048 | acm_tty_unregister(acm); |
1048 | up(&open_sem); | 1049 | mutex_unlock(&open_mutex); |
1049 | return; | 1050 | return; |
1050 | } | 1051 | } |
1051 | 1052 | ||
1052 | up(&open_sem); | 1053 | mutex_unlock(&open_mutex); |
1053 | 1054 | ||
1054 | if (acm->tty) | 1055 | if (acm->tty) |
1055 | tty_hangup(acm->tty); | 1056 | tty_hangup(acm->tty); |
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index d34848ac30b0..48dee4b8d8e5 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c | |||
@@ -55,6 +55,7 @@ | |||
55 | #include <linux/init.h> | 55 | #include <linux/init.h> |
56 | #include <linux/slab.h> | 56 | #include <linux/slab.h> |
57 | #include <linux/lp.h> | 57 | #include <linux/lp.h> |
58 | #include <linux/mutex.h> | ||
58 | #undef DEBUG | 59 | #undef DEBUG |
59 | #include <linux/usb.h> | 60 | #include <linux/usb.h> |
60 | 61 | ||
@@ -223,7 +224,7 @@ static int usblp_cache_device_id_string(struct usblp *usblp); | |||
223 | 224 | ||
224 | /* forward reference to make our lives easier */ | 225 | /* forward reference to make our lives easier */ |
225 | static struct usb_driver usblp_driver; | 226 | static struct usb_driver usblp_driver; |
226 | static DECLARE_MUTEX(usblp_sem); /* locks the existence of usblp's */ | 227 | static DEFINE_MUTEX(usblp_mutex); /* locks the existence of usblp's */ |
227 | 228 | ||
228 | /* | 229 | /* |
229 | * Functions for usblp control messages. | 230 | * Functions for usblp control messages. |
@@ -351,7 +352,7 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
351 | if (minor < 0) | 352 | if (minor < 0) |
352 | return -ENODEV; | 353 | return -ENODEV; |
353 | 354 | ||
354 | down (&usblp_sem); | 355 | mutex_lock (&usblp_mutex); |
355 | 356 | ||
356 | retval = -ENODEV; | 357 | retval = -ENODEV; |
357 | intf = usb_find_interface(&usblp_driver, minor); | 358 | intf = usb_find_interface(&usblp_driver, minor); |
@@ -399,7 +400,7 @@ static int usblp_open(struct inode *inode, struct file *file) | |||
399 | } | 400 | } |
400 | } | 401 | } |
401 | out: | 402 | out: |
402 | up (&usblp_sem); | 403 | mutex_unlock (&usblp_mutex); |
403 | return retval; | 404 | return retval; |
404 | } | 405 | } |
405 | 406 | ||
@@ -425,13 +426,13 @@ static int usblp_release(struct inode *inode, struct file *file) | |||
425 | { | 426 | { |
426 | struct usblp *usblp = file->private_data; | 427 | struct usblp *usblp = file->private_data; |
427 | 428 | ||
428 | down (&usblp_sem); | 429 | mutex_lock (&usblp_mutex); |
429 | usblp->used = 0; | 430 | usblp->used = 0; |
430 | if (usblp->present) { | 431 | if (usblp->present) { |
431 | usblp_unlink_urbs(usblp); | 432 | usblp_unlink_urbs(usblp); |
432 | } else /* finish cleanup from disconnect */ | 433 | } else /* finish cleanup from disconnect */ |
433 | usblp_cleanup (usblp); | 434 | usblp_cleanup (usblp); |
434 | up (&usblp_sem); | 435 | mutex_unlock (&usblp_mutex); |
435 | return 0; | 436 | return 0; |
436 | } | 437 | } |
437 | 438 | ||
@@ -1152,7 +1153,7 @@ static void usblp_disconnect(struct usb_interface *intf) | |||
1152 | 1153 | ||
1153 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); | 1154 | device_remove_file(&intf->dev, &dev_attr_ieee1284_id); |
1154 | 1155 | ||
1155 | down (&usblp_sem); | 1156 | mutex_lock (&usblp_mutex); |
1156 | down (&usblp->sem); | 1157 | down (&usblp->sem); |
1157 | usblp->present = 0; | 1158 | usblp->present = 0; |
1158 | usb_set_intfdata (intf, NULL); | 1159 | usb_set_intfdata (intf, NULL); |
@@ -1166,7 +1167,7 @@ static void usblp_disconnect(struct usb_interface *intf) | |||
1166 | 1167 | ||
1167 | if (!usblp->used) | 1168 | if (!usblp->used) |
1168 | usblp_cleanup (usblp); | 1169 | usblp_cleanup (usblp); |
1169 | up (&usblp_sem); | 1170 | mutex_unlock (&usblp_mutex); |
1170 | } | 1171 | } |
1171 | 1172 | ||
1172 | static struct usb_device_id usblp_ids [] = { | 1173 | static struct usb_device_id usblp_ids [] = { |