aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/serio')
-rw-r--r--drivers/input/serio/gscps2.c4
-rw-r--r--drivers/input/serio/hil_mlc.c3
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h26
-rw-r--r--drivers/input/serio/libps2.c10
-rw-r--r--drivers/input/serio/parkbd.c3
-rw-r--r--drivers/input/serio/rpckbd.c3
-rw-r--r--drivers/input/serio/serio.c48
-rw-r--r--drivers/input/serio/serio_raw.c29
8 files changed, 65 insertions, 61 deletions
diff --git a/drivers/input/serio/gscps2.c b/drivers/input/serio/gscps2.c
index a7b0de0f92b2..c0b1e4becad3 100644
--- a/drivers/input/serio/gscps2.c
+++ b/drivers/input/serio/gscps2.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/input/serio/gscps2.c 2 * drivers/input/serio/gscps2.c
3 * 3 *
4 * Copyright (c) 2004 Helge Deller <deller@gmx.de> 4 * Copyright (c) 2004-2006 Helge Deller <deller@gmx.de>
5 * Copyright (c) 2002 Laurent Canet <canetl@esiee.fr> 5 * Copyright (c) 2002 Laurent Canet <canetl@esiee.fr>
6 * Copyright (c) 2002 Thibaut Varene <varenet@parisc-linux.org> 6 * Copyright (c) 2002 Thibaut Varene <varenet@parisc-linux.org>
7 * 7 *
@@ -354,7 +354,7 @@ static int __init gscps2_probe(struct parisc_device *dev)
354 memset(serio, 0, sizeof(struct serio)); 354 memset(serio, 0, sizeof(struct serio));
355 ps2port->port = serio; 355 ps2port->port = serio;
356 ps2port->padev = dev; 356 ps2port->padev = dev;
357 ps2port->addr = ioremap(hpa, GSC_STATUS + 4); 357 ps2port->addr = ioremap_nocache(hpa, GSC_STATUS + 4);
358 spin_lock_init(&ps2port->lock); 358 spin_lock_init(&ps2port->lock);
359 359
360 gscps2_reset(ps2port); 360 gscps2_reset(ps2port);
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index ea499783fb12..bbbe15e21904 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -872,9 +872,8 @@ int hil_mlc_register(hil_mlc *mlc) {
872 for (i = 0; i < HIL_MLC_DEVMEM; i++) { 872 for (i = 0; i < HIL_MLC_DEVMEM; i++) {
873 struct serio *mlc_serio; 873 struct serio *mlc_serio;
874 hil_mlc_copy_di_scratch(mlc, i); 874 hil_mlc_copy_di_scratch(mlc, i);
875 mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL); 875 mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL);
876 mlc->serio[i] = mlc_serio; 876 mlc->serio[i] = mlc_serio;
877 memset(mlc_serio, 0, sizeof(*mlc_serio));
878 mlc_serio->id = hil_mlc_serio_id; 877 mlc_serio->id = hil_mlc_serio_id;
879 mlc_serio->write = hil_mlc_serio_write; 878 mlc_serio->write = hil_mlc_serio_write;
880 mlc_serio->open = hil_mlc_serio_open; 879 mlc_serio->open = hil_mlc_serio_open;
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index a4c6f3522723..f606e96bc2f4 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -192,7 +192,9 @@ static struct dmi_system_id __initdata i8042_dmi_nomux_table[] = {
192#include <linux/pnp.h> 192#include <linux/pnp.h>
193 193
194static int i8042_pnp_kbd_registered; 194static int i8042_pnp_kbd_registered;
195static unsigned int i8042_pnp_kbd_devices;
195static int i8042_pnp_aux_registered; 196static int i8042_pnp_aux_registered;
197static unsigned int i8042_pnp_aux_devices;
196 198
197static int i8042_pnp_command_reg; 199static int i8042_pnp_command_reg;
198static int i8042_pnp_data_reg; 200static int i8042_pnp_data_reg;
@@ -219,6 +221,7 @@ static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *
219 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name)); 221 strncat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
220 } 222 }
221 223
224 i8042_pnp_kbd_devices++;
222 return 0; 225 return 0;
223} 226}
224 227
@@ -239,6 +242,7 @@ static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *
239 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name)); 242 strncat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
240 } 243 }
241 244
245 i8042_pnp_aux_devices++;
242 return 0; 246 return 0;
243} 247}
244 248
@@ -287,21 +291,23 @@ static void i8042_pnp_exit(void)
287 291
288static int __init i8042_pnp_init(void) 292static int __init i8042_pnp_init(void)
289{ 293{
290 int result_kbd = 0, result_aux = 0;
291 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 }; 294 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
295 int err;
292 296
293 if (i8042_nopnp) { 297 if (i8042_nopnp) {
294 printk(KERN_INFO "i8042: PNP detection disabled\n"); 298 printk(KERN_INFO "i8042: PNP detection disabled\n");
295 return 0; 299 return 0;
296 } 300 }
297 301
298 if ((result_kbd = pnp_register_driver(&i8042_pnp_kbd_driver)) >= 0) 302 err = pnp_register_driver(&i8042_pnp_kbd_driver);
303 if (!err)
299 i8042_pnp_kbd_registered = 1; 304 i8042_pnp_kbd_registered = 1;
300 305
301 if ((result_aux = pnp_register_driver(&i8042_pnp_aux_driver)) >= 0) 306 err = pnp_register_driver(&i8042_pnp_aux_driver);
307 if (!err)
302 i8042_pnp_aux_registered = 1; 308 i8042_pnp_aux_registered = 1;
303 309
304 if (result_kbd <= 0 && result_aux <= 0) { 310 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
305 i8042_pnp_exit(); 311 i8042_pnp_exit();
306#if defined(__ia64__) 312#if defined(__ia64__)
307 return -ENODEV; 313 return -ENODEV;
@@ -311,24 +317,24 @@ static int __init i8042_pnp_init(void)
311#endif 317#endif
312 } 318 }
313 319
314 if (result_kbd > 0) 320 if (i8042_pnp_kbd_devices)
315 snprintf(kbd_irq_str, sizeof(kbd_irq_str), 321 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
316 "%d", i8042_pnp_kbd_irq); 322 "%d", i8042_pnp_kbd_irq);
317 if (result_aux > 0) 323 if (i8042_pnp_aux_devices)
318 snprintf(aux_irq_str, sizeof(aux_irq_str), 324 snprintf(aux_irq_str, sizeof(aux_irq_str),
319 "%d", i8042_pnp_aux_irq); 325 "%d", i8042_pnp_aux_irq);
320 326
321 printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n", 327 printk(KERN_INFO "PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
322 i8042_pnp_kbd_name, (result_kbd > 0 && result_aux > 0) ? "," : "", 328 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
323 i8042_pnp_aux_name, 329 i8042_pnp_aux_name,
324 i8042_pnp_data_reg, i8042_pnp_command_reg, 330 i8042_pnp_data_reg, i8042_pnp_command_reg,
325 kbd_irq_str, (result_kbd > 0 && result_aux > 0) ? "," : "", 331 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
326 aux_irq_str); 332 aux_irq_str);
327 333
328#if defined(__ia64__) 334#if defined(__ia64__)
329 if (result_kbd <= 0) 335 if (!i8042_pnp_kbd_devices)
330 i8042_nokbd = 1; 336 i8042_nokbd = 1;
331 if (result_aux <= 0) 337 if (!i8042_pnp_aux_devices)
332 i8042_noaux = 1; 338 i8042_noaux = 1;
333#endif 339#endif
334 340
diff --git a/drivers/input/serio/libps2.c b/drivers/input/serio/libps2.c
index d4c990f7c85e..79c97f94bcbd 100644
--- a/drivers/input/serio/libps2.c
+++ b/drivers/input/serio/libps2.c
@@ -84,7 +84,7 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout)
84 maxbytes = sizeof(ps2dev->cmdbuf); 84 maxbytes = sizeof(ps2dev->cmdbuf);
85 } 85 }
86 86
87 down(&ps2dev->cmd_sem); 87 mutex_lock(&ps2dev->cmd_mutex);
88 88
89 serio_pause_rx(ps2dev->serio); 89 serio_pause_rx(ps2dev->serio);
90 ps2dev->flags = PS2_FLAG_CMD; 90 ps2dev->flags = PS2_FLAG_CMD;
@@ -94,7 +94,7 @@ void ps2_drain(struct ps2dev *ps2dev, int maxbytes, int timeout)
94 wait_event_timeout(ps2dev->wait, 94 wait_event_timeout(ps2dev->wait,
95 !(ps2dev->flags & PS2_FLAG_CMD), 95 !(ps2dev->flags & PS2_FLAG_CMD),
96 msecs_to_jiffies(timeout)); 96 msecs_to_jiffies(timeout));
97 up(&ps2dev->cmd_sem); 97 mutex_unlock(&ps2dev->cmd_mutex);
98} 98}
99 99
100/* 100/*
@@ -177,7 +177,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
177 return -1; 177 return -1;
178 } 178 }
179 179
180 down(&ps2dev->cmd_sem); 180 mutex_lock(&ps2dev->cmd_mutex);
181 181
182 serio_pause_rx(ps2dev->serio); 182 serio_pause_rx(ps2dev->serio);
183 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0; 183 ps2dev->flags = command == PS2_CMD_GETID ? PS2_FLAG_WAITID : 0;
@@ -229,7 +229,7 @@ int ps2_command(struct ps2dev *ps2dev, unsigned char *param, int command)
229 ps2dev->flags = 0; 229 ps2dev->flags = 0;
230 serio_continue_rx(ps2dev->serio); 230 serio_continue_rx(ps2dev->serio);
231 231
232 up(&ps2dev->cmd_sem); 232 mutex_unlock(&ps2dev->cmd_mutex);
233 return rc; 233 return rc;
234} 234}
235 235
@@ -281,7 +281,7 @@ int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int comman
281 281
282void ps2_init(struct ps2dev *ps2dev, struct serio *serio) 282void ps2_init(struct ps2dev *ps2dev, struct serio *serio)
283{ 283{
284 init_MUTEX(&ps2dev->cmd_sem); 284 mutex_init(&ps2dev->cmd_mutex);
285 init_waitqueue_head(&ps2dev->wait); 285 init_waitqueue_head(&ps2dev->wait);
286 ps2dev->serio = serio; 286 ps2dev->serio = serio;
287} 287}
diff --git a/drivers/input/serio/parkbd.c b/drivers/input/serio/parkbd.c
index 1d15c2819818..a5c1fb3a4a51 100644
--- a/drivers/input/serio/parkbd.c
+++ b/drivers/input/serio/parkbd.c
@@ -171,9 +171,8 @@ static struct serio * __init parkbd_allocate_serio(void)
171{ 171{
172 struct serio *serio; 172 struct serio *serio;
173 173
174 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 174 serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
175 if (serio) { 175 if (serio) {
176 memset(serio, 0, sizeof(struct serio));
177 serio->id.type = parkbd_mode; 176 serio->id.type = parkbd_mode;
178 serio->write = parkbd_write, 177 serio->write = parkbd_write,
179 strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name)); 178 strlcpy(serio->name, "PARKBD AT/XT keyboard adapter", sizeof(serio->name));
diff --git a/drivers/input/serio/rpckbd.c b/drivers/input/serio/rpckbd.c
index a3bd11589bc3..513d37fc1acf 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -111,11 +111,10 @@ static int __devinit rpckbd_probe(struct platform_device *dev)
111{ 111{
112 struct serio *serio; 112 struct serio *serio;
113 113
114 serio = kmalloc(sizeof(struct serio), GFP_KERNEL); 114 serio = kzalloc(sizeof(struct serio), GFP_KERNEL);
115 if (!serio) 115 if (!serio)
116 return -ENOMEM; 116 return -ENOMEM;
117 117
118 memset(serio, 0, sizeof(struct serio));
119 serio->id.type = SERIO_8042; 118 serio->id.type = SERIO_8042;
120 serio->write = rpckbd_write; 119 serio->write = rpckbd_write;
121 serio->open = rpckbd_open; 120 serio->open = rpckbd_open;
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index 2f76813c3a64..6521034bc933 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -34,6 +34,7 @@
34#include <linux/sched.h> 34#include <linux/sched.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/kthread.h> 36#include <linux/kthread.h>
37#include <linux/mutex.h>
37 38
38MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); 39MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
39MODULE_DESCRIPTION("Serio abstraction core"); 40MODULE_DESCRIPTION("Serio abstraction core");
@@ -52,10 +53,10 @@ EXPORT_SYMBOL(serio_rescan);
52EXPORT_SYMBOL(serio_reconnect); 53EXPORT_SYMBOL(serio_reconnect);
53 54
54/* 55/*
55 * serio_sem protects entire serio subsystem and is taken every time 56 * serio_mutex protects entire serio subsystem and is taken every time
56 * serio port or driver registrered or unregistered. 57 * serio port or driver registrered or unregistered.
57 */ 58 */
58static DECLARE_MUTEX(serio_sem); 59static DEFINE_MUTEX(serio_mutex);
59 60
60static LIST_HEAD(serio_list); 61static LIST_HEAD(serio_list);
61 62
@@ -70,9 +71,9 @@ static int serio_connect_driver(struct serio *serio, struct serio_driver *drv)
70{ 71{
71 int retval; 72 int retval;
72 73
73 down(&serio->drv_sem); 74 mutex_lock(&serio->drv_mutex);
74 retval = drv->connect(serio, drv); 75 retval = drv->connect(serio, drv);
75 up(&serio->drv_sem); 76 mutex_unlock(&serio->drv_mutex);
76 77
77 return retval; 78 return retval;
78} 79}
@@ -81,20 +82,20 @@ static int serio_reconnect_driver(struct serio *serio)
81{ 82{
82 int retval = -1; 83 int retval = -1;
83 84
84 down(&serio->drv_sem); 85 mutex_lock(&serio->drv_mutex);
85 if (serio->drv && serio->drv->reconnect) 86 if (serio->drv && serio->drv->reconnect)
86 retval = serio->drv->reconnect(serio); 87 retval = serio->drv->reconnect(serio);
87 up(&serio->drv_sem); 88 mutex_unlock(&serio->drv_mutex);
88 89
89 return retval; 90 return retval;
90} 91}
91 92
92static void serio_disconnect_driver(struct serio *serio) 93static void serio_disconnect_driver(struct serio *serio)
93{ 94{
94 down(&serio->drv_sem); 95 mutex_lock(&serio->drv_mutex);
95 if (serio->drv) 96 if (serio->drv)
96 serio->drv->disconnect(serio); 97 serio->drv->disconnect(serio);
97 up(&serio->drv_sem); 98 mutex_unlock(&serio->drv_mutex);
98} 99}
99 100
100static int serio_match_port(const struct serio_device_id *ids, struct serio *serio) 101static int serio_match_port(const struct serio_device_id *ids, struct serio *serio)
@@ -195,6 +196,7 @@ static void serio_queue_event(void *object, struct module *owner,
195 if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) { 196 if ((event = kmalloc(sizeof(struct serio_event), GFP_ATOMIC))) {
196 if (!try_module_get(owner)) { 197 if (!try_module_get(owner)) {
197 printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type); 198 printk(KERN_WARNING "serio: Can't get module reference, dropping event %d\n", event_type);
199 kfree(event);
198 goto out; 200 goto out;
199 } 201 }
200 202
@@ -272,7 +274,7 @@ static void serio_handle_event(void)
272 struct serio_event *event; 274 struct serio_event *event;
273 struct serio_driver *serio_drv; 275 struct serio_driver *serio_drv;
274 276
275 down(&serio_sem); 277 mutex_lock(&serio_mutex);
276 278
277 /* 279 /*
278 * Note that we handle only one event here to give swsusp 280 * Note that we handle only one event here to give swsusp
@@ -314,7 +316,7 @@ static void serio_handle_event(void)
314 serio_free_event(event); 316 serio_free_event(event);
315 } 317 }
316 318
317 up(&serio_sem); 319 mutex_unlock(&serio_mutex);
318} 320}
319 321
320/* 322/*
@@ -449,7 +451,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
449 struct device_driver *drv; 451 struct device_driver *drv;
450 int retval; 452 int retval;
451 453
452 retval = down_interruptible(&serio_sem); 454 retval = mutex_lock_interruptible(&serio_mutex);
453 if (retval) 455 if (retval)
454 return retval; 456 return retval;
455 457
@@ -469,7 +471,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute *
469 retval = -EINVAL; 471 retval = -EINVAL;
470 } 472 }
471 473
472 up(&serio_sem); 474 mutex_unlock(&serio_mutex);
473 475
474 return retval; 476 return retval;
475} 477}
@@ -524,7 +526,7 @@ static void serio_init_port(struct serio *serio)
524 __module_get(THIS_MODULE); 526 __module_get(THIS_MODULE);
525 527
526 spin_lock_init(&serio->lock); 528 spin_lock_init(&serio->lock);
527 init_MUTEX(&serio->drv_sem); 529 mutex_init(&serio->drv_mutex);
528 device_initialize(&serio->dev); 530 device_initialize(&serio->dev);
529 snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), 531 snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id),
530 "serio%ld", (long)atomic_inc_return(&serio_no) - 1); 532 "serio%ld", (long)atomic_inc_return(&serio_no) - 1);
@@ -661,10 +663,10 @@ void __serio_register_port(struct serio *serio, struct module *owner)
661 */ 663 */
662void serio_unregister_port(struct serio *serio) 664void serio_unregister_port(struct serio *serio)
663{ 665{
664 down(&serio_sem); 666 mutex_lock(&serio_mutex);
665 serio_disconnect_port(serio); 667 serio_disconnect_port(serio);
666 serio_destroy_port(serio); 668 serio_destroy_port(serio);
667 up(&serio_sem); 669 mutex_unlock(&serio_mutex);
668} 670}
669 671
670/* 672/*
@@ -672,17 +674,17 @@ void serio_unregister_port(struct serio *serio)
672 */ 674 */
673void serio_unregister_child_port(struct serio *serio) 675void serio_unregister_child_port(struct serio *serio)
674{ 676{
675 down(&serio_sem); 677 mutex_lock(&serio_mutex);
676 if (serio->child) { 678 if (serio->child) {
677 serio_disconnect_port(serio->child); 679 serio_disconnect_port(serio->child);
678 serio_destroy_port(serio->child); 680 serio_destroy_port(serio->child);
679 } 681 }
680 up(&serio_sem); 682 mutex_unlock(&serio_mutex);
681} 683}
682 684
683/* 685/*
684 * Submits register request to kseriod for subsequent execution. 686 * Submits register request to kseriod for subsequent execution.
685 * Can be used when it is not obvious whether the serio_sem is 687 * Can be used when it is not obvious whether the serio_mutex is
686 * taken or not and when delayed execution is feasible. 688 * taken or not and when delayed execution is feasible.
687 */ 689 */
688void __serio_unregister_port_delayed(struct serio *serio, struct module *owner) 690void __serio_unregister_port_delayed(struct serio *serio, struct module *owner)
@@ -765,7 +767,7 @@ void serio_unregister_driver(struct serio_driver *drv)
765{ 767{
766 struct serio *serio; 768 struct serio *serio;
767 769
768 down(&serio_sem); 770 mutex_lock(&serio_mutex);
769 drv->manual_bind = 1; /* so serio_find_driver ignores it */ 771 drv->manual_bind = 1; /* so serio_find_driver ignores it */
770 772
771start_over: 773start_over:
@@ -779,7 +781,7 @@ start_over:
779 } 781 }
780 782
781 driver_unregister(&drv->driver); 783 driver_unregister(&drv->driver);
782 up(&serio_sem); 784 mutex_unlock(&serio_mutex);
783} 785}
784 786
785static void serio_set_drv(struct serio *serio, struct serio_driver *drv) 787static void serio_set_drv(struct serio *serio, struct serio_driver *drv)
@@ -858,7 +860,7 @@ static int serio_resume(struct device *dev)
858 return 0; 860 return 0;
859} 861}
860 862
861/* called from serio_driver->connect/disconnect methods under serio_sem */ 863/* called from serio_driver->connect/disconnect methods under serio_mutex */
862int serio_open(struct serio *serio, struct serio_driver *drv) 864int serio_open(struct serio *serio, struct serio_driver *drv)
863{ 865{
864 serio_set_drv(serio, drv); 866 serio_set_drv(serio, drv);
@@ -870,7 +872,7 @@ int serio_open(struct serio *serio, struct serio_driver *drv)
870 return 0; 872 return 0;
871} 873}
872 874
873/* called from serio_driver->connect/disconnect methods under serio_sem */ 875/* called from serio_driver->connect/disconnect methods under serio_mutex */
874void serio_close(struct serio *serio) 876void serio_close(struct serio *serio)
875{ 877{
876 if (serio->close) 878 if (serio->close)
@@ -923,5 +925,5 @@ static void __exit serio_exit(void)
923 kthread_stop(serio_task); 925 kthread_stop(serio_task);
924} 926}
925 927
926module_init(serio_init); 928subsys_initcall(serio_init);
927module_exit(serio_exit); 929module_exit(serio_exit);
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
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
@@ -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
110out: 110out:
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
221out: 221out:
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);
327out: 326out:
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
367static struct serio_device_id serio_raw_serio_ids[] = { 366static struct serio_device_id serio_raw_serio_ids[] = {