diff options
Diffstat (limited to 'drivers/input/serio/serio_raw.c')
-rw-r--r-- | drivers/input/serio/serio_raw.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index 47e08de18d07..5a2703b536dc 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 | ||
49 | static DECLARE_MUTEX(serio_raw_sem); | 50 | static DEFINE_MUTEX(serio_raw_mutex); |
50 | static LIST_HEAD(serio_raw_list); | 51 | static LIST_HEAD(serio_raw_list); |
51 | static unsigned int serio_raw_no; | 52 | static 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 | ||
@@ -95,12 +96,11 @@ static int serio_raw_open(struct inode *inode, struct file *file) | |||
95 | goto out; | 96 | goto out; |
96 | } | 97 | } |
97 | 98 | ||
98 | if (!(list = kmalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) { | 99 | if (!(list = kzalloc(sizeof(struct serio_raw_list), GFP_KERNEL))) { |
99 | retval = -ENOMEM; | 100 | retval = -ENOMEM; |
100 | goto out; | 101 | goto out; |
101 | } | 102 | } |
102 | 103 | ||
103 | memset(list, 0, sizeof(struct serio_raw_list)); | ||
104 | list->serio_raw = serio_raw; | 104 | list->serio_raw = serio_raw; |
105 | file->private_data = list; | 105 | file->private_data = list; |
106 | 106 | ||
@@ -108,7 +108,7 @@ static int serio_raw_open(struct inode *inode, struct file *file) | |||
108 | list_add_tail(&list->node, &serio_raw->list); | 108 | list_add_tail(&list->node, &serio_raw->list); |
109 | 109 | ||
110 | out: | 110 | out: |
111 | up(&serio_raw_sem); | 111 | mutex_unlock(&serio_raw_mutex); |
112 | return retval; | 112 | return retval; |
113 | } | 113 | } |
114 | 114 | ||
@@ -130,12 +130,12 @@ static int serio_raw_release(struct inode *inode, struct file *file) | |||
130 | struct serio_raw_list *list = file->private_data; | 130 | struct serio_raw_list *list = file->private_data; |
131 | struct serio_raw *serio_raw = list->serio_raw; | 131 | struct serio_raw *serio_raw = list->serio_raw; |
132 | 132 | ||
133 | down(&serio_raw_sem); | 133 | mutex_lock(&serio_raw_mutex); |
134 | 134 | ||
135 | serio_raw_fasync(-1, file, 0); | 135 | serio_raw_fasync(-1, file, 0); |
136 | serio_raw_cleanup(serio_raw); | 136 | serio_raw_cleanup(serio_raw); |
137 | 137 | ||
138 | up(&serio_raw_sem); | 138 | mutex_unlock(&serio_raw_mutex); |
139 | return 0; | 139 | return 0; |
140 | } | 140 | } |
141 | 141 | ||
@@ -194,7 +194,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz | |||
194 | int retval; | 194 | int retval; |
195 | unsigned char c; | 195 | unsigned char c; |
196 | 196 | ||
197 | retval = down_interruptible(&serio_raw_sem); | 197 | retval = mutex_lock_interruptible(&serio_raw_mutex); |
198 | if (retval) | 198 | if (retval) |
199 | return retval; | 199 | return retval; |
200 | 200 | ||
@@ -219,7 +219,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer, siz | |||
219 | }; | 219 | }; |
220 | 220 | ||
221 | out: | 221 | out: |
222 | up(&serio_raw_sem); | 222 | mutex_unlock(&serio_raw_mutex); |
223 | return written; | 223 | return written; |
224 | } | 224 | } |
225 | 225 | ||
@@ -275,14 +275,13 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv) | |||
275 | struct serio_raw *serio_raw; | 275 | struct serio_raw *serio_raw; |
276 | int err; | 276 | int err; |
277 | 277 | ||
278 | if (!(serio_raw = kmalloc(sizeof(struct serio_raw), GFP_KERNEL))) { | 278 | if (!(serio_raw = kzalloc(sizeof(struct serio_raw), GFP_KERNEL))) { |
279 | printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n"); | 279 | printk(KERN_ERR "serio_raw.c: can't allocate memory for a device\n"); |
280 | return -ENOMEM; | 280 | return -ENOMEM; |
281 | } | 281 | } |
282 | 282 | ||
283 | down(&serio_raw_sem); | 283 | mutex_lock(&serio_raw_mutex); |
284 | 284 | ||
285 | memset(serio_raw, 0, sizeof(struct serio_raw)); | ||
286 | snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++); | 285 | snprintf(serio_raw->name, sizeof(serio_raw->name), "serio_raw%d", serio_raw_no++); |
287 | serio_raw->refcnt = 1; | 286 | serio_raw->refcnt = 1; |
288 | serio_raw->serio = serio; | 287 | serio_raw->serio = serio; |
@@ -325,7 +324,7 @@ out_free: | |||
325 | serio_set_drvdata(serio, NULL); | 324 | serio_set_drvdata(serio, NULL); |
326 | kfree(serio_raw); | 325 | kfree(serio_raw); |
327 | out: | 326 | out: |
328 | up(&serio_raw_sem); | 327 | mutex_unlock(&serio_raw_mutex); |
329 | return err; | 328 | return err; |
330 | } | 329 | } |
331 | 330 | ||
@@ -350,7 +349,7 @@ static void serio_raw_disconnect(struct serio *serio) | |||
350 | { | 349 | { |
351 | struct serio_raw *serio_raw; | 350 | struct serio_raw *serio_raw; |
352 | 351 | ||
353 | down(&serio_raw_sem); | 352 | mutex_lock(&serio_raw_mutex); |
354 | 353 | ||
355 | serio_raw = serio_get_drvdata(serio); | 354 | serio_raw = serio_get_drvdata(serio); |
356 | 355 | ||
@@ -361,7 +360,7 @@ static void serio_raw_disconnect(struct serio *serio) | |||
361 | if (!serio_raw_cleanup(serio_raw)) | 360 | if (!serio_raw_cleanup(serio_raw)) |
362 | wake_up_interruptible(&serio_raw->wait); | 361 | wake_up_interruptible(&serio_raw->wait); |
363 | 362 | ||
364 | up(&serio_raw_sem); | 363 | mutex_unlock(&serio_raw_mutex); |
365 | } | 364 | } |
366 | 365 | ||
367 | static struct serio_device_id serio_raw_serio_ids[] = { | 366 | static struct serio_device_id serio_raw_serio_ids[] = { |