Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: use mutex instead of semaphore in the ELAN U132 adapter driver

The ELAN U132 adapter driver uses the semaphore u132_module_lock
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>

authored by

Matthias Kaehlcke and committed by
Greg Kroah-Hartman
d2066eb6 831c70fc

+9 -8
+9 -8
drivers/usb/host/u132-hcd.c
··· 52 52 #include <linux/workqueue.h> 53 53 #include <linux/platform_device.h> 54 54 #include <linux/pci_ids.h> 55 + #include <linux/mutex.h> 55 56 #include <asm/io.h> 56 57 #include <asm/irq.h> 57 58 #include <asm/system.h> ··· 84 83 * u132_module_lock exists to protect access to global variables 85 84 * 86 85 */ 87 - static struct semaphore u132_module_lock; 86 + static struct mutex u132_module_lock; 88 87 static int u132_exiting = 0; 89 88 static int u132_instances = 0; 90 89 static struct list_head u132_static_list; ··· 259 258 struct platform_device *pdev = u132->platform_dev; 260 259 struct usb_hcd *hcd = u132_to_hcd(u132); 261 260 u132->going += 1; 262 - down(&u132_module_lock); 261 + mutex_lock(&u132_module_lock); 263 262 list_del_init(&u132->u132_list); 264 263 u132_instances -= 1; 265 - up(&u132_module_lock); 264 + mutex_unlock(&u132_module_lock); 266 265 dev_warn(&u132->platform_dev->dev, "FREEING the hcd=%p and thus the u13" 267 266 "2=%p going=%d pdev=%p\n", hcd, u132, u132->going, pdev); 268 267 usb_put_hcd(hcd); ··· 3112 3111 int retval = 0; 3113 3112 struct u132 *u132 = hcd_to_u132(hcd); 3114 3113 hcd->rsrc_start = 0; 3115 - down(&u132_module_lock); 3114 + mutex_lock(&u132_module_lock); 3116 3115 list_add_tail(&u132->u132_list, &u132_static_list); 3117 3116 u132->sequence_num = ++u132_instances; 3118 - up(&u132_module_lock); 3117 + mutex_unlock(&u132_module_lock); 3119 3118 u132_u132_init_kref(u132); 3120 3119 u132_initialise(u132, pdev); 3121 3120 hcd->product_desc = "ELAN U132 Host Controller"; ··· 3217 3216 INIT_LIST_HEAD(&u132_static_list); 3218 3217 u132_instances = 0; 3219 3218 u132_exiting = 0; 3220 - init_MUTEX(&u132_module_lock); 3219 + mutex_init(&u132_module_lock); 3221 3220 if (usb_disabled()) 3222 3221 return -ENODEV; 3223 3222 printk(KERN_INFO "driver %s built at %s on %s\n", hcd_name, __TIME__, ··· 3233 3232 { 3234 3233 struct u132 *u132; 3235 3234 struct u132 *temp; 3236 - down(&u132_module_lock); 3235 + mutex_lock(&u132_module_lock); 3237 3236 u132_exiting += 1; 3238 - up(&u132_module_lock); 3237 + mutex_unlock(&u132_module_lock); 3239 3238 list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) { 3240 3239 platform_device_unregister(u132->platform_dev); 3241 3240 } platform_driver_unregister(&u132_platform_driver);