[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>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
35cce732d9
commit
4186ecf8ad
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user