aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/mon/mon_text.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/mon/mon_text.c')
-rw-r--r--drivers/usb/mon/mon_text.c21
1 files changed, 11 insertions, 10 deletions
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