diff options
Diffstat (limited to 'drivers/usb/mon/mon_main.c')
-rw-r--r-- | drivers/usb/mon/mon_main.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index c34944c75047..6ecc27302211 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); | |||
23 | static void mon_bus_drop(struct kref *r); | 24 | static void mon_bus_drop(struct kref *r); |
24 | static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus); | 25 | static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus); |
25 | 26 | ||
26 | DECLARE_MUTEX(mon_lock); | 27 | DEFINE_MUTEX(mon_lock); |
27 | 28 | ||
28 | static struct dentry *mon_dir; /* /dbg/usbmon */ | 29 | static struct dentry *mon_dir; /* /dbg/usbmon */ |
29 | static LIST_HEAD(mon_buses); /* All buses we know: struct mon_bus */ | 30 | 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) | |||
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 | ||
209 | static int mon_notify(struct notifier_block *self, unsigned long action, | 210 | static int mon_notify(struct notifier_block *self, unsigned long action, |
@@ -276,9 +277,8 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus) | |||
276 | char name[NAMESZ]; | 277 | char name[NAMESZ]; |
277 | int rc; | 278 | int rc; |
278 | 279 | ||
279 | if ((mbus = kmalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL) | 280 | if ((mbus = kzalloc(sizeof(struct mon_bus), GFP_KERNEL)) == NULL) |
280 | goto err_alloc; | 281 | goto err_alloc; |
281 | memset(mbus, 0, sizeof(struct mon_bus)); | ||
282 | kref_init(&mbus->ref); | 282 | kref_init(&mbus->ref); |
283 | spin_lock_init(&mbus->lock); | 283 | spin_lock_init(&mbus->lock); |
284 | INIT_LIST_HEAD(&mbus->r_list); | 284 | INIT_LIST_HEAD(&mbus->r_list); |
@@ -307,9 +307,9 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus) | |||
307 | goto err_create_s; | 307 | goto err_create_s; |
308 | mbus->dent_s = d; | 308 | mbus->dent_s = d; |
309 | 309 | ||
310 | down(&mon_lock); | 310 | mutex_lock(&mon_lock); |
311 | list_add_tail(&mbus->bus_link, &mon_buses); | 311 | list_add_tail(&mbus->bus_link, &mon_buses); |
312 | up(&mon_lock); | 312 | mutex_unlock(&mon_lock); |
313 | return; | 313 | return; |
314 | 314 | ||
315 | err_create_s: | 315 | err_create_s: |
@@ -347,11 +347,11 @@ static int __init mon_init(void) | |||
347 | 347 | ||
348 | usb_register_notify(&mon_nb); | 348 | usb_register_notify(&mon_nb); |
349 | 349 | ||
350 | down(&usb_bus_list_lock); | 350 | mutex_lock(&usb_bus_list_lock); |
351 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { | 351 | list_for_each_entry (ubus, &usb_bus_list, bus_list) { |
352 | mon_bus_init(mondir, ubus); | 352 | mon_bus_init(mondir, ubus); |
353 | } | 353 | } |
354 | up(&usb_bus_list_lock); | 354 | mutex_unlock(&usb_bus_list_lock); |
355 | return 0; | 355 | return 0; |
356 | } | 356 | } |
357 | 357 | ||
@@ -363,7 +363,7 @@ static void __exit mon_exit(void) | |||
363 | usb_unregister_notify(&mon_nb); | 363 | usb_unregister_notify(&mon_nb); |
364 | usb_mon_deregister(); | 364 | usb_mon_deregister(); |
365 | 365 | ||
366 | down(&mon_lock); | 366 | mutex_lock(&mon_lock); |
367 | while (!list_empty(&mon_buses)) { | 367 | while (!list_empty(&mon_buses)) { |
368 | p = mon_buses.next; | 368 | p = mon_buses.next; |
369 | mbus = list_entry(p, struct mon_bus, bus_link); | 369 | mbus = list_entry(p, struct mon_bus, bus_link); |
@@ -387,7 +387,7 @@ static void __exit mon_exit(void) | |||
387 | mon_dissolve(mbus, mbus->u_bus); | 387 | mon_dissolve(mbus, mbus->u_bus); |
388 | kref_put(&mbus->ref, mon_bus_drop); | 388 | kref_put(&mbus->ref, mon_bus_drop); |
389 | } | 389 | } |
390 | up(&mon_lock); | 390 | mutex_unlock(&mon_lock); |
391 | 391 | ||
392 | debugfs_remove(mon_dir); | 392 | debugfs_remove(mon_dir); |
393 | } | 393 | } |