aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/mon
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 15:55:29 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 14:49:55 -0800
commit4186ecf8ad16dd05759a09594de6a87e48759ba6 (patch)
tree3ee5292d9f4a36e3eb359b586289ec972bcbaf39 /drivers/usb/mon
parent35cce732d9d4d9af6b4ad4d26d8f8c0eddb573a2 (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/mon')
-rw-r--r--drivers/usb/mon/mon_main.c19
-rw-r--r--drivers/usb/mon/mon_text.c21
-rw-r--r--drivers/usb/mon/usb_mon.h2
3 files changed, 22 insertions, 20 deletions
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index c34944c7504..b03e346e33f 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -12,6 +12,7 @@
#include <linux/debugfs.h>
#include <linux/smp_lock.h>
#include <linux/notifier.h>
+#include <linux/mutex.h>
#include "usb_mon.h"
#include "../core/hcd.h"
@@ -23,7 +24,7 @@ static void mon_dissolve(struct mon_bus *mbus, struct usb_bus *ubus);
static void mon_bus_drop(struct kref *r);
static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus);
-DECLARE_MUTEX(mon_lock);
+DEFINE_MUTEX(mon_lock);
static struct dentry *mon_dir; /* /dbg/usbmon */
static LIST_HEAD(mon_buses); /* All buses we know: struct mon_bus */
@@ -196,14 +197,14 @@ static void mon_bus_remove(struct usb_bus *ubus)
{
struct mon_bus *mbus = ubus->mon_bus;
- down(&mon_lock);
+ mutex_lock(&mon_lock);
list_del(&mbus->bus_link);
debugfs_remove(mbus->dent_t);
debugfs_remove(mbus->dent_s);
mon_dissolve(mbus, ubus);
kref_put(&mbus->ref, mon_bus_drop);
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
}
static int mon_notify(struct notifier_block *self, unsigned long action,
@@ -307,9 +308,9 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus)
goto err_create_s;
mbus->dent_s = d;
- down(&mon_lock);
+ mutex_lock(&mon_lock);
list_add_tail(&mbus->bus_link, &mon_buses);
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
return;
err_create_s:
@@ -347,11 +348,11 @@ static int __init mon_init(void)
usb_register_notify(&mon_nb);
- down(&usb_bus_list_lock);
+ mutex_lock(&usb_bus_list_lock);
list_for_each_entry (ubus, &usb_bus_list, bus_list) {
mon_bus_init(mondir, ubus);
}
- up(&usb_bus_list_lock);
+ mutex_unlock(&usb_bus_list_lock);
return 0;
}
@@ -363,7 +364,7 @@ static void __exit mon_exit(void)
usb_unregister_notify(&mon_nb);
usb_mon_deregister();
- down(&mon_lock);
+ mutex_lock(&mon_lock);
while (!list_empty(&mon_buses)) {
p = mon_buses.next;
mbus = list_entry(p, struct mon_bus, bus_link);
@@ -387,7 +388,7 @@ static void __exit mon_exit(void)
mon_dissolve(mbus, mbus->u_bus);
kref_put(&mbus->ref, mon_bus_drop);
}
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
debugfs_remove(mon_dir);
}
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 611612146ae..59089e8b7e5 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -8,6 +8,7 @@
#include <linux/list.h>
#include <linux/usb.h>
#include <linux/time.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
#include "usb_mon.h"
@@ -54,7 +55,7 @@ struct mon_reader_text {
wait_queue_head_t wait;
int printf_size;
char *printf_buf;
- struct semaphore printf_lock;
+ struct mutex printf_lock;
char slab_name[SLAB_NAME_SZ];
};
@@ -208,7 +209,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
struct mon_reader_text *rp;
int rc;
- down(&mon_lock);
+ mutex_lock(&mon_lock);
mbus = inode->u.generic_ip;
ubus = mbus->u_bus;
@@ -220,7 +221,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
memset(rp, 0, sizeof(struct mon_reader_text));
INIT_LIST_HEAD(&rp->e_list);
init_waitqueue_head(&rp->wait);
- init_MUTEX(&rp->printf_lock);
+ mutex_init(&rp->printf_lock);
rp->printf_size = PRINTF_DFL;
rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL);
@@ -247,7 +248,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
mon_reader_add(mbus, &rp->r);
file->private_data = rp;
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
return 0;
// err_busy:
@@ -257,7 +258,7 @@ err_slab:
err_alloc_pr:
kfree(rp);
err_alloc:
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
return rc;
}
@@ -301,7 +302,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
set_current_state(TASK_RUNNING);
remove_wait_queue(&rp->wait, &waita);
- down(&rp->printf_lock);
+ mutex_lock(&rp->printf_lock);
cnt = 0;
pbuf = rp->printf_buf;
limit = rp->printf_size;
@@ -358,7 +359,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
if (copy_to_user(buf, rp->printf_buf, cnt))
cnt = -EFAULT;
- up(&rp->printf_lock);
+ mutex_unlock(&rp->printf_lock);
kmem_cache_free(rp->e_slab, ep);
return cnt;
}
@@ -371,12 +372,12 @@ static int mon_text_release(struct inode *inode, struct file *file)
struct list_head *p;
struct mon_event_text *ep;
- down(&mon_lock);
+ mutex_lock(&mon_lock);
mbus = inode->u.generic_ip;
if (mbus->nreaders <= 0) {
printk(KERN_ERR TAG ": consistency error on close\n");
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
return 0;
}
mon_reader_del(mbus, &rp->r);
@@ -402,7 +403,7 @@ static int mon_text_release(struct inode *inode, struct file *file)
kfree(rp->printf_buf);
kfree(rp);
- up(&mon_lock);
+ mutex_unlock(&mon_lock);
return 0;
}
diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h
index 4be0f934607..8e0613c350c 100644
--- a/drivers/usb/mon/usb_mon.h
+++ b/drivers/usb/mon/usb_mon.h
@@ -49,7 +49,7 @@ void mon_reader_del(struct mon_bus *mbus, struct mon_reader *r);
*/
extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
-extern struct semaphore mon_lock;
+extern struct mutex mon_lock;
extern struct file_operations mon_fops_text;
extern struct file_operations mon_fops_stat;