aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/joystick/gamecon.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2010-02-21 23:54:54 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-02-22 01:10:01 -0500
commit0995174dda3e97d70fd9c335c55041b6b5aa11dd (patch)
tree6915fcaaea6f3f30994c82830d207fbc9cd77b3a /drivers/input/joystick/gamecon.c
parent315543fd112ae3b573bc44e7dbfef99c11714610 (diff)
Input: gamecon - simplify pad type handling
Instead of having array bitmasks by type for all gamepads have explicit type field in every pad structure. Tested-by: Scott Moreau <oreaus@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/joystick/gamecon.c')
-rw-r--r--drivers/input/joystick/gamecon.c202
1 files changed, 123 insertions, 79 deletions
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c
index d57edd4a5992..e9c6647e1f74 100644
--- a/drivers/input/joystick/gamecon.c
+++ b/drivers/input/joystick/gamecon.c
@@ -61,28 +61,36 @@ MODULE_PARM_DESC(map3, "Describes third set of devices");
61 61
62/* see also gs_psx_delay parameter in PSX support section */ 62/* see also gs_psx_delay parameter in PSX support section */
63 63
64#define GC_SNES 1 64enum gc_type {
65#define GC_NES 2 65 GC_NONE = 0,
66#define GC_NES4 3 66 GC_SNES,
67#define GC_MULTI 4 67 GC_NES,
68#define GC_MULTI2 5 68 GC_NES4,
69#define GC_N64 6 69 GC_MULTI,
70#define GC_PSX 7 70 GC_MULTI2,
71#define GC_DDR 8 71 GC_N64,
72#define GC_SNESMOUSE 9 72 GC_PSX,
73 73 GC_DDR,
74#define GC_MAX 9 74 GC_SNESMOUSE,
75 GC_MAX
76};
75 77
76#define GC_REFRESH_TIME HZ/100 78#define GC_REFRESH_TIME HZ/100
77 79
80struct gc_pad {
81 struct input_dev *dev;
82 enum gc_type type;
83 char phys[32];
84};
85
78struct gc { 86struct gc {
79 struct pardevice *pd; 87 struct pardevice *pd;
88 struct gc_pad pads[GC_MAX_DEVICES];
80 struct input_dev *dev[GC_MAX_DEVICES]; 89 struct input_dev *dev[GC_MAX_DEVICES];
81 struct timer_list timer; 90 struct timer_list timer;
82 unsigned char pads[GC_MAX + 1]; 91 int pad_count[GC_MAX];
83 int used; 92 int used;
84 struct mutex mutex; 93 struct mutex mutex;
85 char phys[GC_MAX_DEVICES][32];
86}; 94};
87 95
88struct gc_subdev { 96struct gc_subdev {
@@ -218,13 +226,13 @@ static void gc_n64_process_packet(struct gc *gc)
218 226
219 for (i = 0; i < GC_MAX_DEVICES; i++) { 227 for (i = 0; i < GC_MAX_DEVICES; i++) {
220 228
221 dev = gc->dev[i]; 229 if (gc->pads[i].type != GC_N64)
222 if (!dev)
223 continue; 230 continue;
224 231
232 dev = gc->pads[i].dev;
225 s = gc_status_bit[i]; 233 s = gc_status_bit[i];
226 234
227 if (s & gc->pads[GC_N64] & ~(data[8] | data[9])) { 235 if (s & ~(data[8] | data[9])) {
228 236
229 x = y = 0; 237 x = y = 0;
230 238
@@ -363,39 +371,47 @@ static void gc_nes_read_packet(struct gc *gc, int length, unsigned char *data)
363static void gc_nes_process_packet(struct gc *gc) 371static void gc_nes_process_packet(struct gc *gc)
364{ 372{
365 unsigned char data[GC_SNESMOUSE_LENGTH]; 373 unsigned char data[GC_SNESMOUSE_LENGTH];
374 struct gc_pad *pad;
366 struct input_dev *dev; 375 struct input_dev *dev;
367 int i, j, s, len; 376 int i, j, s, len;
368 char x_rel, y_rel; 377 char x_rel, y_rel;
369 378
370 len = gc->pads[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH : 379 len = gc->pad_count[GC_SNESMOUSE] ? GC_SNESMOUSE_LENGTH :
371 (gc->pads[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH); 380 (gc->pad_count[GC_SNES] ? GC_SNES_LENGTH : GC_NES_LENGTH);
372 381
373 gc_nes_read_packet(gc, len, data); 382 gc_nes_read_packet(gc, len, data);
374 383
375 for (i = 0; i < GC_MAX_DEVICES; i++) { 384 for (i = 0; i < GC_MAX_DEVICES; i++) {
376 385
386 pad = &gc->pads[i];
377 dev = gc->dev[i]; 387 dev = gc->dev[i];
378 if (!dev)
379 continue;
380
381 s = gc_status_bit[i]; 388 s = gc_status_bit[i];
382 389
383 if (s & (gc->pads[GC_NES] | gc->pads[GC_SNES])) { 390 switch (pad->type) {
391
392 case GC_NES:
393
384 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7])); 394 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
385 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5])); 395 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
386 }
387 396
388 if (s & gc->pads[GC_NES])
389 for (j = 0; j < 4; j++) 397 for (j = 0; j < 4; j++)
390 input_report_key(dev, gc_snes_btn[j], 398 input_report_key(dev, gc_snes_btn[j],
391 s & data[gc_nes_bytes[j]]); 399 s & data[gc_nes_bytes[j]]);
400 input_sync(dev);
401 break;
402
403 case GC_SNES:
404
405 input_report_abs(dev, ABS_X, !(s & data[6]) - !(s & data[7]));
406 input_report_abs(dev, ABS_Y, !(s & data[4]) - !(s & data[5]));
392 407
393 if (s & gc->pads[GC_SNES])
394 for (j = 0; j < 8; j++) 408 for (j = 0; j < 8; j++)
395 input_report_key(dev, gc_snes_btn[j], 409 input_report_key(dev, gc_snes_btn[j],
396 s & data[gc_snes_bytes[j]]); 410 s & data[gc_snes_bytes[j]]);
411 input_sync(dev);
412 break;
397 413
398 if (s & gc->pads[GC_SNESMOUSE]) { 414 case GC_SNESMOUSE:
399 /* 415 /*
400 * The 4 unused bits from SNES controllers appear 416 * The 4 unused bits from SNES controllers appear
401 * to be ID bits so use them to make sure we are 417 * to be ID bits so use them to make sure we are
@@ -432,9 +448,14 @@ static void gc_nes_process_packet(struct gc *gc)
432 y_rel = -y_rel; 448 y_rel = -y_rel;
433 input_report_rel(dev, REL_Y, y_rel); 449 input_report_rel(dev, REL_Y, y_rel);
434 } 450 }
451
452 input_sync(dev);
435 } 453 }
454 break;
455
456 default:
457 break;
436 } 458 }
437 input_sync(dev);
438 } 459 }
439} 460}
440 461
@@ -462,32 +483,35 @@ static void gc_multi_read_packet(struct gc *gc, int length, unsigned char *data)
462static void gc_multi_process_packet(struct gc *gc) 483static void gc_multi_process_packet(struct gc *gc)
463{ 484{
464 unsigned char data[GC_MULTI2_LENGTH]; 485 unsigned char data[GC_MULTI2_LENGTH];
465 int data_len = gc->pads[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH; 486 int data_len = gc->pad_count[GC_MULTI2] ? GC_MULTI2_LENGTH : GC_MULTI_LENGTH;
487 struct gc_pad *pad;
466 struct input_dev *dev; 488 struct input_dev *dev;
467 int i, s; 489 int i, s;
468 490
469 gc_multi_read_packet(gc, data_len, data); 491 gc_multi_read_packet(gc, data_len, data);
470 492
471 for (i = 0; i < GC_MAX_DEVICES; i++) { 493 for (i = 0; i < GC_MAX_DEVICES; i++) {
472 494 pad = &gc->pads[i];
473 dev = gc->dev[i]; 495 dev = pad->dev;
474 if (!dev)
475 continue;
476
477 s = gc_status_bit[i]; 496 s = gc_status_bit[i];
478 497
479 if (s & (gc->pads[GC_MULTI] | gc->pads[GC_MULTI2])) { 498 switch (pad->type) {
499 case GC_MULTI2:
500 input_report_key(dev, BTN_THUMB, s & data[5]);
501 /* fall through */
502
503 case GC_MULTI:
480 input_report_abs(dev, ABS_X, 504 input_report_abs(dev, ABS_X,
481 !(s & data[2]) - !(s & data[3])); 505 !(s & data[2]) - !(s & data[3]));
482 input_report_abs(dev, ABS_Y, 506 input_report_abs(dev, ABS_Y,
483 !(s & data[0]) - !(s & data[1])); 507 !(s & data[0]) - !(s & data[1]));
484 input_report_key(dev, BTN_TRIGGER, s & data[4]); 508 input_report_key(dev, BTN_TRIGGER, s & data[4]);
485 } 509 input_sync(dev);
486 510 break;
487 if (s & gc->pads[GC_MULTI2])
488 input_report_key(dev, BTN_THUMB, s & data[5]);
489 511
490 input_sync(dev); 512 default:
513 break;
514 }
491 } 515 }
492} 516}
493 517
@@ -548,9 +572,16 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char *data)
548 cmd = (b & 1) ? GC_PSX_COMMAND : 0; 572 cmd = (b & 1) ? GC_PSX_COMMAND : 0;
549 parport_write_data(port, cmd | GC_PSX_POWER); 573 parport_write_data(port, cmd | GC_PSX_POWER);
550 udelay(gc_psx_delay); 574 udelay(gc_psx_delay);
575
551 read = parport_read_status(port) ^ 0x80; 576 read = parport_read_status(port) ^ 0x80;
552 for (j = 0; j < GC_MAX_DEVICES; j++) 577
553 data[j] |= (read & gc_status_bit[j] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) ? (1 << i) : 0; 578 for (j = 0; j < GC_MAX_DEVICES; j++) {
579 struct gc_pad *pad = &gc->pads[i];
580
581 if (pad->type == GC_PSX || pad->type == GC_DDR)
582 data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0;
583 }
584
554 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER); 585 parport_write_data(gc->pd->port, cmd | GC_PSX_CLOCK | GC_PSX_POWER);
555 udelay(gc_psx_delay); 586 udelay(gc_psx_delay);
556 } 587 }
@@ -561,7 +592,8 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char *data)
561 * device identifier code. 592 * device identifier code.
562 */ 593 */
563 594
564static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES], 595static void gc_psx_read_packet(struct gc *gc,
596 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES],
565 unsigned char id[GC_MAX_DEVICES]) 597 unsigned char id[GC_MAX_DEVICES])
566{ 598{
567 int i, j, max_len = 0; 599 int i, j, max_len = 0;
@@ -582,12 +614,15 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES]
582 gc_psx_command(gc, 0, data2); /* Dump status */ 614 gc_psx_command(gc, 0, data2); /* Dump status */
583 615
584 /* Find the longest pad */ 616 /* Find the longest pad */
585 for (i = 0; i < GC_MAX_DEVICES; i++) 617 for (i = 0; i < GC_MAX_DEVICES; i++) {
586 if ((gc_status_bit[i] & (gc->pads[GC_PSX] | gc->pads[GC_DDR])) && 618 struct gc_pad *pad = &gc->pads[i];
619
620 if ((pad->type == GC_PSX || pad->type == GC_DDR) &&
587 GC_PSX_LEN(id[i]) > max_len && 621 GC_PSX_LEN(id[i]) > max_len &&
588 GC_PSX_LEN(id[i]) <= GC_PSX_BYTES) { 622 GC_PSX_LEN(id[i]) <= GC_PSX_BYTES) {
589 max_len = GC_PSX_LEN(id[i]); 623 max_len = GC_PSX_LEN(id[i]);
590 } 624 }
625 }
591 626
592 /* Read in all the data */ 627 /* Read in all the data */
593 for (i = 0; i < max_len; i++) { 628 for (i = 0; i < max_len; i++) {
@@ -605,13 +640,13 @@ static void gc_psx_read_packet(struct gc *gc, unsigned char data[GC_MAX_DEVICES]
605 id[i] = GC_PSX_ID(id[i]); 640 id[i] = GC_PSX_ID(id[i]);
606} 641}
607 642
608static void gc_psx_report_one(struct gc *gc, struct input_dev *dev, 643static void gc_psx_report_one(struct gc_pad *pad, unsigned char psx_type,
609 unsigned char pad_type, unsigned char status_bit,
610 unsigned char *data) 644 unsigned char *data)
611{ 645{
646 struct input_dev *dev = pad->dev;
612 int i; 647 int i;
613 648
614 switch (pad_type) { 649 switch (psx_type) {
615 650
616 case GC_PSX_RUMBLE: 651 case GC_PSX_RUMBLE:
617 652
@@ -621,7 +656,7 @@ static void gc_psx_report_one(struct gc *gc, struct input_dev *dev,
621 case GC_PSX_NEGCON: 656 case GC_PSX_NEGCON:
622 case GC_PSX_ANALOG: 657 case GC_PSX_ANALOG:
623 658
624 if (gc->pads[GC_DDR] & status_bit) { 659 if (pad->type == GC_DDR) {
625 for (i = 0; i < 4; i++) 660 for (i = 0; i < 4; i++)
626 input_report_key(dev, gc_psx_ddr_btn[i], 661 input_report_key(dev, gc_psx_ddr_btn[i],
627 ~data[0] & (0x10 << i)); 662 ~data[0] & (0x10 << i));
@@ -647,7 +682,8 @@ static void gc_psx_report_one(struct gc *gc, struct input_dev *dev,
647 break; 682 break;
648 683
649 case GC_PSX_NORMAL: 684 case GC_PSX_NORMAL:
650 if (gc->pads[GC_DDR] & status_bit) { 685
686 if (pad->type == GC_DDR) {
651 for (i = 0; i < 4; i++) 687 for (i = 0; i < 4; i++)
652 input_report_key(dev, gc_psx_ddr_btn[i], 688 input_report_key(dev, gc_psx_ddr_btn[i],
653 ~data[0] & (0x10 << i)); 689 ~data[0] & (0x10 << i));
@@ -679,7 +715,7 @@ static void gc_psx_report_one(struct gc *gc, struct input_dev *dev,
679 715
680 break; 716 break;
681 717
682 case 0: /* not a pad, ignore */ 718 default: /* not a pad, ignore */
683 break; 719 break;
684 } 720 }
685} 721}
@@ -688,15 +724,15 @@ static void gc_psx_process_packet(struct gc *gc)
688{ 724{
689 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES]; 725 unsigned char data[GC_MAX_DEVICES][GC_PSX_BYTES];
690 unsigned char id[GC_MAX_DEVICES]; 726 unsigned char id[GC_MAX_DEVICES];
727 struct gc_pad *pad;
691 int i; 728 int i;
692 729
693 gc_psx_read_packet(gc, data, id); 730 gc_psx_read_packet(gc, data, id);
694 731
695 for (i = 0; i < GC_MAX_DEVICES; i++) { 732 for (i = 0; i < GC_MAX_DEVICES; i++) {
696 733 pad = &gc->pads[i];
697 if (gc->dev[i]) 734 if (pad->type == GC_PSX || pad->type == GC_DDR)
698 gc_psx_report_one(gc, gc->dev[i], 735 gc_psx_report_one(pad, id[i], data[i]);
699 id[i], gc_status_bit[i], data[i]);
700 } 736 }
701} 737}
702 738
@@ -712,28 +748,31 @@ static void gc_timer(unsigned long private)
712 * N64 pads - must be read first, any read confuses them for 200 us 748 * N64 pads - must be read first, any read confuses them for 200 us
713 */ 749 */
714 750
715 if (gc->pads[GC_N64]) 751 if (gc->pad_count[GC_N64])
716 gc_n64_process_packet(gc); 752 gc_n64_process_packet(gc);
717 753
718/* 754/*
719 * NES and SNES pads or mouse 755 * NES and SNES pads or mouse
720 */ 756 */
721 757
722 if (gc->pads[GC_NES] || gc->pads[GC_SNES] || gc->pads[GC_SNESMOUSE]) 758 if (gc->pad_count[GC_NES] ||
759 gc->pad_count[GC_SNES] ||
760 gc->pad_count[GC_SNESMOUSE]) {
723 gc_nes_process_packet(gc); 761 gc_nes_process_packet(gc);
762 }
724 763
725/* 764/*
726 * Multi and Multi2 joysticks 765 * Multi and Multi2 joysticks
727 */ 766 */
728 767
729 if (gc->pads[GC_MULTI] || gc->pads[GC_MULTI2]) 768 if (gc->pad_count[GC_MULTI] || gc->pad_count[GC_MULTI2])
730 gc_multi_process_packet(gc); 769 gc_multi_process_packet(gc);
731 770
732/* 771/*
733 * PSX controllers 772 * PSX controllers
734 */ 773 */
735 774
736 if (gc->pads[GC_PSX] || gc->pads[GC_DDR]) 775 if (gc->pad_count[GC_PSX] || gc->pad_count[GC_DDR])
737 gc_psx_process_packet(gc); 776 gc_psx_process_packet(gc);
738 777
739 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME); 778 mod_timer(&gc->timer, jiffies + GC_REFRESH_TIME);
@@ -773,26 +812,29 @@ static void gc_close(struct input_dev *dev)
773 812
774static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type) 813static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
775{ 814{
815 struct gc_pad *pad = &gc->pads[idx];
776 struct input_dev *input_dev; 816 struct input_dev *input_dev;
777 int i; 817 int i;
778 int err; 818 int err;
779 819
780 if (!pad_type)
781 return 0;
782
783 if (pad_type < 1 || pad_type > GC_MAX) { 820 if (pad_type < 1 || pad_type > GC_MAX) {
784 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type); 821 printk(KERN_WARNING "gamecon.c: Pad type %d unknown\n", pad_type);
785 return -EINVAL; 822 return -EINVAL;
786 } 823 }
787 824
788 gc->dev[idx] = input_dev = input_allocate_device(); 825 pad->dev = input_dev = input_allocate_device();
789 if (!input_dev) { 826 if (!input_dev) {
790 printk(KERN_ERR "gamecon.c: Not enough memory for input device\n"); 827 printk(KERN_ERR "gamecon.c: Not enough memory for input device\n");
791 return -ENOMEM; 828 return -ENOMEM;
792 } 829 }
793 830
831 pad->type = pad_type;
832
833 snprintf(pad->phys, sizeof(pad->phys),
834 "%s/input%d", gc->pd->port->name, idx);
835
794 input_dev->name = gc_names[pad_type]; 836 input_dev->name = gc_names[pad_type];
795 input_dev->phys = gc->phys[idx]; 837 input_dev->phys = pad->phys;
796 input_dev->id.bustype = BUS_PARPORT; 838 input_dev->id.bustype = BUS_PARPORT;
797 input_dev->id.vendor = 0x0001; 839 input_dev->id.vendor = 0x0001;
798 input_dev->id.product = pad_type; 840 input_dev->id.product = pad_type;
@@ -811,8 +853,7 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
811 } else 853 } else
812 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); 854 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL);
813 855
814 gc->pads[0] |= gc_status_bit[idx]; 856 gc->pad_count[pad_type]++;
815 gc->pads[pad_type] |= gc_status_bit[idx];
816 857
817 switch (pad_type) { 858 switch (pad_type) {
818 859
@@ -828,8 +869,7 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
828 err = gc_n64_init_ff(input_dev, idx); 869 err = gc_n64_init_ff(input_dev, idx);
829 if (err) { 870 if (err) {
830 printk(KERN_WARNING "gamecon.c: Failed to initiate rumble for N64 device %d\n", idx); 871 printk(KERN_WARNING "gamecon.c: Failed to initiate rumble for N64 device %d\n", idx);
831 input_free_device(input_dev); 872 goto err_free_dev;
832 return err;
833 } 873 }
834 874
835 break; 875 break;
@@ -873,7 +913,16 @@ static int __init gc_setup_pad(struct gc *gc, int idx, int pad_type)
873 break; 913 break;
874 } 914 }
875 915
916 err = input_register_device(pad->dev);
917 if (err)
918 goto err_free_dev;
919
876 return 0; 920 return 0;
921
922err_free_dev:
923 input_free_device(pad->dev);
924 pad->dev = NULL;
925 return err;
877} 926}
878 927
879static struct gc __init *gc_probe(int parport, int *pads, int n_pads) 928static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
@@ -882,6 +931,7 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
882 struct parport *pp; 931 struct parport *pp;
883 struct pardevice *pd; 932 struct pardevice *pd;
884 int i; 933 int i;
934 int count = 0;
885 int err; 935 int err;
886 936
887 pp = parport_find_number(parport); 937 pp = parport_find_number(parport);
@@ -913,18 +963,14 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
913 if (!pads[i]) 963 if (!pads[i])
914 continue; 964 continue;
915 965
916 snprintf(gc->phys[i], sizeof(gc->phys[i]),
917 "%s/input%d", gc->pd->port->name, i);
918 err = gc_setup_pad(gc, i, pads[i]); 966 err = gc_setup_pad(gc, i, pads[i]);
919 if (err) 967 if (err)
920 goto err_unreg_devs; 968 goto err_unreg_devs;
921 969
922 err = input_register_device(gc->dev[i]); 970 count++;
923 if (err)
924 goto err_free_dev;
925 } 971 }
926 972
927 if (!gc->pads[0]) { 973 if (count == 0) {
928 printk(KERN_ERR "gamecon.c: No valid devices specified\n"); 974 printk(KERN_ERR "gamecon.c: No valid devices specified\n");
929 err = -EINVAL; 975 err = -EINVAL;
930 goto err_free_gc; 976 goto err_free_gc;
@@ -933,12 +979,10 @@ static struct gc __init *gc_probe(int parport, int *pads, int n_pads)
933 parport_put_port(pp); 979 parport_put_port(pp);
934 return gc; 980 return gc;
935 981
936 err_free_dev:
937 input_free_device(gc->dev[i]);
938 err_unreg_devs: 982 err_unreg_devs:
939 while (--i >= 0) 983 while (--i >= 0)
940 if (gc->dev[i]) 984 if (gc->pads[i].dev)
941 input_unregister_device(gc->dev[i]); 985 input_unregister_device(gc->pads[i].dev);
942 err_free_gc: 986 err_free_gc:
943 kfree(gc); 987 kfree(gc);
944 err_unreg_pardev: 988 err_unreg_pardev:
@@ -954,8 +998,8 @@ static void gc_remove(struct gc *gc)
954 int i; 998 int i;
955 999
956 for (i = 0; i < GC_MAX_DEVICES; i++) 1000 for (i = 0; i < GC_MAX_DEVICES; i++)
957 if (gc->dev[i]) 1001 if (gc->pads[i].dev)
958 input_unregister_device(gc->dev[i]); 1002 input_unregister_device(gc->pads[i].dev);
959 parport_unregister_device(gc->pd); 1003 parport_unregister_device(gc->pd);
960 kfree(gc); 1004 kfree(gc);
961} 1005}