aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/lkkbd.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-09-15 03:01:45 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 12:52:52 -0400
commit3c42f0c3dde8feb59fc87df45cadb847d5511c0a (patch)
treee4f9f644473c3d9c7fe78f5df68bc42c8fa5850e /drivers/input/keyboard/lkkbd.c
parent2e5b636bb5f8dacbb91d08544e2c41ebcad5dace (diff)
[PATCH] drivers/input/keyboard: convert to dynamic input_dev allocation
Input: convert drivers/input/keyboard to dynamic input_dev allocation This is required for input_dev sysfs integration Signed-off-by: Dmitry Torokhov <dtor@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/input/keyboard/lkkbd.c')
-rw-r--r--drivers/input/keyboard/lkkbd.c128
1 files changed, 64 insertions, 64 deletions
diff --git a/drivers/input/keyboard/lkkbd.c b/drivers/input/keyboard/lkkbd.c
index 098963c7cdd6..7f06780a437f 100644
--- a/drivers/input/keyboard/lkkbd.c
+++ b/drivers/input/keyboard/lkkbd.c
@@ -102,7 +102,7 @@ static int ctrlclick_volume = 100; /* % */
102module_param (ctrlclick_volume, int, 0); 102module_param (ctrlclick_volume, int, 0);
103MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%"); 103MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%");
104 104
105static int lk201_compose_is_alt = 0; 105static int lk201_compose_is_alt;
106module_param (lk201_compose_is_alt, int, 0); 106module_param (lk201_compose_is_alt, int, 0);
107MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key " 107MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key "
108 "will act as an Alt key"); 108 "will act as an Alt key");
@@ -274,7 +274,7 @@ static lk_keycode_t lkkbd_keycode[LK_NUM_KEYCODES] = {
274}; 274};
275 275
276#define CHECK_LED(LED, BITS) do { \ 276#define CHECK_LED(LED, BITS) do { \
277 if (test_bit (LED, lk->dev.led)) \ 277 if (test_bit (LED, lk->dev->led)) \
278 leds_on |= BITS; \ 278 leds_on |= BITS; \
279 else \ 279 else \
280 leds_off |= BITS; \ 280 leds_off |= BITS; \
@@ -287,7 +287,7 @@ struct lkkbd {
287 lk_keycode_t keycode[LK_NUM_KEYCODES]; 287 lk_keycode_t keycode[LK_NUM_KEYCODES];
288 int ignore_bytes; 288 int ignore_bytes;
289 unsigned char id[LK_NUM_IGNORE_BYTES]; 289 unsigned char id[LK_NUM_IGNORE_BYTES];
290 struct input_dev dev; 290 struct input_dev *dev;
291 struct serio *serio; 291 struct serio *serio;
292 struct work_struct tq; 292 struct work_struct tq;
293 char name[64]; 293 char name[64];
@@ -423,8 +423,7 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
423 DBG (KERN_INFO "Got byte 0x%02x\n", data); 423 DBG (KERN_INFO "Got byte 0x%02x\n", data);
424 424
425 if (lk->ignore_bytes > 0) { 425 if (lk->ignore_bytes > 0) {
426 DBG (KERN_INFO "Ignoring a byte on %s\n", 426 DBG (KERN_INFO "Ignoring a byte on %s\n", lk->name);
427 lk->name);
428 lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data; 427 lk->id[LK_NUM_IGNORE_BYTES - lk->ignore_bytes--] = data;
429 428
430 if (lk->ignore_bytes == 0) 429 if (lk->ignore_bytes == 0)
@@ -435,14 +434,14 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
435 434
436 switch (data) { 435 switch (data) {
437 case LK_ALL_KEYS_UP: 436 case LK_ALL_KEYS_UP:
438 input_regs (&lk->dev, regs); 437 input_regs (lk->dev, regs);
439 for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++) 438 for (i = 0; i < ARRAY_SIZE (lkkbd_keycode); i++)
440 if (lk->keycode[i] != KEY_RESERVED) 439 if (lk->keycode[i] != KEY_RESERVED)
441 input_report_key (&lk->dev, lk->keycode[i], 0); 440 input_report_key (lk->dev, lk->keycode[i], 0);
442 input_sync (&lk->dev); 441 input_sync (lk->dev);
443 break; 442 break;
444 case LK_METRONOME: 443 case LK_METRONOME:
445 DBG (KERN_INFO "Got LK_METRONOME and don't " 444 DBG (KERN_INFO "Got %#d and don't "
446 "know how to handle...\n"); 445 "know how to handle...\n");
447 break; 446 break;
448 case LK_OUTPUT_ERROR: 447 case LK_OUTPUT_ERROR:
@@ -482,12 +481,12 @@ lkkbd_interrupt (struct serio *serio, unsigned char data, unsigned int flags,
482 481
483 default: 482 default:
484 if (lk->keycode[data] != KEY_RESERVED) { 483 if (lk->keycode[data] != KEY_RESERVED) {
485 input_regs (&lk->dev, regs); 484 input_regs (lk->dev, regs);
486 if (!test_bit (lk->keycode[data], lk->dev.key)) 485 if (!test_bit (lk->keycode[data], lk->dev->key))
487 input_report_key (&lk->dev, lk->keycode[data], 1); 486 input_report_key (lk->dev, lk->keycode[data], 1);
488 else 487 else
489 input_report_key (&lk->dev, lk->keycode[data], 0); 488 input_report_key (lk->dev, lk->keycode[data], 0);
490 input_sync (&lk->dev); 489 input_sync (lk->dev);
491 } else 490 } else
492 printk (KERN_WARNING "%s: Unknown key with " 491 printk (KERN_WARNING "%s: Unknown key with "
493 "scancode 0x%02x on %s.\n", 492 "scancode 0x%02x on %s.\n",
@@ -605,7 +604,7 @@ lkkbd_reinit (void *data)
605 lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume)); 604 lk->serio->write (lk->serio, volume_to_hw (lk->bell_volume));
606 605
607 /* Enable/disable keyclick (and possibly set volume) */ 606 /* Enable/disable keyclick (and possibly set volume) */
608 if (test_bit (SND_CLICK, lk->dev.snd)) { 607 if (test_bit (SND_CLICK, lk->dev->snd)) {
609 lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK); 608 lk->serio->write (lk->serio, LK_CMD_ENABLE_KEYCLICK);
610 lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume)); 609 lk->serio->write (lk->serio, volume_to_hw (lk->keyclick_volume));
611 lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK); 610 lk->serio->write (lk->serio, LK_CMD_ENABLE_CTRCLICK);
@@ -616,7 +615,7 @@ lkkbd_reinit (void *data)
616 } 615 }
617 616
618 /* Sound the bell if needed */ 617 /* Sound the bell if needed */
619 if (test_bit (SND_BELL, lk->dev.snd)) 618 if (test_bit (SND_BELL, lk->dev->snd))
620 lk->serio->write (lk->serio, LK_CMD_SOUND_BELL); 619 lk->serio->write (lk->serio, LK_CMD_SOUND_BELL);
621} 620}
622 621
@@ -627,71 +626,70 @@ static int
627lkkbd_connect (struct serio *serio, struct serio_driver *drv) 626lkkbd_connect (struct serio *serio, struct serio_driver *drv)
628{ 627{
629 struct lkkbd *lk; 628 struct lkkbd *lk;
629 struct input_dev *input_dev;
630 int i; 630 int i;
631 int err; 631 int err;
632 632
633 if (!(lk = kmalloc (sizeof (struct lkkbd), GFP_KERNEL))) 633 lk = kzalloc (sizeof (struct lkkbd), GFP_KERNEL);
634 return -ENOMEM; 634 input_dev = input_allocate_device ();
635 635 if (!lk || !input_dev) {
636 memset (lk, 0, sizeof (struct lkkbd)); 636 err = -ENOMEM;
637 637 goto fail;
638 init_input_dev (&lk->dev); 638 }
639 set_bit (EV_KEY, lk->dev.evbit);
640 set_bit (EV_LED, lk->dev.evbit);
641 set_bit (EV_SND, lk->dev.evbit);
642 set_bit (EV_REP, lk->dev.evbit);
643 set_bit (LED_CAPSL, lk->dev.ledbit);
644 set_bit (LED_SLEEP, lk->dev.ledbit);
645 set_bit (LED_COMPOSE, lk->dev.ledbit);
646 set_bit (LED_SCROLLL, lk->dev.ledbit);
647 set_bit (SND_BELL, lk->dev.sndbit);
648 set_bit (SND_CLICK, lk->dev.sndbit);
649 639
650 lk->serio = serio; 640 lk->serio = serio;
651 641 lk->dev = input_dev;
652 INIT_WORK (&lk->tq, lkkbd_reinit, lk); 642 INIT_WORK (&lk->tq, lkkbd_reinit, lk);
653
654 lk->bell_volume = bell_volume; 643 lk->bell_volume = bell_volume;
655 lk->keyclick_volume = keyclick_volume; 644 lk->keyclick_volume = keyclick_volume;
656 lk->ctrlclick_volume = ctrlclick_volume; 645 lk->ctrlclick_volume = ctrlclick_volume;
646 memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);
657 647
658 lk->dev.keycode = lk->keycode; 648 strlcpy (lk->name, "DEC LK keyboard", sizeof(lk->name));
659 lk->dev.keycodesize = sizeof (lk_keycode_t); 649 snprintf (lk->phys, sizeof(lk->phys), "%s/input0", serio->phys);
660 lk->dev.keycodemax = LK_NUM_KEYCODES; 650
661 651 input_dev->name = lk->name;
662 lk->dev.event = lkkbd_event; 652 input_dev->phys = lk->phys;
663 lk->dev.private = lk; 653 input_dev->id.bustype = BUS_RS232;
654 input_dev->id.vendor = SERIO_LKKBD;
655 input_dev->id.product = 0;
656 input_dev->id.version = 0x0100;
657 input_dev->cdev.dev = &serio->dev;
658 input_dev->event = lkkbd_event;
659 input_dev->private = lk;
660
661 set_bit (EV_KEY, input_dev->evbit);
662 set_bit (EV_LED, input_dev->evbit);
663 set_bit (EV_SND, input_dev->evbit);
664 set_bit (EV_REP, input_dev->evbit);
665 set_bit (LED_CAPSL, input_dev->ledbit);
666 set_bit (LED_SLEEP, input_dev->ledbit);
667 set_bit (LED_COMPOSE, input_dev->ledbit);
668 set_bit (LED_SCROLLL, input_dev->ledbit);
669 set_bit (SND_BELL, input_dev->sndbit);
670 set_bit (SND_CLICK, input_dev->sndbit);
671
672 input_dev->keycode = lk->keycode;
673 input_dev->keycodesize = sizeof (lk_keycode_t);
674 input_dev->keycodemax = LK_NUM_KEYCODES;
675 for (i = 0; i < LK_NUM_KEYCODES; i++)
676 set_bit (lk->keycode[i], input_dev->keybit);
664 677
665 serio_set_drvdata (serio, lk); 678 serio_set_drvdata (serio, lk);
666 679
667 err = serio_open (serio, drv); 680 err = serio_open (serio, drv);
668 if (err) { 681 if (err)
669 serio_set_drvdata (serio, NULL); 682 goto fail;
670 kfree (lk);
671 return err;
672 }
673 683
674 sprintf (lk->name, "DEC LK keyboard"); 684 input_register_device (lk->dev);
675 sprintf (lk->phys, "%s/input0", serio->phys);
676
677 memcpy (lk->keycode, lkkbd_keycode, sizeof (lk_keycode_t) * LK_NUM_KEYCODES);
678 for (i = 0; i < LK_NUM_KEYCODES; i++)
679 set_bit (lk->keycode[i], lk->dev.keybit);
680
681 lk->dev.name = lk->name;
682 lk->dev.phys = lk->phys;
683 lk->dev.id.bustype = BUS_RS232;
684 lk->dev.id.vendor = SERIO_LKKBD;
685 lk->dev.id.product = 0;
686 lk->dev.id.version = 0x0100;
687 lk->dev.dev = &serio->dev;
688
689 input_register_device (&lk->dev);
690
691 printk (KERN_INFO "input: %s on %s, initiating reset\n", lk->name, serio->phys);
692 lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET); 685 lk->serio->write (lk->serio, LK_CMD_POWERCYCLE_RESET);
693 686
694 return 0; 687 return 0;
688
689 fail: serio_set_drvdata (serio, NULL);
690 input_free_device (input_dev);
691 kfree (lk);
692 return err;
695} 693}
696 694
697/* 695/*
@@ -702,9 +700,11 @@ lkkbd_disconnect (struct serio *serio)
702{ 700{
703 struct lkkbd *lk = serio_get_drvdata (serio); 701 struct lkkbd *lk = serio_get_drvdata (serio);
704 702
705 input_unregister_device (&lk->dev); 703 input_get_device (lk->dev);
704 input_unregister_device (lk->dev);
706 serio_close (serio); 705 serio_close (serio);
707 serio_set_drvdata (serio, NULL); 706 serio_set_drvdata (serio, NULL);
707 input_put_device (lk->dev);
708 kfree (lk); 708 kfree (lk);
709} 709}
710 710