aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon
diff options
context:
space:
mode:
authorJaroslav Kysela <perex@suse.cz>2006-03-22 05:02:08 -0500
committerJaroslav Kysela <perex@suse.cz>2006-03-22 05:02:08 -0500
commit5501972e0b5857bc8354770d900ceb9b40c7f6b7 (patch)
treeff239422827c4cd54d2998f8851304255de31b38 /drivers/usb/mon
parent9d2f928ddf64ca0361562e30faf584cd33055c60 (diff)
parente952f31bce6e9f64db01f607abc46529ba57ac9e (diff)
Merge with rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'drivers/usb/mon')
-rw-r--r--drivers/usb/mon/mon_main.c22
-rw-r--r--drivers/usb/mon/mon_text.c24
-rw-r--r--drivers/usb/mon/usb_mon.h2
3 files changed, 24 insertions, 24 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);
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,
@@ -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
315err_create_s: 315err_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}
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 611612146ae9..ac043ec2b8dc 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,19 +209,18 @@ 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
215 rp = kmalloc(sizeof(struct mon_reader_text), GFP_KERNEL); 216 rp = kzalloc(sizeof(struct mon_reader_text), GFP_KERNEL);
216 if (rp == NULL) { 217 if (rp == NULL) {
217 rc = -ENOMEM; 218 rc = -ENOMEM;
218 goto err_alloc; 219 goto err_alloc;
219 } 220 }
220 memset(rp, 0, sizeof(struct mon_reader_text));
221 INIT_LIST_HEAD(&rp->e_list); 221 INIT_LIST_HEAD(&rp->e_list);
222 init_waitqueue_head(&rp->wait); 222 init_waitqueue_head(&rp->wait);
223 init_MUTEX(&rp->printf_lock); 223 mutex_init(&rp->printf_lock);
224 224
225 rp->printf_size = PRINTF_DFL; 225 rp->printf_size = PRINTF_DFL;
226 rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL); 226 rp->printf_buf = kmalloc(rp->printf_size, GFP_KERNEL);
@@ -247,7 +247,7 @@ static int mon_text_open(struct inode *inode, struct file *file)
247 mon_reader_add(mbus, &rp->r); 247 mon_reader_add(mbus, &rp->r);
248 248
249 file->private_data = rp; 249 file->private_data = rp;
250 up(&mon_lock); 250 mutex_unlock(&mon_lock);
251 return 0; 251 return 0;
252 252
253// err_busy: 253// err_busy:
@@ -257,7 +257,7 @@ err_slab:
257err_alloc_pr: 257err_alloc_pr:
258 kfree(rp); 258 kfree(rp);
259err_alloc: 259err_alloc:
260 up(&mon_lock); 260 mutex_unlock(&mon_lock);
261 return rc; 261 return rc;
262} 262}
263 263
@@ -301,7 +301,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
301 set_current_state(TASK_RUNNING); 301 set_current_state(TASK_RUNNING);
302 remove_wait_queue(&rp->wait, &waita); 302 remove_wait_queue(&rp->wait, &waita);
303 303
304 down(&rp->printf_lock); 304 mutex_lock(&rp->printf_lock);
305 cnt = 0; 305 cnt = 0;
306 pbuf = rp->printf_buf; 306 pbuf = rp->printf_buf;
307 limit = rp->printf_size; 307 limit = rp->printf_size;
@@ -358,7 +358,7 @@ static ssize_t mon_text_read(struct file *file, char __user *buf,
358 358
359 if (copy_to_user(buf, rp->printf_buf, cnt)) 359 if (copy_to_user(buf, rp->printf_buf, cnt))
360 cnt = -EFAULT; 360 cnt = -EFAULT;
361 up(&rp->printf_lock); 361 mutex_unlock(&rp->printf_lock);
362 kmem_cache_free(rp->e_slab, ep); 362 kmem_cache_free(rp->e_slab, ep);
363 return cnt; 363 return cnt;
364} 364}
@@ -371,12 +371,12 @@ static int mon_text_release(struct inode *inode, struct file *file)
371 struct list_head *p; 371 struct list_head *p;
372 struct mon_event_text *ep; 372 struct mon_event_text *ep;
373 373
374 down(&mon_lock); 374 mutex_lock(&mon_lock);
375 mbus = inode->u.generic_ip; 375 mbus = inode->u.generic_ip;
376 376
377 if (mbus->nreaders <= 0) { 377 if (mbus->nreaders <= 0) {
378 printk(KERN_ERR TAG ": consistency error on close\n"); 378 printk(KERN_ERR TAG ": consistency error on close\n");
379 up(&mon_lock); 379 mutex_unlock(&mon_lock);
380 return 0; 380 return 0;
381 } 381 }
382 mon_reader_del(mbus, &rp->r); 382 mon_reader_del(mbus, &rp->r);
@@ -402,7 +402,7 @@ static int mon_text_release(struct inode *inode, struct file *file)
402 kfree(rp->printf_buf); 402 kfree(rp->printf_buf);
403 kfree(rp); 403 kfree(rp);
404 404
405 up(&mon_lock); 405 mutex_unlock(&mon_lock);
406 return 0; 406 return 0;
407} 407}
408 408
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;