diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-02-19 00:21:55 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-02-19 00:21:55 -0500 |
commit | c4e32e9faaaa83340dbbc00e07c48d38f032b7dc (patch) | |
tree | aa3adb5073a8c4c70a7f4b7f2dda57e9d1c52d85 /drivers/input | |
parent | e676c232e670e27d8b3783e1167f34288e17c83f (diff) |
Input: serio - semaphore to mutex conversion
The conversion was generated via scripts, and the result was validated
automatically via a script as well.
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/serio/libps2.c | 10 | ||||
-rw-r--r-- | drivers/input/serio/serio.c | 45 | ||||
-rw-r--r-- | drivers/input/serio/serio_raw.c | 23 |
3 files changed, 40 insertions, 38 deletions
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 | ||
282 | void ps2_init(struct ps2dev *ps2dev, struct serio *serio) | 282 | void 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/serio.c b/drivers/input/serio/serio.c index 2f76813c3a64..79e5e77ce03e 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 | ||
38 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 39 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
39 | MODULE_DESCRIPTION("Serio abstraction core"); | 40 | MODULE_DESCRIPTION("Serio abstraction core"); |
@@ -52,10 +53,10 @@ EXPORT_SYMBOL(serio_rescan); | |||
52 | EXPORT_SYMBOL(serio_reconnect); | 53 | EXPORT_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 | */ |
58 | static DECLARE_MUTEX(serio_sem); | 59 | static DEFINE_MUTEX(serio_mutex); |
59 | 60 | ||
60 | static LIST_HEAD(serio_list); | 61 | static 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 | ||
92 | static void serio_disconnect_driver(struct serio *serio) | 93 | static 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 | ||
100 | static int serio_match_port(const struct serio_device_id *ids, struct serio *serio) | 101 | static int serio_match_port(const struct serio_device_id *ids, struct serio *serio) |
@@ -272,7 +273,7 @@ static void serio_handle_event(void) | |||
272 | struct serio_event *event; | 273 | struct serio_event *event; |
273 | struct serio_driver *serio_drv; | 274 | struct serio_driver *serio_drv; |
274 | 275 | ||
275 | down(&serio_sem); | 276 | mutex_lock(&serio_mutex); |
276 | 277 | ||
277 | /* | 278 | /* |
278 | * Note that we handle only one event here to give swsusp | 279 | * Note that we handle only one event here to give swsusp |
@@ -314,7 +315,7 @@ static void serio_handle_event(void) | |||
314 | serio_free_event(event); | 315 | serio_free_event(event); |
315 | } | 316 | } |
316 | 317 | ||
317 | up(&serio_sem); | 318 | mutex_unlock(&serio_mutex); |
318 | } | 319 | } |
319 | 320 | ||
320 | /* | 321 | /* |
@@ -449,7 +450,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute * | |||
449 | struct device_driver *drv; | 450 | struct device_driver *drv; |
450 | int retval; | 451 | int retval; |
451 | 452 | ||
452 | retval = down_interruptible(&serio_sem); | 453 | retval = mutex_lock_interruptible(&serio_mutex); |
453 | if (retval) | 454 | if (retval) |
454 | return retval; | 455 | return retval; |
455 | 456 | ||
@@ -469,7 +470,7 @@ static ssize_t serio_rebind_driver(struct device *dev, struct device_attribute * | |||
469 | retval = -EINVAL; | 470 | retval = -EINVAL; |
470 | } | 471 | } |
471 | 472 | ||
472 | up(&serio_sem); | 473 | mutex_unlock(&serio_mutex); |
473 | 474 | ||
474 | return retval; | 475 | return retval; |
475 | } | 476 | } |
@@ -524,7 +525,7 @@ static void serio_init_port(struct serio *serio) | |||
524 | __module_get(THIS_MODULE); | 525 | __module_get(THIS_MODULE); |
525 | 526 | ||
526 | spin_lock_init(&serio->lock); | 527 | spin_lock_init(&serio->lock); |
527 | init_MUTEX(&serio->drv_sem); | 528 | mutex_init(&serio->drv_mutex); |
528 | device_initialize(&serio->dev); | 529 | device_initialize(&serio->dev); |
529 | snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), | 530 | snprintf(serio->dev.bus_id, sizeof(serio->dev.bus_id), |
530 | "serio%ld", (long)atomic_inc_return(&serio_no) - 1); | 531 | "serio%ld", (long)atomic_inc_return(&serio_no) - 1); |
@@ -661,10 +662,10 @@ void __serio_register_port(struct serio *serio, struct module *owner) | |||
661 | */ | 662 | */ |
662 | void serio_unregister_port(struct serio *serio) | 663 | void serio_unregister_port(struct serio *serio) |
663 | { | 664 | { |
664 | down(&serio_sem); | 665 | mutex_lock(&serio_mutex); |
665 | serio_disconnect_port(serio); | 666 | serio_disconnect_port(serio); |
666 | serio_destroy_port(serio); | 667 | serio_destroy_port(serio); |
667 | up(&serio_sem); | 668 | mutex_unlock(&serio_mutex); |
668 | } | 669 | } |
669 | 670 | ||
670 | /* | 671 | /* |
@@ -672,17 +673,17 @@ void serio_unregister_port(struct serio *serio) | |||
672 | */ | 673 | */ |
673 | void serio_unregister_child_port(struct serio *serio) | 674 | void serio_unregister_child_port(struct serio *serio) |
674 | { | 675 | { |
675 | down(&serio_sem); | 676 | mutex_lock(&serio_mutex); |
676 | if (serio->child) { | 677 | if (serio->child) { |
677 | serio_disconnect_port(serio->child); | 678 | serio_disconnect_port(serio->child); |
678 | serio_destroy_port(serio->child); | 679 | serio_destroy_port(serio->child); |
679 | } | 680 | } |
680 | up(&serio_sem); | 681 | mutex_unlock(&serio_mutex); |
681 | } | 682 | } |
682 | 683 | ||
683 | /* | 684 | /* |
684 | * Submits register request to kseriod for subsequent execution. | 685 | * Submits register request to kseriod for subsequent execution. |
685 | * Can be used when it is not obvious whether the serio_sem is | 686 | * Can be used when it is not obvious whether the serio_mutex is |
686 | * taken or not and when delayed execution is feasible. | 687 | * taken or not and when delayed execution is feasible. |
687 | */ | 688 | */ |
688 | void __serio_unregister_port_delayed(struct serio *serio, struct module *owner) | 689 | void __serio_unregister_port_delayed(struct serio *serio, struct module *owner) |
@@ -765,7 +766,7 @@ void serio_unregister_driver(struct serio_driver *drv) | |||
765 | { | 766 | { |
766 | struct serio *serio; | 767 | struct serio *serio; |
767 | 768 | ||
768 | down(&serio_sem); | 769 | mutex_lock(&serio_mutex); |
769 | drv->manual_bind = 1; /* so serio_find_driver ignores it */ | 770 | drv->manual_bind = 1; /* so serio_find_driver ignores it */ |
770 | 771 | ||
771 | start_over: | 772 | start_over: |
@@ -779,7 +780,7 @@ start_over: | |||
779 | } | 780 | } |
780 | 781 | ||
781 | driver_unregister(&drv->driver); | 782 | driver_unregister(&drv->driver); |
782 | up(&serio_sem); | 783 | mutex_unlock(&serio_mutex); |
783 | } | 784 | } |
784 | 785 | ||
785 | static void serio_set_drv(struct serio *serio, struct serio_driver *drv) | 786 | static void serio_set_drv(struct serio *serio, struct serio_driver *drv) |
@@ -858,7 +859,7 @@ static int serio_resume(struct device *dev) | |||
858 | return 0; | 859 | return 0; |
859 | } | 860 | } |
860 | 861 | ||
861 | /* called from serio_driver->connect/disconnect methods under serio_sem */ | 862 | /* called from serio_driver->connect/disconnect methods under serio_mutex */ |
862 | int serio_open(struct serio *serio, struct serio_driver *drv) | 863 | int serio_open(struct serio *serio, struct serio_driver *drv) |
863 | { | 864 | { |
864 | serio_set_drv(serio, drv); | 865 | serio_set_drv(serio, drv); |
@@ -870,7 +871,7 @@ int serio_open(struct serio *serio, struct serio_driver *drv) | |||
870 | return 0; | 871 | return 0; |
871 | } | 872 | } |
872 | 873 | ||
873 | /* called from serio_driver->connect/disconnect methods under serio_sem */ | 874 | /* called from serio_driver->connect/disconnect methods under serio_mutex */ |
874 | void serio_close(struct serio *serio) | 875 | void serio_close(struct serio *serio) |
875 | { | 876 | { |
876 | if (serio->close) | 877 | if (serio->close) |
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 | ||
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 | ||
@@ -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 | ||
110 | out: | 111 | out: |
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 | ||
221 | out: | 222 | out: |
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); |
327 | out: | 328 | out: |
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 | ||
367 | static struct serio_device_id serio_raw_serio_ids[] = { | 368 | static struct serio_device_id serio_raw_serio_ids[] = { |