diff options
Diffstat (limited to 'drivers/usb/mon/mon_text.c')
-rw-r--r-- | drivers/usb/mon/mon_text.c | 24 |
1 files changed, 12 insertions, 12 deletions
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: | |||
257 | err_alloc_pr: | 257 | err_alloc_pr: |
258 | kfree(rp); | 258 | kfree(rp); |
259 | err_alloc: | 259 | err_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 | ||