diff options
author | Matthias Kaehlcke <matthias.kaehlcke@gmail.com> | 2007-07-13 15:29:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-19 20:46:03 -0400 |
commit | eb33caec1ed29fa2b04a2c5f02e3fed2add91db4 (patch) | |
tree | a8ae0f233be330eaf0a5df4eba83381424144224 /drivers | |
parent | 8293c568b25611cdc4ac54ded438d8d7938c593c (diff) |
USB: use mutex instead of semaphore in the FTDI ELAN driver
The FTDI ELAN driver uses a semaphore as mutex. Use the mutex API
instead of the (binary) semaphore.
Signed-off-by: Matthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/misc/ftdi-elan.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/usb/misc/ftdi-elan.c b/drivers/usb/misc/ftdi-elan.c index e0f122e131d7..7cc6883a6fa3 100644 --- a/drivers/usb/misc/ftdi-elan.c +++ b/drivers/usb/misc/ftdi-elan.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include <linux/slab.h> | 44 | #include <linux/slab.h> |
45 | #include <linux/module.h> | 45 | #include <linux/module.h> |
46 | #include <linux/kref.h> | 46 | #include <linux/kref.h> |
47 | #include <linux/mutex.h> | ||
47 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
48 | #include <linux/usb.h> | 49 | #include <linux/usb.h> |
49 | #include <linux/workqueue.h> | 50 | #include <linux/workqueue.h> |
@@ -64,7 +65,7 @@ static struct workqueue_struct *respond_queue; | |||
64 | * ftdi_module_lock exists to protect access to global variables | 65 | * ftdi_module_lock exists to protect access to global variables |
65 | * | 66 | * |
66 | */ | 67 | */ |
67 | static struct semaphore ftdi_module_lock; | 68 | static struct mutex ftdi_module_lock; |
68 | static int ftdi_instances = 0; | 69 | static int ftdi_instances = 0; |
69 | static struct list_head ftdi_static_list; | 70 | static struct list_head ftdi_static_list; |
70 | /* | 71 | /* |
@@ -199,10 +200,10 @@ static void ftdi_elan_delete(struct kref *kref) | |||
199 | dev_warn(&ftdi->udev->dev, "FREEING ftdi=%p\n", ftdi); | 200 | dev_warn(&ftdi->udev->dev, "FREEING ftdi=%p\n", ftdi); |
200 | usb_put_dev(ftdi->udev); | 201 | usb_put_dev(ftdi->udev); |
201 | ftdi->disconnected += 1; | 202 | ftdi->disconnected += 1; |
202 | down(&ftdi_module_lock); | 203 | mutex_lock(&ftdi_module_lock); |
203 | list_del_init(&ftdi->ftdi_list); | 204 | list_del_init(&ftdi->ftdi_list); |
204 | ftdi_instances -= 1; | 205 | ftdi_instances -= 1; |
205 | up(&ftdi_module_lock); | 206 | mutex_unlock(&ftdi_module_lock); |
206 | kfree(ftdi->bulk_in_buffer); | 207 | kfree(ftdi->bulk_in_buffer); |
207 | ftdi->bulk_in_buffer = NULL; | 208 | ftdi->bulk_in_buffer = NULL; |
208 | } | 209 | } |
@@ -2780,10 +2781,10 @@ static int ftdi_elan_probe(struct usb_interface *interface, | |||
2780 | return -ENOMEM; | 2781 | return -ENOMEM; |
2781 | } | 2782 | } |
2782 | memset(ftdi, 0x00, sizeof(struct usb_ftdi)); | 2783 | memset(ftdi, 0x00, sizeof(struct usb_ftdi)); |
2783 | down(&ftdi_module_lock); | 2784 | mutex_lock(&ftdi_module_lock); |
2784 | list_add_tail(&ftdi->ftdi_list, &ftdi_static_list); | 2785 | list_add_tail(&ftdi->ftdi_list, &ftdi_static_list); |
2785 | ftdi->sequence_num = ++ftdi_instances; | 2786 | ftdi->sequence_num = ++ftdi_instances; |
2786 | up(&ftdi_module_lock); | 2787 | mutex_unlock(&ftdi_module_lock); |
2787 | ftdi_elan_init_kref(ftdi); | 2788 | ftdi_elan_init_kref(ftdi); |
2788 | init_MUTEX(&ftdi->sw_lock); | 2789 | init_MUTEX(&ftdi->sw_lock); |
2789 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); | 2790 | ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); |
@@ -2909,7 +2910,7 @@ static int __init ftdi_elan_init(void) | |||
2909 | int result; | 2910 | int result; |
2910 | printk(KERN_INFO "driver %s built at %s on %s\n", ftdi_elan_driver.name, | 2911 | printk(KERN_INFO "driver %s built at %s on %s\n", ftdi_elan_driver.name, |
2911 | __TIME__, __DATE__); | 2912 | __TIME__, __DATE__); |
2912 | init_MUTEX(&ftdi_module_lock); | 2913 | mutex_init(&ftdi_module_lock); |
2913 | INIT_LIST_HEAD(&ftdi_static_list); | 2914 | INIT_LIST_HEAD(&ftdi_static_list); |
2914 | status_queue = create_singlethread_workqueue("ftdi-status-control"); | 2915 | status_queue = create_singlethread_workqueue("ftdi-status-control"); |
2915 | if (!status_queue) | 2916 | if (!status_queue) |