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>
This commit is contained in:
Matthias Kaehlcke 2007-07-13 21:29:46 +02:00 committed by Greg Kroah-Hartman
parent 8293c568b2
commit eb33caec1e

View File

@ -44,6 +44,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/mutex.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
@ -64,7 +65,7 @@ static struct workqueue_struct *respond_queue;
* ftdi_module_lock exists to protect access to global variables * ftdi_module_lock exists to protect access to global variables
* *
*/ */
static struct semaphore ftdi_module_lock; static struct mutex ftdi_module_lock;
static int ftdi_instances = 0; static int ftdi_instances = 0;
static struct list_head ftdi_static_list; static struct list_head ftdi_static_list;
/* /*
@ -199,10 +200,10 @@ static void ftdi_elan_delete(struct kref *kref)
dev_warn(&ftdi->udev->dev, "FREEING ftdi=%p\n", ftdi); dev_warn(&ftdi->udev->dev, "FREEING ftdi=%p\n", ftdi);
usb_put_dev(ftdi->udev); usb_put_dev(ftdi->udev);
ftdi->disconnected += 1; ftdi->disconnected += 1;
down(&ftdi_module_lock); mutex_lock(&ftdi_module_lock);
list_del_init(&ftdi->ftdi_list); list_del_init(&ftdi->ftdi_list);
ftdi_instances -= 1; ftdi_instances -= 1;
up(&ftdi_module_lock); mutex_unlock(&ftdi_module_lock);
kfree(ftdi->bulk_in_buffer); kfree(ftdi->bulk_in_buffer);
ftdi->bulk_in_buffer = NULL; ftdi->bulk_in_buffer = NULL;
} }
@ -2780,10 +2781,10 @@ static int ftdi_elan_probe(struct usb_interface *interface,
return -ENOMEM; return -ENOMEM;
} }
memset(ftdi, 0x00, sizeof(struct usb_ftdi)); memset(ftdi, 0x00, sizeof(struct usb_ftdi));
down(&ftdi_module_lock); mutex_lock(&ftdi_module_lock);
list_add_tail(&ftdi->ftdi_list, &ftdi_static_list); list_add_tail(&ftdi->ftdi_list, &ftdi_static_list);
ftdi->sequence_num = ++ftdi_instances; ftdi->sequence_num = ++ftdi_instances;
up(&ftdi_module_lock); mutex_unlock(&ftdi_module_lock);
ftdi_elan_init_kref(ftdi); ftdi_elan_init_kref(ftdi);
init_MUTEX(&ftdi->sw_lock); init_MUTEX(&ftdi->sw_lock);
ftdi->udev = usb_get_dev(interface_to_usbdev(interface)); ftdi->udev = usb_get_dev(interface_to_usbdev(interface));
@ -2909,7 +2910,7 @@ static int __init ftdi_elan_init(void)
int result; int result;
printk(KERN_INFO "driver %s built at %s on %s\n", ftdi_elan_driver.name, printk(KERN_INFO "driver %s built at %s on %s\n", ftdi_elan_driver.name,
__TIME__, __DATE__); __TIME__, __DATE__);
init_MUTEX(&ftdi_module_lock); mutex_init(&ftdi_module_lock);
INIT_LIST_HEAD(&ftdi_static_list); INIT_LIST_HEAD(&ftdi_static_list);
status_queue = create_singlethread_workqueue("ftdi-status-control"); status_queue = create_singlethread_workqueue("ftdi-status-control");
if (!status_queue) if (!status_queue)