diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-02-19 00:22:03 -0500 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-02-19 00:22:03 -0500 |
commit | 286295eb936e76347173639c218134e6342440f9 (patch) | |
tree | a6a746aaa8df21691c71454d1f522a4188a54558 | |
parent | c4e32e9faaaa83340dbbc00e07c48d38f032b7dc (diff) |
Input: gameport - 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>
-rw-r--r-- | drivers/input/gameport/gameport.c | 27 | ||||
-rw-r--r-- | include/linux/gameport.h | 7 |
2 files changed, 18 insertions, 16 deletions
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index b765a155c008..9444702630c4 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/delay.h> | 22 | #include <linux/delay.h> |
23 | #include <linux/kthread.h> | 23 | #include <linux/kthread.h> |
24 | #include <linux/sched.h> /* HZ */ | 24 | #include <linux/sched.h> /* HZ */ |
25 | #include <linux/mutex.h> | ||
25 | 26 | ||
26 | /*#include <asm/io.h>*/ | 27 | /*#include <asm/io.h>*/ |
27 | 28 | ||
@@ -43,10 +44,10 @@ EXPORT_SYMBOL(gameport_start_polling); | |||
43 | EXPORT_SYMBOL(gameport_stop_polling); | 44 | EXPORT_SYMBOL(gameport_stop_polling); |
44 | 45 | ||
45 | /* | 46 | /* |
46 | * gameport_sem protects entire gameport subsystem and is taken | 47 | * gameport_mutex protects entire gameport subsystem and is taken |
47 | * every time gameport port or driver registrered or unregistered. | 48 | * every time gameport port or driver registrered or unregistered. |
48 | */ | 49 | */ |
49 | static DECLARE_MUTEX(gameport_sem); | 50 | static DEFINE_MUTEX(gameport_mutex); |
50 | 51 | ||
51 | static LIST_HEAD(gameport_list); | 52 | static LIST_HEAD(gameport_list); |
52 | 53 | ||
@@ -342,7 +343,7 @@ static void gameport_handle_event(void) | |||
342 | struct gameport_event *event; | 343 | struct gameport_event *event; |
343 | struct gameport_driver *gameport_drv; | 344 | struct gameport_driver *gameport_drv; |
344 | 345 | ||
345 | down(&gameport_sem); | 346 | mutex_lock(&gameport_mutex); |
346 | 347 | ||
347 | /* | 348 | /* |
348 | * Note that we handle only one event here to give swsusp | 349 | * Note that we handle only one event here to give swsusp |
@@ -379,7 +380,7 @@ static void gameport_handle_event(void) | |||
379 | gameport_free_event(event); | 380 | gameport_free_event(event); |
380 | } | 381 | } |
381 | 382 | ||
382 | up(&gameport_sem); | 383 | mutex_unlock(&gameport_mutex); |
383 | } | 384 | } |
384 | 385 | ||
385 | /* | 386 | /* |
@@ -464,7 +465,7 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut | |||
464 | struct device_driver *drv; | 465 | struct device_driver *drv; |
465 | int retval; | 466 | int retval; |
466 | 467 | ||
467 | retval = down_interruptible(&gameport_sem); | 468 | retval = mutex_lock_interruptible(&gameport_mutex); |
468 | if (retval) | 469 | if (retval) |
469 | return retval; | 470 | return retval; |
470 | 471 | ||
@@ -484,7 +485,7 @@ static ssize_t gameport_rebind_driver(struct device *dev, struct device_attribut | |||
484 | retval = -EINVAL; | 485 | retval = -EINVAL; |
485 | } | 486 | } |
486 | 487 | ||
487 | up(&gameport_sem); | 488 | mutex_unlock(&gameport_mutex); |
488 | 489 | ||
489 | return retval; | 490 | return retval; |
490 | } | 491 | } |
@@ -521,7 +522,7 @@ static void gameport_init_port(struct gameport *gameport) | |||
521 | 522 | ||
522 | __module_get(THIS_MODULE); | 523 | __module_get(THIS_MODULE); |
523 | 524 | ||
524 | init_MUTEX(&gameport->drv_sem); | 525 | mutex_init(&gameport->drv_mutex); |
525 | device_initialize(&gameport->dev); | 526 | device_initialize(&gameport->dev); |
526 | snprintf(gameport->dev.bus_id, sizeof(gameport->dev.bus_id), | 527 | snprintf(gameport->dev.bus_id, sizeof(gameport->dev.bus_id), |
527 | "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1); | 528 | "gameport%lu", (unsigned long)atomic_inc_return(&gameport_no) - 1); |
@@ -661,10 +662,10 @@ void __gameport_register_port(struct gameport *gameport, struct module *owner) | |||
661 | */ | 662 | */ |
662 | void gameport_unregister_port(struct gameport *gameport) | 663 | void gameport_unregister_port(struct gameport *gameport) |
663 | { | 664 | { |
664 | down(&gameport_sem); | 665 | mutex_lock(&gameport_mutex); |
665 | gameport_disconnect_port(gameport); | 666 | gameport_disconnect_port(gameport); |
666 | gameport_destroy_port(gameport); | 667 | gameport_destroy_port(gameport); |
667 | up(&gameport_sem); | 668 | mutex_unlock(&gameport_mutex); |
668 | } | 669 | } |
669 | 670 | ||
670 | 671 | ||
@@ -717,7 +718,7 @@ void gameport_unregister_driver(struct gameport_driver *drv) | |||
717 | { | 718 | { |
718 | struct gameport *gameport; | 719 | struct gameport *gameport; |
719 | 720 | ||
720 | down(&gameport_sem); | 721 | mutex_lock(&gameport_mutex); |
721 | drv->ignore = 1; /* so gameport_find_driver ignores it */ | 722 | drv->ignore = 1; /* so gameport_find_driver ignores it */ |
722 | 723 | ||
723 | start_over: | 724 | start_over: |
@@ -731,7 +732,7 @@ start_over: | |||
731 | } | 732 | } |
732 | 733 | ||
733 | driver_unregister(&drv->driver); | 734 | driver_unregister(&drv->driver); |
734 | up(&gameport_sem); | 735 | mutex_unlock(&gameport_mutex); |
735 | } | 736 | } |
736 | 737 | ||
737 | static int gameport_bus_match(struct device *dev, struct device_driver *drv) | 738 | static int gameport_bus_match(struct device *dev, struct device_driver *drv) |
@@ -743,9 +744,9 @@ static int gameport_bus_match(struct device *dev, struct device_driver *drv) | |||
743 | 744 | ||
744 | static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv) | 745 | static void gameport_set_drv(struct gameport *gameport, struct gameport_driver *drv) |
745 | { | 746 | { |
746 | down(&gameport->drv_sem); | 747 | mutex_lock(&gameport->drv_mutex); |
747 | gameport->drv = drv; | 748 | gameport->drv = drv; |
748 | up(&gameport->drv_sem); | 749 | mutex_unlock(&gameport->drv_mutex); |
749 | } | 750 | } |
750 | 751 | ||
751 | int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode) | 752 | int gameport_open(struct gameport *gameport, struct gameport_driver *drv, int mode) |
diff --git a/include/linux/gameport.h b/include/linux/gameport.h index 2401dea2b867..3e1b9b285258 100644 --- a/include/linux/gameport.h +++ b/include/linux/gameport.h | |||
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | #include <asm/io.h> | 12 | #include <asm/io.h> |
13 | #include <linux/list.h> | 13 | #include <linux/list.h> |
14 | #include <linux/mutex.h> | ||
14 | #include <linux/device.h> | 15 | #include <linux/device.h> |
15 | #include <linux/timer.h> | 16 | #include <linux/timer.h> |
16 | 17 | ||
@@ -40,7 +41,7 @@ struct gameport { | |||
40 | struct gameport *parent, *child; | 41 | struct gameport *parent, *child; |
41 | 42 | ||
42 | struct gameport_driver *drv; | 43 | struct gameport_driver *drv; |
43 | struct semaphore drv_sem; /* protects serio->drv so attributes can pin driver */ | 44 | struct mutex drv_mutex; /* protects serio->drv so attributes can pin driver */ |
44 | 45 | ||
45 | struct device dev; | 46 | struct device dev; |
46 | unsigned int registered; /* port has been fully registered with driver core */ | 47 | unsigned int registered; /* port has been fully registered with driver core */ |
@@ -137,12 +138,12 @@ static inline void gameport_set_drvdata(struct gameport *gameport, void *data) | |||
137 | */ | 138 | */ |
138 | static inline int gameport_pin_driver(struct gameport *gameport) | 139 | static inline int gameport_pin_driver(struct gameport *gameport) |
139 | { | 140 | { |
140 | return down_interruptible(&gameport->drv_sem); | 141 | return mutex_lock_interruptible(&gameport->drv_mutex); |
141 | } | 142 | } |
142 | 143 | ||
143 | static inline void gameport_unpin_driver(struct gameport *gameport) | 144 | static inline void gameport_unpin_driver(struct gameport *gameport) |
144 | { | 145 | { |
145 | up(&gameport->drv_sem); | 146 | mutex_unlock(&gameport->drv_mutex); |
146 | } | 147 | } |
147 | 148 | ||
148 | void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); | 149 | void __gameport_register_driver(struct gameport_driver *drv, struct module *owner); |