aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio/serio_raw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/serio/serio_raw.c')
-rw-r--r--drivers/input/serio/serio_raw.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index 47e08de18d07..8734e7f75b7d 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -19,6 +19,7 @@
19#include <linux/devfs_fs_kernel.h> 19#include <linux/devfs_fs_kernel.h>
20#include <linux/miscdevice.h> 20#include <linux/miscdevice.h>
21#include <linux/wait.h> 21#include <linux/wait.h>
22#include <linux/mutex.h>
22 23
23#define DRIVER_DESC "Raw serio driver" 24#define DRIVER_DESC "Raw serio driver"
24 25
@@ -46,7 +47,7 @@ struct serio_raw_list {
46 struct list_head node; 47 struct list_head node;
47}; 48};
48 49
49static DECLARE_MUTEX(serio_raw_sem); 50static DEFINE_MUTEX(serio_raw_mutex);
50static LIST_HEAD(serio_raw_list); 51static LIST_HEAD(serio_raw_list);
51static unsigned int serio_raw_no; 52static unsigned int serio_raw_no;
52 53
@@ -81,7 +82,7 @@ static int serio_raw_open(struct inode *inode, struct file *file)
81 struct serio_raw_list *list; 82 struct serio_raw_list *list;
82 int retval = 0; 83 int retval = 0;
83 84
84 retval = down_interruptible(&serio_raw_sem); 85 retval = mutex_lock_interruptible(&serio_raw_mutex);
85 if (retval) 86 if (retval)
86 return retval; 87 return retval;
87 88
@@ -108,7 +109,7 @@ static int serio_raw_open(struct inode *inode, struct file *file)
108 list_add_tail(&list->node, &serio_raw->list); 109 list_add_tail(&list->node, &serio_raw->list);
109 110
110out: 111out:
111 up(&serio_raw_sem); 112 mutex_unlock(&serio_raw_mutex);
112 return retval; 113 return retval;
113} 114}
114 115
@@ -130,12 +131,12 @@ static int serio_raw_release(struct inode *inode, struct file *file)
130 struct serio_raw_list *list = file->private_data; 131 struct serio_raw_list *list = file->private_data;
131 struct serio_raw *serio_raw = list->serio_raw; 132 struct serio_raw *serio_raw = list->serio_raw;
132 133
133 down(&serio_raw_sem); 134 mutex_lock(&serio_raw_mutex);
134 135
135 serio_raw_fasync(-1, file, 0); 136 serio_raw_fasync(-1, file, 0);
136 serio_raw_cleanup(serio_raw); 137 serio_raw_cleanup(serio_raw);
137 138
138 up(&serio_raw_sem); 139 mutex_unlock(&serio_raw_mutex);
139 return 0; 140 return 0;
140} 141}
141 142
@@ -194,7 +195,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
194 int retval; 195 int retval;
195 unsigned char c; 196 unsigned char c;
196 197
197 retval = down_interruptible(&serio_raw_sem); 198 retval = mutex_lock_interruptible(&serio_raw_mutex);
198 if (retval) 199 if (retval)
199 return retval; 200 return retval;
200 201
@@ -219,7 +220,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz
219 }; 220 };
220 221
221out: 222out:
222 up(&serio_raw_sem); 223 mutex_unlock(&serio_raw_mutex);
223 return written; 224 return written;
224} 225}
225 226
@@ -280,7 +281,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
280 return -ENOMEM; 281 return -ENOMEM;
281 } 282 }
282 283
283 down(&serio_raw_sem); 284 mutex_lock(&serio_raw_mutex);
284 285
285 memset(serio_raw, 0, sizeof(struct serio_raw)); 286 memset(serio_raw, 0, sizeof(struct serio_raw));
286 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++); 287 snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++);
@@ -325,7 +326,7 @@ out_free:
325 serio_set_drvdata(serio, NULL); 326 serio_set_drvdata(serio, NULL);
326 kfree(serio_raw); 327 kfree(serio_raw);
327out: 328out:
328 up(&serio_raw_sem); 329 mutex_unlock(&serio_raw_mutex);
329 return err; 330 return err;
330} 331}
331 332
@@ -350,7 +351,7 @@ static void serio_raw_disconnect(struct serio *serio)
350{ 351{
351 struct serio_raw *serio_raw; 352 struct serio_raw *serio_raw;
352 353
353 down(&serio_raw_sem); 354 mutex_lock(&serio_raw_mutex);
354 355
355 serio_raw = serio_get_drvdata(serio); 356 serio_raw = serio_get_drvdata(serio);
356 357
@@ -361,7 +362,7 @@ static void serio_raw_disconnect(struct serio *serio)
361 if (!serio_raw_cleanup(serio_raw)) 362 if (!serio_raw_cleanup(serio_raw))
362 wake_up_interruptible(&serio_raw->wait); 363 wake_up_interruptible(&serio_raw->wait);
363 364
364 up(&serio_raw_sem); 365 mutex_unlock(&serio_raw_mutex);
365} 366}
366 367
367static struct serio_device_id serio_raw_serio_ids[] = { 368static struct serio_device_id serio_raw_serio_ids[] = {