aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@infradead.org>2006-01-11 09:55:29 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:55 -0500
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 c34944c75047..b03e346e33f1 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -12,6 +12,7 @@
12#include <linux/debugfs.h> 12#include <linux/debugfs.h>
13#include <linux/smp_lock.h> 13#include <linux/smp_lock.h>
14#include <linux/notifier.h> 14#include <linux/notifier.h>
15#include <linux/mutex.h>
15 16
16#include "usb_mon.h" 17#include "usb_mon.h"
17#include "../core/hcd.h" 18#include "../core/hcd.h"
@@ -23,7 +24,7 @@ static void mon_dissolve(struct mon_bus *mbus, struct usb_bus *ubus);
23static void mon_bus_drop(struct kref *r); 24static void mon_bus_drop(struct kref *r);
24static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus); 25static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus);
25 26
26DECLARE_MUTEX(mon_lock); 27DEFINE_MUTEX(mon_lock);
27 28
28static struct dentry *mon_dir; /* /dbg/usbmon */ 29static struct dentry *mon_dir; /* /dbg/usbmon */
29static LIST_HEAD(mon_buses); /* All buses we know: struct mon_bus */ 30static LIST_HEAD(mon_buses); /* All buses we know: struct mon_bus */
@@ -196,14 +197,14 @@ static void mon_bus_remove(struct usb_bus *ubus)
196{ 197{
197 struct mon_bus *mbus = ubus->mon_bus; 198 struct mon_bus *mbus = ubus->mon_bus;
198 199
199 down(&mon_lock); 200 mutex_lock(&mon_lock);
200 list_del(&mbus->bus_link); 201 list_del(&mbus->bus_link);
201 debugfs_remove(mbus->dent_t); 202 debugfs_remove(mbus->dent_t);
202 debugfs_remove(mbus->dent_s); 203 debugfs_remove(mbus->dent_s);
203 204
204 mon_dissolve(mbus, ubus); 205 mon_dissolve(mbus, ubus);
205 kref_put(&mbus->ref, mon_bus_drop); 206 kref_put(&mbus->ref, mon_bus_drop);
206 up(&mon_lock); 207 mutex_unlock(&mon_lock);
207} 208}
208 209
209static int mon_notify(struct notifier_block *self, unsigned long action, 210static 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)
307 goto err_create_s; 308 goto err_create_s;
308 mbus->dent_s = d; 309 mbus->dent_s = d;
309 310
310 down(&mon_lock); 311 mutex_lock(&mon_lock);
311 list_add_tail(&mbus->bus_link, &mon_buses); 312 list_add_tail(&mbus->bus_link, &mon_buses);
312 up(&mon_lock); 313 mutex_unlock(&mon_lock);
313 return; 314 return;
314 315
315err_create_s: 316err_create_s:
@@ -347,11 +348,11 @@ static int __init mon_init(void)
347 348
348 usb_register_notify(&mon_nb); 349 usb_register_notify(&mon_nb);
349 350
350 down(&usb_bus_list_lock); 351 mutex_lock(&usb_bus_list_lock);
351 list_for_each_entry (ubus, &usb_bus_list, bus_list) { 352 list_for_each_entry (ubus, &usb_bus_list, bus_list) {
352 mon_bus_init(mondir, ubus); 353 mon_bus_init(mondir, ubus);
353 } 354 }
354 up(&usb_bus_list_lock); 355 mutex_unlock(&usb_bus_list_lock);
355 return 0; 356 return 0;
356} 357}
357 358
@@ -363,7 +364,7 @@ static void __exit mon_exit(void)
363 usb_unregister_notify(&mon_nb); 364 usb_unregister_notify(&mon_nb);
364 usb_mon_deregister(); 365 usb_mon_deregister();
365 366
366 down(&mon_lock); 367 mutex_lock(&mon_lock);
367 while (!list_empty(&mon_buses)) { 368 while (!list_empty(&mon_buses)) {
368 p = mon_buses.next; 369 p = mon_buses.next;
369 mbus = list_entry(p, struct mon_bus, bus_link); 370 mbus = list_entry(p, struct mon_bus, bus_link);
@@ -387,7 +388,7 @@ static void __exit mon_exit(void)
387 mon_dissolve(mbus, mbus->u_bus); 388 mon_dissolve(mbus, mbus->u_bus);
388 kref_put(&mbus->ref, mon_bus_drop); 389 kref_put(&mbus->ref, mon_bus_drop);
389 } 390 }
390 up(&mon_lock); 391 mutex_unlock(&mon_lock);
391 392
392 debugfs_remove(mon_dir); 393 debugfs_remove(mon_dir);
393} 394}
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 611612146ae9..59089e8b7e5e 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -8,6 +8,7 @@
8#include <linux/list.h> 8#include <linux/list.h>
9#include <linux/usb.h> 9#include <linux/usb.h>
10#include <linux/time.h> 10#include <linux/time.h>
11#include <linux/mutex.h>
11#include <asm/uaccess.h> 12#include <asm/uaccess.h>
12 13
13#include "usb_mon.h" 14#include "usb_mon.h"
@@ -54,7 +55,7 @@ struct mon_reader_text {
54 wait_queue_head_t wait; 55 wait_queue_head_t wait;
55 int printf_size; 56 int printf_size;
56 char *printf_buf; 57 char *printf_buf;
57 struct semaphore printf_lock; 58 struct mutex printf_lock;
58 59
59 char slab_name[SLAB_NAME_SZ]; 60 char slab_name[SLAB_NAME_SZ];
60}; 61};
@@ -208,7 +209,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
208 struct mon_reader_text *rp; 209 struct mon_reader_text *rp;
209 int rc; 210 int rc;
210 211
211 down(&mon_lock); 212 mutex_lock(&mon_lock);
212 mbus = inode->u.generic_ip; 213 mbus = inode->u.generic_ip;
213 ubus = mbus->u_bus; 214 ubus = mbus->u_bus;
214 215
@@ -220,7 +221,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
220 memset(rp, 0, sizeof(struct mon_reader_text)); 221 memset(rp, 0, sizeof(struct mon_reader_text));
221 INIT_LIST_HEAD(&rp->e_list); 222 INIT_LIST_HEAD(&rp->e_list);
222 init_waitqueue_head(&rp->wait); 223 init_waitqueue_head(&rp->wait);
223 init_MUTEX(&rp->printf_lock); 224 mutex_init(&rp->printf_lock);
224 225
225 rp->printf_size = PRINTF_DFL; 226 rp->printf_size = PRINTF_DFL;
226 rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL); 227 rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL);
@@ -247,7 +248,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
247 mon_reader_add(mbus, &rp->r); 248 mon_reader_add(mbus, &rp->r);
248 249
249 file->private_data = rp; 250 file->private_data = rp;
250 up(&mon_lock); 251 mutex_unlock(&mon_lock);
251 return 0; 252 return 0;
252 253
253// err_busy: 254// err_busy:
@@ -257,7 +258,7 @@ err_slab:
257err_alloc_pr: 258err_alloc_pr:
258 kfree(rp); 259 kfree(rp);
259err_alloc: 260err_alloc:
260 up(&mon_lock); 261 mutex_unlock(&mon_lock);
261 return rc; 262 return rc;
262} 263}
263 264
@@ -301,7 +302,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
301 set_current_state(TASK_RUNNING); 302 set_current_state(TASK_RUNNING);
302 remove_wait_queue(&rp->wait, &waita); 303 remove_wait_queue(&rp->wait, &waita);
303 304
304 down(&rp->printf_lock); 305 mutex_lock(&rp->printf_lock);
305 cnt = 0; 306 cnt = 0;
306 pbuf = rp->printf_buf; 307 pbuf = rp->printf_buf;
307 limit = rp->printf_size; 308 limit = rp->printf_size;
@@ -358,7 +359,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
358 359
359 if (copy_to_user(buf, rp->printf_buf, cnt)) 360 if (copy_to_user(buf, rp->printf_buf, cnt))
360 cnt = -EFAULT; 361 cnt = -EFAULT;
361 up(&rp->printf_lock); 362 mutex_unlock(&rp->printf_lock);
362 kmem_cache_free(rp->e_slab, ep); 363 kmem_cache_free(rp->e_slab, ep);
363 return cnt; 364 return cnt;
364} 365}
@@ -371,12 +372,12 @@ static int mon_text_release(struct inode *inode, struct file *file)
371 struct list_head *p; 372 struct list_head *p;
372 struct mon_event_text *ep; 373 struct mon_event_text *ep;
373 374
374 down(&mon_lock); 375 mutex_lock(&mon_lock);
375 mbus = inode->u.generic_ip; 376 mbus = inode->u.generic_ip;
376 377
377 if (mbus->nreaders <= 0) { 378 if (mbus->nreaders <= 0) {
378 printk(KERN_ERR TAG ": consistency error on close\n"); 379 printk(KERN_ERR TAG ": consistency error on close\n");
379 up(&mon_lock); 380 mutex_unlock(&mon_lock);
380 return 0; 381 return 0;
381 } 382 }
382 mon_reader_del(mbus, &rp->r); 383 mon_reader_del(mbus, &rp->r);
@@ -402,7 +403,7 @@ static int mon_text_release(struct inode *inode, struct file *file)
402 kfree(rp->printf_buf); 403 kfree(rp->printf_buf);
403 kfree(rp); 404 kfree(rp);
404 405
405 up(&mon_lock); 406 mutex_unlock(&mon_lock);
406 return 0; 407 return 0;
407} 408}
408 409
diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h
index 4be0f9346071..8e0613c350cc 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);
49 */ 49 */
50extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len); 50extern char mon_dmapeek(unsigned char *dst, dma_addr_t dma_addr, int len);
51 51
52extern struct semaphore mon_lock; 52extern struct mutex mon_lock;
53 53
54extern struct file_operations mon_fops_text; 54extern struct file_operations mon_fops_text;
55extern struct file_operations mon_fops_stat; 55extern struct file_operations mon_fops_stat;