diff options
Diffstat (limited to 'drivers/input/joystick')
-rw-r--r-- | drivers/input/joystick/amijoy.c | 11 | ||||
-rw-r--r-- | drivers/input/joystick/db9.c | 13 | ||||
-rw-r--r-- | drivers/input/joystick/gamecon.c | 96 | ||||
-rw-r--r-- | drivers/input/joystick/iforce/iforce-ff.c | 24 | ||||
-rw-r--r-- | drivers/input/joystick/iforce/iforce-main.c | 2 | ||||
-rw-r--r-- | drivers/input/joystick/iforce/iforce.h | 5 | ||||
-rw-r--r-- | drivers/input/joystick/turbografx.c | 13 |
7 files changed, 113 insertions, 51 deletions
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c index ec55a29fc861..7249d324297b 100644 --- a/drivers/input/joystick/amijoy.c +++ b/drivers/input/joystick/amijoy.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/input.h> | 37 | #include <linux/input.h> |
38 | #include <linux/interrupt.h> | 38 | #include <linux/interrupt.h> |
39 | #include <linux/mutex.h> | ||
39 | 40 | ||
40 | #include <asm/system.h> | 41 | #include <asm/system.h> |
41 | #include <asm/amigahw.h> | 42 | #include <asm/amigahw.h> |
@@ -52,7 +53,7 @@ MODULE_PARM_DESC(map, "Map of attached joysticks in form of <a>,<b> (default is | |||
52 | __obsolete_setup("amijoy="); | 53 | __obsolete_setup("amijoy="); |
53 | 54 | ||
54 | static int amijoy_used; | 55 | static int amijoy_used; |
55 | static DECLARE_MUTEX(amijoy_sem); | 56 | static DEFINE_MUTEX(amijoy_mutex); |
56 | static struct input_dev *amijoy_dev[2]; | 57 | static struct input_dev *amijoy_dev[2]; |
57 | static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; | 58 | static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" }; |
58 | 59 | ||
@@ -85,7 +86,7 @@ static int amijoy_open(struct input_dev *dev) | |||
85 | { | 86 | { |
86 | int err; | 87 | int err; |
87 | 88 | ||
88 | err = down_interruptible(&amijoy_sem); | 89 | err = mutex_lock_interruptible(&amijoy_mutex); |
89 | if (err) | 90 | if (err) |
90 | return err; | 91 | return err; |
91 | 92 | ||
@@ -97,16 +98,16 @@ static int amijoy_open(struct input_dev *dev) | |||
97 | 98 | ||
98 | amijoy_used++; | 99 | amijoy_used++; |
99 | out: | 100 | out: |
100 | up(&amijoy_sem); | 101 | mutex_unlock(&amijoy_mutex); |
101 | return err; | 102 | return err; |
102 | } | 103 | } |
103 | 104 | ||
104 | static void amijoy_close(struct input_dev *dev) | 105 | static void amijoy_close(struct input_dev *dev) |
105 | { | 106 | { |
106 | down(&amijoy_sem); | 107 | mutex_lock(&amijoy_mutex); |
107 | if (!--amijoy_used) | 108 | if (!--amijoy_used) |
108 | free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); | 109 | free_irq(IRQ_AMIGA_VERTB, amijoy_interrupt); |
109 | up(&amijoy_sem); | 110 | mutex_unlock(&amijoy_mutex); |
110 | } | 111 | } |
111 | 112 | ||
112 | static int __init amijoy_init(void) | 113 | static int __init amijoy_init(void) |
diff --git a/drivers/input/joystick/db9.c b/drivers/input/joystick/db9.c index dcffc34f30c3..e61894685cb1 100644 --- a/drivers/input/joystick/db9.c +++ b/drivers/input/joystick/db9.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/init.h> | 38 | #include <linux/init.h> |
39 | #include <linux/parport.h> | 39 | #include <linux/parport.h> |
40 | #include <linux/input.h> | 40 | #include <linux/input.h> |
41 | #include <linux/mutex.h> | ||
41 | 42 | ||
42 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 43 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
43 | MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); | 44 | MODULE_DESCRIPTION("Atari, Amstrad, Commodore, Amiga, Sega, etc. joystick driver"); |
@@ -111,7 +112,7 @@ struct db9 { | |||
111 | struct pardevice *pd; | 112 | struct pardevice *pd; |
112 | int mode; | 113 | int mode; |
113 | int used; | 114 | int used; |
114 | struct semaphore sem; | 115 | struct mutex mutex; |
115 | char phys[DB9_MAX_DEVICES][32]; | 116 | char phys[DB9_MAX_DEVICES][32]; |
116 | }; | 117 | }; |
117 | 118 | ||
@@ -525,7 +526,7 @@ static int db9_open(struct input_dev *dev) | |||
525 | struct parport *port = db9->pd->port; | 526 | struct parport *port = db9->pd->port; |
526 | int err; | 527 | int err; |
527 | 528 | ||
528 | err = down_interruptible(&db9->sem); | 529 | err = mutex_lock_interruptible(&db9->mutex); |
529 | if (err) | 530 | if (err) |
530 | return err; | 531 | return err; |
531 | 532 | ||
@@ -539,7 +540,7 @@ static int db9_open(struct input_dev *dev) | |||
539 | mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME); | 540 | mod_timer(&db9->timer, jiffies + DB9_REFRESH_TIME); |
540 | } | 541 | } |
541 | 542 | ||
542 | up(&db9->sem); | 543 | mutex_unlock(&db9->mutex); |
543 | return 0; | 544 | return 0; |
544 | } | 545 | } |
545 | 546 | ||
@@ -548,14 +549,14 @@ static void db9_close(struct input_dev *dev) | |||
548 | struct db9 *db9 = dev->private; | 549 | struct db9 *db9 = dev->private; |
549 | struct parport *port = db9->pd->port; | 550 | struct parport *port = db9->pd->port; |
550 | 551 | ||
551 | down(&db9->sem); | 552 | mutex_lock(&db9->mutex); |
552 | if (!--db9->used) { | 553 | if (!--db9->used) { |
553 | del_timer_sync(&db9->timer); | 554 | del_timer_sync(&db9->timer); |
554 | parport_write_control(port, 0x00); | 555 | parport_write_control(port, 0x00); |
555 | parport_data_forward(port); | 556 | parport_data_forward(port); |
556 | parport_release(db9->pd); | 557 | parport_release(db9->pd); |
557 | } | 558 | } |
558 | up(&db9->sem); | 559 | mutex_unlock(&db9->mutex); |
559 | } | 560 | } |
560 | 561 | ||
561 | static struct db9 __init *db9_probe(int parport, int mode) | 562 | static struct db9 __init *db9_probe(int parport, int mode) |
@@ -603,7 +604,7 @@ static struct db9 __init *db9_probe(int parport, int mode) | |||
603 | goto err_unreg_pardev; | 604 | goto err_unreg_pardev; |
604 | } | 605 | } |
605 | 606 | ||
606 | init_MUTEX(&db9->sem); | 607 | mutex_init(&db9->mutex); |
607 | db9->pd = pd; | 608 | db9->pd = pd; |
608 | db9->mode = mode; | 609 | db9->mode = mode; |
609 | init_timer(&db9->timer); | 610 | init_timer(&db9->timer); |
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index 900587acdb47..ecbdb6b9bbd6 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * Based on the work of: | 7 | * Based on the work of: |
8 | * Andree Borrmann John Dahlstrom | 8 | * Andree Borrmann John Dahlstrom |
9 | * David Kuder Nathan Hand | 9 | * David Kuder Nathan Hand |
10 | * Raphael Assenat | ||
10 | */ | 11 | */ |
11 | 12 | ||
12 | /* | 13 | /* |
@@ -36,6 +37,7 @@ | |||
36 | #include <linux/init.h> | 37 | #include <linux/init.h> |
37 | #include <linux/parport.h> | 38 | #include <linux/parport.h> |
38 | #include <linux/input.h> | 39 | #include <linux/input.h> |
40 | #include <linux/mutex.h> | ||
39 | 41 | ||
40 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 42 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
41 | MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); | 43 | MODULE_DESCRIPTION("NES, SNES, N64, MultiSystem, PSX gamepad driver"); |
@@ -72,8 +74,9 @@ __obsolete_setup("gc_3="); | |||
72 | #define GC_N64 6 | 74 | #define GC_N64 6 |
73 | #define GC_PSX 7 | 75 | #define GC_PSX 7 |
74 | #define GC_DDR 8 | 76 | #define GC_DDR 8 |
77 | #define GC_SNESMOUSE 9 | ||
75 | 78 | ||
76 | #define GC_MAX 8 | 79 | #define GC_MAX 9 |
77 | 80 | ||
78 | #define GC_REFRESH_TIME HZ/100 | 81 | #define GC_REFRESH_TIME HZ/100 |
79 | 82 | ||
@@ -83,7 +86,7 @@ struct gc { | |||
83 | struct timer_list timer; | 86 | struct timer_list timer; |
84 | unsigned char pads[GC_MAX + 1]; | 87 | unsigned char pads[GC_MAX + 1]; |
85 | int used; | 88 | int used; |
86 | struct semaphore sem; | 89 | struct mutex mutex; |
87 | char phys[GC_MAX_DEVICES][32]; | 90 | char phys[GC_MAX_DEVICES][32]; |
88 | }; | 91 | }; |
89 | 92 | ||
@@ -93,7 +96,7 @@ static int gc_status_bit[] = { 0x40, 0x80, 0x20, 0x10, 0x08 }; | |||
93 | 96 | ||
94 | static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick", | 97 | static char *gc_names[] = { NULL, "SNES pad", "NES pad", "NES FourPort", "Multisystem joystick", |
95 | "Multisystem 2-button joystick", "N64 controller", "PSX controller", | 98 | "Multisystem 2-button joystick", "N64 controller", "PSX controller", |
96 | "PSX DDR controller" }; | 99 | "PSX DDR controller", "SNES mouse" }; |
97 | /* | 100 | /* |
98 | * N64 support. | 101 | * N64 support. |
99 | */ | 102 | */ |
@@ -205,9 +208,12 @@ static void gc_n64_process_packet(struct gc *gc) | |||
205 | * NES/SNES support. | 208 | * NES/SNES support. |
206 | */ | 209 | */ |
207 | 210 | ||
208 | #define GC_NES_DELAY 6 /* Delay between bits - 6us */ | 211 | #define GC_NES_DELAY 6 /* Delay between bits - 6us */ |
209 | #define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */ | 212 | #define GC_NES_LENGTH 8 /* The NES pads use 8 bits of data */ |
210 | #define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the last 4 bits are unused */ | 213 | #define GC_SNES_LENGTH 12 /* The SNES true length is 16, but the |
214 | last 4 bits are unused */ | ||
215 | #define GC_SNESMOUSE_LENGTH 32 /* The SNES mouse uses 32 bits, the first | ||
216 | 16 bits are equivalent to a gamepad */ | ||
211 | 217 | ||
212 | #define GC_NES_POWER 0xfc | 218 | #define GC_NES_POWER 0xfc |
213 | #define GC_NES_CLOCK 0x01 | 219 | #define GC_NES_CLOCK 0x01 |
@@ -242,11 +248,15 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data) | |||
242 | 248 | ||
243 | static void gc_nes_process_packet(struct gc *gc) | 249 | static void gc_nes_process_packet(struct gc *gc) |
244 | { | 250 | { |
245 | unsigned char data[GC_SNES_LENGTH]; | 251 | unsigned char data[GC_SNESMOUSE_LENGTH]; |
246 | struct input_dev *dev; | 252 | struct input_dev *dev; |
247 | int i, j, s; | 253 | int i, j, s, len; |
254 | char x_rel, y_rel; | ||
255 | |||
256 | len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : | ||
257 | (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); | ||
248 | 258 | ||
249 | gc_nes_read_packet(gc, gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH, data); | 259 | gc_nes_read_packet(gc, len, data); |
250 | 260 | ||
251 | for (i = 0; i < GC_MAX_DEVICES; i++) { | 261 | for (i = 0; i < GC_MAX_DEVICES; i++) { |
252 | 262 | ||
@@ -269,6 +279,44 @@ static void gc_nes_process_packet(struct gc *gc) | |||
269 | for (j = 0; j < 8; j++) | 279 | for (j = 0; j < 8; j++) |
270 | input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); | 280 | input_report_key(dev, gc_snes_btn[j], s & data[gc_snes_bytes[j]]); |
271 | 281 | ||
282 | if (s & gc->pads[GC_SNESMOUSE]) { | ||
283 | /* | ||
284 | * The 4 unused bits from SNES controllers appear to be ID bits | ||
285 | * so use them to make sure iwe are dealing with a mouse. | ||
286 | * gamepad is connected. This is important since | ||
287 | * my SNES gamepad sends 1's for bits 16-31, which | ||
288 | * cause the mouse pointer to quickly move to the | ||
289 | * upper left corner of the screen. | ||
290 | */ | ||
291 | if (!(s & data[12]) && !(s & data[13]) && | ||
292 | !(s & data[14]) && (s & data[15])) { | ||
293 | input_report_key(dev, BTN_LEFT, s & data[9]); | ||
294 | input_report_key(dev, BTN_RIGHT, s & data[8]); | ||
295 | |||
296 | x_rel = y_rel = 0; | ||
297 | for (j = 0; j < 7; j++) { | ||
298 | x_rel <<= 1; | ||
299 | if (data[25 + j] & s) | ||
300 | x_rel |= 1; | ||
301 | |||
302 | y_rel <<= 1; | ||
303 | if (data[17 + j] & s) | ||
304 | y_rel |= 1; | ||
305 | } | ||
306 | |||
307 | if (x_rel) { | ||
308 | if (data[24] & s) | ||
309 | x_rel = -x_rel; | ||
310 | input_report_rel(dev, REL_X, x_rel); | ||
311 | } | ||
312 | |||
313 | if (y_rel) { | ||
314 | if (data[16] & s) | ||
315 | y_rel = -y_rel; | ||
316 | input_report_rel(dev, REL_Y, y_rel); | ||
317 | } | ||
318 | } | ||
319 | } | ||
272 | input_sync(dev); | 320 | input_sync(dev); |
273 | } | 321 | } |
274 | } | 322 | } |
@@ -524,10 +572,10 @@ static void gc_timer(unsigned long private) | |||
524 | gc_n64_process_packet(gc); | 572 | gc_n64_process_packet(gc); |
525 | 573 | ||
526 | /* | 574 | /* |
527 | * NES and SNES pads | 575 | * NES and SNES pads or mouse |
528 | */ | 576 | */ |
529 | 577 | ||
530 | if (gc->pads[GC_NES] || gc->pads[GC_SNES]) | 578 | if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE]) |
531 | gc_nes_process_packet(gc); | 579 | gc_nes_process_packet(gc); |
532 | 580 | ||
533 | /* | 581 | /* |
@@ -552,7 +600,7 @@ static int gc_open(struct input_dev *dev) | |||
552 | struct gc *gc = dev->private; | 600 | struct gc *gc = dev->private; |
553 | int err; | 601 | int err; |
554 | 602 | ||
555 | err = down_interruptible(&gc->sem); | 603 | err = mutex_lock_interruptible(&gc->mutex); |
556 | if (err) | 604 | if (err) |
557 | return err; | 605 | return err; |
558 | 606 | ||
@@ -562,7 +610,7 @@ static int gc_open(struct input_dev *dev) | |||
562 | mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); | 610 | mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); |
563 | } | 611 | } |
564 | 612 | ||
565 | up(&gc->sem); | 613 | mutex_unlock(&gc->mutex); |
566 | return 0; | 614 | return 0; |
567 | } | 615 | } |
568 | 616 | ||
@@ -570,13 +618,13 @@ static void gc_close(struct input_dev *dev) | |||
570 | { | 618 | { |
571 | struct gc *gc = dev->private; | 619 | struct gc *gc = dev->private; |
572 | 620 | ||
573 | down(&gc->sem); | 621 | mutex_lock(&gc->mutex); |
574 | if (!--gc->used) { | 622 | if (!--gc->used) { |
575 | del_timer_sync(&gc->timer); | 623 | del_timer_sync(&gc->timer); |
576 | parport_write_control(gc->pd->port, 0x00); | 624 | parport_write_control(gc->pd->port, 0x00); |
577 | parport_release(gc->pd); | 625 | parport_release(gc->pd); |
578 | } | 626 | } |
579 | up(&gc->sem); | 627 | mutex_unlock(&gc->mutex); |
580 | } | 628 | } |
581 | 629 | ||
582 | static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) | 630 | static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) |
@@ -609,10 +657,13 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) | |||
609 | input_dev->open = gc_open; | 657 | input_dev->open = gc_open; |
610 | input_dev->close = gc_close; | 658 | input_dev->close = gc_close; |
611 | 659 | ||
612 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 660 | if (pad_type != GC_SNESMOUSE) { |
661 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
613 | 662 | ||
614 | for (i = 0; i < 2; i++) | 663 | for (i = 0; i < 2; i++) |
615 | input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); | 664 | input_set_abs_params(input_dev, ABS_X + i, -1, 1, 0, 0); |
665 | } else | ||
666 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REL); | ||
616 | 667 | ||
617 | gc->pads[0] |= gc_status_bit[idx]; | 668 | gc->pads[0] |= gc_status_bit[idx]; |
618 | gc->pads[pad_type] |= gc_status_bit[idx]; | 669 | gc->pads[pad_type] |= gc_status_bit[idx]; |
@@ -630,6 +681,13 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) | |||
630 | 681 | ||
631 | break; | 682 | break; |
632 | 683 | ||
684 | case GC_SNESMOUSE: | ||
685 | set_bit(BTN_LEFT, input_dev->keybit); | ||
686 | set_bit(BTN_RIGHT, input_dev->keybit); | ||
687 | set_bit(REL_X, input_dev->relbit); | ||
688 | set_bit(REL_Y, input_dev->relbit); | ||
689 | break; | ||
690 | |||
633 | case GC_SNES: | 691 | case GC_SNES: |
634 | for (i = 4; i < 8; i++) | 692 | for (i = 4; i < 8; i++) |
635 | set_bit(gc_snes_btn[i], input_dev->keybit); | 693 | set_bit(gc_snes_btn[i], input_dev->keybit); |
@@ -693,7 +751,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads) | |||
693 | goto err_unreg_pardev; | 751 | goto err_unreg_pardev; |
694 | } | 752 | } |
695 | 753 | ||
696 | init_MUTEX(&gc->sem); | 754 | mutex_init(&gc->mutex); |
697 | gc->pd = pd; | 755 | gc->pd = pd; |
698 | init_timer(&gc->timer); | 756 | init_timer(&gc->timer); |
699 | gc->timer.data = (long) gc; | 757 | gc->timer.data = (long) gc; |
diff --git a/drivers/input/joystick/iforce/iforce-ff.c b/drivers/input/joystick/iforce/iforce-ff.c index 4678b6dab43b..2b8e8456c9fa 100644 --- a/drivers/input/joystick/iforce/iforce-ff.c +++ b/drivers/input/joystick/iforce/iforce-ff.c | |||
@@ -42,14 +42,14 @@ static int make_magnitude_modifier(struct iforce* iforce, | |||
42 | unsigned char data[3]; | 42 | unsigned char data[3]; |
43 | 43 | ||
44 | if (!no_alloc) { | 44 | if (!no_alloc) { |
45 | down(&iforce->mem_mutex); | 45 | mutex_lock(&iforce->mem_mutex); |
46 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 2, | 46 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 2, |
47 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 47 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
48 | NULL, NULL)) { | 48 | NULL, NULL)) { |
49 | up(&iforce->mem_mutex); | 49 | mutex_unlock(&iforce->mem_mutex); |
50 | return -ENOMEM; | 50 | return -ENOMEM; |
51 | } | 51 | } |
52 | up(&iforce->mem_mutex); | 52 | mutex_unlock(&iforce->mem_mutex); |
53 | } | 53 | } |
54 | 54 | ||
55 | data[0] = LO(mod_chunk->start); | 55 | data[0] = LO(mod_chunk->start); |
@@ -75,14 +75,14 @@ static int make_period_modifier(struct iforce* iforce, | |||
75 | period = TIME_SCALE(period); | 75 | period = TIME_SCALE(period); |
76 | 76 | ||
77 | if (!no_alloc) { | 77 | if (!no_alloc) { |
78 | down(&iforce->mem_mutex); | 78 | mutex_lock(&iforce->mem_mutex); |
79 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c, | 79 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0c, |
80 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 80 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
81 | NULL, NULL)) { | 81 | NULL, NULL)) { |
82 | up(&iforce->mem_mutex); | 82 | mutex_unlock(&iforce->mem_mutex); |
83 | return -ENOMEM; | 83 | return -ENOMEM; |
84 | } | 84 | } |
85 | up(&iforce->mem_mutex); | 85 | mutex_unlock(&iforce->mem_mutex); |
86 | } | 86 | } |
87 | 87 | ||
88 | data[0] = LO(mod_chunk->start); | 88 | data[0] = LO(mod_chunk->start); |
@@ -115,14 +115,14 @@ static int make_envelope_modifier(struct iforce* iforce, | |||
115 | fade_duration = TIME_SCALE(fade_duration); | 115 | fade_duration = TIME_SCALE(fade_duration); |
116 | 116 | ||
117 | if (!no_alloc) { | 117 | if (!no_alloc) { |
118 | down(&iforce->mem_mutex); | 118 | mutex_lock(&iforce->mem_mutex); |
119 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e, | 119 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 0x0e, |
120 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 120 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
121 | NULL, NULL)) { | 121 | NULL, NULL)) { |
122 | up(&iforce->mem_mutex); | 122 | mutex_unlock(&iforce->mem_mutex); |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | } | 124 | } |
125 | up(&iforce->mem_mutex); | 125 | mutex_unlock(&iforce->mem_mutex); |
126 | } | 126 | } |
127 | 127 | ||
128 | data[0] = LO(mod_chunk->start); | 128 | data[0] = LO(mod_chunk->start); |
@@ -152,14 +152,14 @@ static int make_condition_modifier(struct iforce* iforce, | |||
152 | unsigned char data[10]; | 152 | unsigned char data[10]; |
153 | 153 | ||
154 | if (!no_alloc) { | 154 | if (!no_alloc) { |
155 | down(&iforce->mem_mutex); | 155 | mutex_lock(&iforce->mem_mutex); |
156 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 8, | 156 | if (allocate_resource(&(iforce->device_memory), mod_chunk, 8, |
157 | iforce->device_memory.start, iforce->device_memory.end, 2L, | 157 | iforce->device_memory.start, iforce->device_memory.end, 2L, |
158 | NULL, NULL)) { | 158 | NULL, NULL)) { |
159 | up(&iforce->mem_mutex); | 159 | mutex_unlock(&iforce->mem_mutex); |
160 | return -ENOMEM; | 160 | return -ENOMEM; |
161 | } | 161 | } |
162 | up(&iforce->mem_mutex); | 162 | mutex_unlock(&iforce->mem_mutex); |
163 | } | 163 | } |
164 | 164 | ||
165 | data[0] = LO(mod_chunk->start); | 165 | data[0] = LO(mod_chunk->start); |
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c index b6bc04998047..ab0a26b924ca 100644 --- a/drivers/input/joystick/iforce/iforce-main.c +++ b/drivers/input/joystick/iforce/iforce-main.c | |||
@@ -350,7 +350,7 @@ int iforce_init_device(struct iforce *iforce) | |||
350 | 350 | ||
351 | init_waitqueue_head(&iforce->wait); | 351 | init_waitqueue_head(&iforce->wait); |
352 | spin_lock_init(&iforce->xmit_lock); | 352 | spin_lock_init(&iforce->xmit_lock); |
353 | init_MUTEX(&iforce->mem_mutex); | 353 | mutex_init(&iforce->mem_mutex); |
354 | iforce->xmit.buf = iforce->xmit_data; | 354 | iforce->xmit.buf = iforce->xmit_data; |
355 | iforce->dev = input_dev; | 355 | iforce->dev = input_dev; |
356 | 356 | ||
diff --git a/drivers/input/joystick/iforce/iforce.h b/drivers/input/joystick/iforce/iforce.h index 146f406b8f8a..668f24535ba0 100644 --- a/drivers/input/joystick/iforce/iforce.h +++ b/drivers/input/joystick/iforce/iforce.h | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/serio.h> | 37 | #include <linux/serio.h> |
38 | #include <linux/config.h> | 38 | #include <linux/config.h> |
39 | #include <linux/circ_buf.h> | 39 | #include <linux/circ_buf.h> |
40 | #include <asm/semaphore.h> | 40 | #include <linux/mutex.h> |
41 | 41 | ||
42 | /* This module provides arbitrary resource management routines. | 42 | /* This module provides arbitrary resource management routines. |
43 | * I use it to manage the device's memory. | 43 | * I use it to manage the device's memory. |
@@ -45,6 +45,7 @@ | |||
45 | */ | 45 | */ |
46 | #include <linux/ioport.h> | 46 | #include <linux/ioport.h> |
47 | 47 | ||
48 | |||
48 | #define IFORCE_MAX_LENGTH 16 | 49 | #define IFORCE_MAX_LENGTH 16 |
49 | 50 | ||
50 | /* iforce::bus */ | 51 | /* iforce::bus */ |
@@ -146,7 +147,7 @@ struct iforce { | |||
146 | wait_queue_head_t wait; | 147 | wait_queue_head_t wait; |
147 | struct resource device_memory; | 148 | struct resource device_memory; |
148 | struct iforce_core_effect core_effects[FF_EFFECTS_MAX]; | 149 | struct iforce_core_effect core_effects[FF_EFFECTS_MAX]; |
149 | struct semaphore mem_mutex; | 150 | struct mutex mem_mutex; |
150 | }; | 151 | }; |
151 | 152 | ||
152 | /* Get hi and low bytes of a 16-bits int */ | 153 | /* Get hi and low bytes of a 16-bits int */ |
diff --git a/drivers/input/joystick/turbografx.c b/drivers/input/joystick/turbografx.c index b154938e88a4..5570fd5487c7 100644 --- a/drivers/input/joystick/turbografx.c +++ b/drivers/input/joystick/turbografx.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/moduleparam.h> | 38 | #include <linux/moduleparam.h> |
39 | #include <linux/init.h> | 39 | #include <linux/init.h> |
40 | #include <linux/mutex.h> | ||
40 | 41 | ||
41 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); | 42 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>"); |
42 | MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); | 43 | MODULE_DESCRIPTION("TurboGraFX parallel port interface driver"); |
@@ -86,7 +87,7 @@ static struct tgfx { | |||
86 | char phys[TGFX_MAX_DEVICES][32]; | 87 | char phys[TGFX_MAX_DEVICES][32]; |
87 | int sticks; | 88 | int sticks; |
88 | int used; | 89 | int used; |
89 | struct semaphore sem; | 90 | struct mutex sem; |
90 | } *tgfx_base[TGFX_MAX_PORTS]; | 91 | } *tgfx_base[TGFX_MAX_PORTS]; |
91 | 92 | ||
92 | /* | 93 | /* |
@@ -128,7 +129,7 @@ static int tgfx_open(struct input_dev *dev) | |||
128 | struct tgfx *tgfx = dev->private; | 129 | struct tgfx *tgfx = dev->private; |
129 | int err; | 130 | int err; |
130 | 131 | ||
131 | err = down_interruptible(&tgfx->sem); | 132 | err = mutex_lock_interruptible(&tgfx->sem); |
132 | if (err) | 133 | if (err) |
133 | return err; | 134 | return err; |
134 | 135 | ||
@@ -138,7 +139,7 @@ static int tgfx_open(struct input_dev *dev) | |||
138 | mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); | 139 | mod_timer(&tgfx->timer, jiffies + TGFX_REFRESH_TIME); |
139 | } | 140 | } |
140 | 141 | ||
141 | up(&tgfx->sem); | 142 | mutex_unlock(&tgfx->sem); |
142 | return 0; | 143 | return 0; |
143 | } | 144 | } |
144 | 145 | ||
@@ -146,13 +147,13 @@ static void tgfx_close(struct input_dev *dev) | |||
146 | { | 147 | { |
147 | struct tgfx *tgfx = dev->private; | 148 | struct tgfx *tgfx = dev->private; |
148 | 149 | ||
149 | down(&tgfx->sem); | 150 | mutex_lock(&tgfx->sem); |
150 | if (!--tgfx->used) { | 151 | if (!--tgfx->used) { |
151 | del_timer_sync(&tgfx->timer); | 152 | del_timer_sync(&tgfx->timer); |
152 | parport_write_control(tgfx->pd->port, 0x00); | 153 | parport_write_control(tgfx->pd->port, 0x00); |
153 | parport_release(tgfx->pd); | 154 | parport_release(tgfx->pd); |
154 | } | 155 | } |
155 | up(&tgfx->sem); | 156 | mutex_unlock(&tgfx->sem); |
156 | } | 157 | } |
157 | 158 | ||
158 | 159 | ||
@@ -191,7 +192,7 @@ static struct tgfx __init *tgfx_probe(int parport, int *n_buttons, int n_devs) | |||
191 | goto err_unreg_pardev; | 192 | goto err_unreg_pardev; |
192 | } | 193 | } |
193 | 194 | ||
194 | init_MUTEX(&tgfx->sem); | 195 | mutex_init(&tgfx->sem); |
195 | tgfx->pd = pd; | 196 | tgfx->pd = pd; |
196 | init_timer(&tgfx->timer); | 197 | init_timer(&tgfx->timer); |
197 | tgfx->timer.data = (long) tgfx; | 198 | tgfx->timer.data = (long) tgfx; |