diff options
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r-- | drivers/input/keyboard/amikbd.c | 59 | ||||
-rw-r--r-- | drivers/input/keyboard/atkbd.c | 188 | ||||
-rw-r--r-- | drivers/input/keyboard/corgikbd.c | 74 | ||||
-rw-r--r-- | drivers/input/keyboard/lkkbd.c | 128 | ||||
-rw-r--r-- | drivers/input/keyboard/maple_keyb.c | 72 | ||||
-rw-r--r-- | drivers/input/keyboard/newtonkbd.c | 83 | ||||
-rw-r--r-- | drivers/input/keyboard/spitzkbd.c | 79 | ||||
-rw-r--r-- | drivers/input/keyboard/sunkbd.c | 117 | ||||
-rw-r--r-- | drivers/input/keyboard/xtkbd.c | 80 |
9 files changed, 449 insertions, 431 deletions
diff --git a/drivers/input/keyboard/amikbd.c b/drivers/input/keyboard/amikbd.c index 4e8e8ea214ab..3d63bc1ad322 100644 --- a/drivers/input/keyboard/amikbd.c +++ b/drivers/input/keyboard/amikbd.c | |||
@@ -155,10 +155,7 @@ static const char *amikbd_messages[8] = { | |||
155 | [7] = KERN_WARNING "amikbd: keyboard interrupt\n" | 155 | [7] = KERN_WARNING "amikbd: keyboard interrupt\n" |
156 | }; | 156 | }; |
157 | 157 | ||
158 | static struct input_dev amikbd_dev; | 158 | static struct input_dev *amikbd_dev; |
159 | |||
160 | static char *amikbd_name = "Amiga keyboard"; | ||
161 | static char *amikbd_phys = "amikbd/input0"; | ||
162 | 159 | ||
163 | static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) | 160 | static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) |
164 | { | 161 | { |
@@ -176,16 +173,16 @@ static irqreturn_t amikbd_interrupt(int irq, void *dummy, struct pt_regs *fp) | |||
176 | 173 | ||
177 | scancode = amikbd_keycode[scancode]; | 174 | scancode = amikbd_keycode[scancode]; |
178 | 175 | ||
179 | input_regs(&amikbd_dev, fp); | 176 | input_regs(amikbd_dev, fp); |
180 | 177 | ||
181 | if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */ | 178 | if (scancode == KEY_CAPSLOCK) { /* CapsLock is a toggle switch key on Amiga */ |
182 | input_report_key(&amikbd_dev, scancode, 1); | 179 | input_report_key(amikbd_dev, scancode, 1); |
183 | input_report_key(&amikbd_dev, scancode, 0); | 180 | input_report_key(amikbd_dev, scancode, 0); |
184 | input_sync(&amikbd_dev); | ||
185 | } else { | 181 | } else { |
186 | input_report_key(&amikbd_dev, scancode, down); | 182 | input_report_key(amikbd_dev, scancode, down); |
187 | input_sync(&amikbd_dev); | ||
188 | } | 183 | } |
184 | |||
185 | input_sync(amikbd_dev); | ||
189 | } else /* scancodes >= 0x78 are error codes */ | 186 | } else /* scancodes >= 0x78 are error codes */ |
190 | printk(amikbd_messages[scancode - 0x78]); | 187 | printk(amikbd_messages[scancode - 0x78]); |
191 | 188 | ||
@@ -202,39 +199,41 @@ static int __init amikbd_init(void) | |||
202 | if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) | 199 | if (!request_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100, "amikeyb")) |
203 | return -EBUSY; | 200 | return -EBUSY; |
204 | 201 | ||
205 | init_input_dev(&amikbd_dev); | 202 | amikbd_dev = input_dev_allocate(); |
206 | 203 | if (!amikbd_dev) { | |
207 | amikbd_dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 204 | printk(KERN_ERR "amikbd: not enough memory for input device\n"); |
208 | amikbd_dev.keycode = amikbd_keycode; | 205 | release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); |
209 | amikbd_dev.keycodesize = sizeof(unsigned char); | 206 | return -ENOMEM; |
210 | amikbd_dev.keycodemax = ARRAY_SIZE(amikbd_keycode); | 207 | } |
208 | |||
209 | amikbd_dev->name = "Amiga Keyboard"; | ||
210 | amikbd_dev->phys = "amikbd/input0"; | ||
211 | amikbd_dev->id.bustype = BUS_AMIGA; | ||
212 | amikbd_dev->id.vendor = 0x0001; | ||
213 | amikbd_dev->id.product = 0x0001; | ||
214 | amikbd_dev->id.version = 0x0100; | ||
215 | |||
216 | amikbd_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
217 | amikbd_dev->keycode = amikbd_keycode; | ||
218 | amikbd_dev->keycodesize = sizeof(unsigned char); | ||
219 | amikbd_dev->keycodemax = ARRAY_SIZE(amikbd_keycode); | ||
211 | 220 | ||
212 | for (i = 0; i < 0x78; i++) | 221 | for (i = 0; i < 0x78; i++) |
213 | if (amikbd_keycode[i]) | 222 | if (amikbd_keycode[i]) |
214 | set_bit(amikbd_keycode[i], amikbd_dev.keybit); | 223 | set_bit(amikbd_keycode[i], amikbd_dev->keybit); |
215 | 224 | ||
216 | ciaa.cra &= ~0x41; /* serial data in, turn off TA */ | 225 | ciaa.cra &= ~0x41; /* serial data in, turn off TA */ |
217 | request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); | 226 | request_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt, 0, "amikbd", amikbd_interrupt); |
218 | 227 | ||
219 | amikbd_dev.name = amikbd_name; | 228 | input_register_device(amikbd_dev); |
220 | amikbd_dev.phys = amikbd_phys; | ||
221 | amikbd_dev.id.bustype = BUS_AMIGA; | ||
222 | amikbd_dev.id.vendor = 0x0001; | ||
223 | amikbd_dev.id.product = 0x0001; | ||
224 | amikbd_dev.id.version = 0x0100; | ||
225 | |||
226 | input_register_device(&amikbd_dev); | ||
227 | |||
228 | printk(KERN_INFO "input: %s\n", amikbd_name); | ||
229 | |||
230 | return 0; | 229 | return 0; |
231 | } | 230 | } |
232 | 231 | ||
233 | static void __exit amikbd_exit(void) | 232 | static void __exit amikbd_exit(void) |
234 | { | 233 | { |
235 | input_unregister_device(&amikbd_dev); | ||
236 | free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); | 234 | free_irq(IRQ_AMIGA_CIAA_SP, amikbd_interrupt); |
237 | release_mem_region(CIAA_PHYSADDR-1+0xb00, 0x100); | 235 | input_unregister_device(amikbd_dev); |
236 | release_mem_region(CIAA_PHYSADDR - 1 + 0xb00, 0x100); | ||
238 | } | 237 | } |
239 | 238 | ||
240 | module_init(amikbd_init); | 239 | module_init(amikbd_init); |
diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 1ad8c2ee7dbf..820c7fd9a604 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c | |||
@@ -185,12 +185,12 @@ static struct { | |||
185 | 185 | ||
186 | struct atkbd { | 186 | struct atkbd { |
187 | 187 | ||
188 | struct ps2dev ps2dev; | 188 | struct ps2dev ps2dev; |
189 | struct input_dev *dev; | ||
189 | 190 | ||
190 | /* Written only during init */ | 191 | /* Written only during init */ |
191 | char name[64]; | 192 | char name[64]; |
192 | char phys[32]; | 193 | char phys[32]; |
193 | struct input_dev dev; | ||
194 | 194 | ||
195 | unsigned short id; | 195 | unsigned short id; |
196 | unsigned char keycode[512]; | 196 | unsigned char keycode[512]; |
@@ -290,7 +290,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
290 | if (!atkbd->enabled) | 290 | if (!atkbd->enabled) |
291 | goto out; | 291 | goto out; |
292 | 292 | ||
293 | input_event(&atkbd->dev, EV_MSC, MSC_RAW, code); | 293 | input_event(atkbd->dev, EV_MSC, MSC_RAW, code); |
294 | 294 | ||
295 | if (atkbd->translated) { | 295 | if (atkbd->translated) { |
296 | 296 | ||
@@ -326,10 +326,10 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
326 | atkbd->release = 1; | 326 | atkbd->release = 1; |
327 | goto out; | 327 | goto out; |
328 | case ATKBD_RET_HANGUEL: | 328 | case ATKBD_RET_HANGUEL: |
329 | atkbd_report_key(&atkbd->dev, regs, KEY_HANGUEL, 3); | 329 | atkbd_report_key(atkbd->dev, regs, KEY_HANGUEL, 3); |
330 | goto out; | 330 | goto out; |
331 | case ATKBD_RET_HANJA: | 331 | case ATKBD_RET_HANJA: |
332 | atkbd_report_key(&atkbd->dev, regs, KEY_HANJA, 3); | 332 | atkbd_report_key(atkbd->dev, regs, KEY_HANJA, 3); |
333 | goto out; | 333 | goto out; |
334 | case ATKBD_RET_ERR: | 334 | case ATKBD_RET_ERR: |
335 | printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); | 335 | printk(KERN_DEBUG "atkbd.c: Keyboard on %s reports too many keys pressed.\n", serio->phys); |
@@ -345,7 +345,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
345 | } | 345 | } |
346 | 346 | ||
347 | if (atkbd->keycode[code] != ATKBD_KEY_NULL) | 347 | if (atkbd->keycode[code] != ATKBD_KEY_NULL) |
348 | input_event(&atkbd->dev, EV_MSC, MSC_SCAN, code); | 348 | input_event(atkbd->dev, EV_MSC, MSC_SCAN, code); |
349 | 349 | ||
350 | switch (atkbd->keycode[code]) { | 350 | switch (atkbd->keycode[code]) { |
351 | case ATKBD_KEY_NULL: | 351 | case ATKBD_KEY_NULL: |
@@ -365,7 +365,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
365 | "to make it known.\n", | 365 | "to make it known.\n", |
366 | code & 0x80 ? "e0" : "", code & 0x7f); | 366 | code & 0x80 ? "e0" : "", code & 0x7f); |
367 | } | 367 | } |
368 | input_sync(&atkbd->dev); | 368 | input_sync(atkbd->dev); |
369 | break; | 369 | break; |
370 | case ATKBD_SCR_1: | 370 | case ATKBD_SCR_1: |
371 | scroll = 1 - atkbd->release * 2; | 371 | scroll = 1 - atkbd->release * 2; |
@@ -390,7 +390,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
390 | break; | 390 | break; |
391 | default: | 391 | default: |
392 | value = atkbd->release ? 0 : | 392 | value = atkbd->release ? 0 : |
393 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev.key))); | 393 | (1 + (!atkbd->softrepeat && test_bit(atkbd->keycode[code], atkbd->dev->key))); |
394 | 394 | ||
395 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ | 395 | switch (value) { /* Workaround Toshiba laptop multiple keypress */ |
396 | case 0: | 396 | case 0: |
@@ -398,7 +398,7 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
398 | break; | 398 | break; |
399 | case 1: | 399 | case 1: |
400 | atkbd->last = code; | 400 | atkbd->last = code; |
401 | atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev.rep[REP_DELAY]) / 2; | 401 | atkbd->time = jiffies + msecs_to_jiffies(atkbd->dev->rep[REP_DELAY]) / 2; |
402 | break; | 402 | break; |
403 | case 2: | 403 | case 2: |
404 | if (!time_after(jiffies, atkbd->time) && atkbd->last == code) | 404 | if (!time_after(jiffies, atkbd->time) && atkbd->last == code) |
@@ -406,16 +406,16 @@ static irqreturn_t atkbd_interrupt(struct serio *serio, unsigned char data, | |||
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | 408 | ||
409 | atkbd_report_key(&atkbd->dev, regs, atkbd->keycode[code], value); | 409 | atkbd_report_key(atkbd->dev, regs, atkbd->keycode[code], value); |
410 | } | 410 | } |
411 | 411 | ||
412 | if (atkbd->scroll) { | 412 | if (atkbd->scroll) { |
413 | input_regs(&atkbd->dev, regs); | 413 | input_regs(atkbd->dev, regs); |
414 | if (click != -1) | 414 | if (click != -1) |
415 | input_report_key(&atkbd->dev, BTN_MIDDLE, click); | 415 | input_report_key(atkbd->dev, BTN_MIDDLE, click); |
416 | input_report_rel(&atkbd->dev, REL_WHEEL, scroll); | 416 | input_report_rel(atkbd->dev, REL_WHEEL, scroll); |
417 | input_report_rel(&atkbd->dev, REL_HWHEEL, hscroll); | 417 | input_report_rel(atkbd->dev, REL_HWHEEL, hscroll); |
418 | input_sync(&atkbd->dev); | 418 | input_sync(atkbd->dev); |
419 | } | 419 | } |
420 | 420 | ||
421 | atkbd->release = 0; | 421 | atkbd->release = 0; |
@@ -463,7 +463,6 @@ static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int co | |||
463 | 463 | ||
464 | return 0; | 464 | return 0; |
465 | 465 | ||
466 | |||
467 | case EV_REP: | 466 | case EV_REP: |
468 | 467 | ||
469 | if (atkbd->softrepeat) return 0; | 468 | if (atkbd->softrepeat) return 0; |
@@ -693,7 +692,7 @@ static void atkbd_disconnect(struct serio *serio) | |||
693 | device_remove_file(&serio->dev, &atkbd_attr_softrepeat); | 692 | device_remove_file(&serio->dev, &atkbd_attr_softrepeat); |
694 | device_remove_file(&serio->dev, &atkbd_attr_softraw); | 693 | device_remove_file(&serio->dev, &atkbd_attr_softraw); |
695 | 694 | ||
696 | input_unregister_device(&atkbd->dev); | 695 | input_unregister_device(atkbd->dev); |
697 | serio_close(serio); | 696 | serio_close(serio); |
698 | serio_set_drvdata(serio, NULL); | 697 | serio_set_drvdata(serio, NULL); |
699 | kfree(atkbd); | 698 | kfree(atkbd); |
@@ -701,7 +700,7 @@ static void atkbd_disconnect(struct serio *serio) | |||
701 | 700 | ||
702 | 701 | ||
703 | /* | 702 | /* |
704 | * atkbd_set_device_attrs() initializes keyboard's keycode table | 703 | * atkbd_set_keycode_table() initializes keyboard's keycode table |
705 | * according to the selected scancode set | 704 | * according to the selected scancode set |
706 | */ | 705 | */ |
707 | 706 | ||
@@ -737,53 +736,58 @@ static void atkbd_set_keycode_table(struct atkbd *atkbd) | |||
737 | 736 | ||
738 | static void atkbd_set_device_attrs(struct atkbd *atkbd) | 737 | static void atkbd_set_device_attrs(struct atkbd *atkbd) |
739 | { | 738 | { |
739 | struct input_dev *input_dev = atkbd->dev; | ||
740 | int i; | 740 | int i; |
741 | 741 | ||
742 | memset(&atkbd->dev, 0, sizeof(struct input_dev)); | 742 | if (atkbd->extra) |
743 | sprintf(atkbd->name, "AT Set 2 Extra keyboard"); | ||
744 | else | ||
745 | sprintf(atkbd->name, "AT %s Set %d keyboard", | ||
746 | atkbd->translated ? "Translated" : "Raw", atkbd->set); | ||
743 | 747 | ||
744 | init_input_dev(&atkbd->dev); | 748 | sprintf(atkbd->phys, "%s/input0", atkbd->ps2dev.serio->phys); |
745 | 749 | ||
746 | atkbd->dev.name = atkbd->name; | 750 | input_dev->name = atkbd->name; |
747 | atkbd->dev.phys = atkbd->phys; | 751 | input_dev->phys = atkbd->phys; |
748 | atkbd->dev.id.bustype = BUS_I8042; | 752 | input_dev->id.bustype = BUS_I8042; |
749 | atkbd->dev.id.vendor = 0x0001; | 753 | input_dev->id.vendor = 0x0001; |
750 | atkbd->dev.id.product = atkbd->translated ? 1 : atkbd->set; | 754 | input_dev->id.product = atkbd->translated ? 1 : atkbd->set; |
751 | atkbd->dev.id.version = atkbd->id; | 755 | input_dev->id.version = atkbd->id; |
752 | atkbd->dev.event = atkbd_event; | 756 | input_dev->event = atkbd_event; |
753 | atkbd->dev.private = atkbd; | 757 | input_dev->private = atkbd; |
754 | atkbd->dev.dev = &atkbd->ps2dev.serio->dev; | 758 | input_dev->cdev.dev = &atkbd->ps2dev.serio->dev; |
755 | 759 | ||
756 | atkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); | 760 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_MSC); |
757 | 761 | ||
758 | if (atkbd->write) { | 762 | if (atkbd->write) { |
759 | atkbd->dev.evbit[0] |= BIT(EV_LED); | 763 | input_dev->evbit[0] |= BIT(EV_LED); |
760 | atkbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 764 | input_dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); |
761 | } | 765 | } |
762 | 766 | ||
763 | if (atkbd->extra) | 767 | if (atkbd->extra) |
764 | atkbd->dev.ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | | 768 | input_dev->ledbit[0] |= BIT(LED_COMPOSE) | BIT(LED_SUSPEND) | |
765 | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC); | 769 | BIT(LED_SLEEP) | BIT(LED_MUTE) | BIT(LED_MISC); |
766 | 770 | ||
767 | if (!atkbd->softrepeat) { | 771 | if (!atkbd->softrepeat) { |
768 | atkbd->dev.rep[REP_DELAY] = 250; | 772 | input_dev->rep[REP_DELAY] = 250; |
769 | atkbd->dev.rep[REP_PERIOD] = 33; | 773 | input_dev->rep[REP_PERIOD] = 33; |
770 | } | 774 | } |
771 | 775 | ||
772 | atkbd->dev.mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN); | 776 | input_dev->mscbit[0] = atkbd->softraw ? BIT(MSC_SCAN) : BIT(MSC_RAW) | BIT(MSC_SCAN); |
773 | 777 | ||
774 | if (atkbd->scroll) { | 778 | if (atkbd->scroll) { |
775 | atkbd->dev.evbit[0] |= BIT(EV_REL); | 779 | input_dev->evbit[0] |= BIT(EV_REL); |
776 | atkbd->dev.relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL); | 780 | input_dev->relbit[0] = BIT(REL_WHEEL) | BIT(REL_HWHEEL); |
777 | set_bit(BTN_MIDDLE, atkbd->dev.keybit); | 781 | set_bit(BTN_MIDDLE, input_dev->keybit); |
778 | } | 782 | } |
779 | 783 | ||
780 | atkbd->dev.keycode = atkbd->keycode; | 784 | input_dev->keycode = atkbd->keycode; |
781 | atkbd->dev.keycodesize = sizeof(unsigned char); | 785 | input_dev->keycodesize = sizeof(unsigned char); |
782 | atkbd->dev.keycodemax = ARRAY_SIZE(atkbd_set2_keycode); | 786 | input_dev->keycodemax = ARRAY_SIZE(atkbd_set2_keycode); |
783 | 787 | ||
784 | for (i = 0; i < 512; i++) | 788 | for (i = 0; i < 512; i++) |
785 | if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) | 789 | if (atkbd->keycode[i] && atkbd->keycode[i] < ATKBD_SPECIAL) |
786 | set_bit(atkbd->keycode[i], atkbd->dev.keybit); | 790 | set_bit(atkbd->keycode[i], input_dev->keybit); |
787 | } | 791 | } |
788 | 792 | ||
789 | /* | 793 | /* |
@@ -796,13 +800,15 @@ static void atkbd_set_device_attrs(struct atkbd *atkbd) | |||
796 | static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | 800 | static int atkbd_connect(struct serio *serio, struct serio_driver *drv) |
797 | { | 801 | { |
798 | struct atkbd *atkbd; | 802 | struct atkbd *atkbd; |
799 | int err; | 803 | struct input_dev *dev; |
800 | 804 | int err = -ENOMEM; | |
801 | if (!(atkbd = kmalloc(sizeof(struct atkbd), GFP_KERNEL))) | ||
802 | return - ENOMEM; | ||
803 | 805 | ||
804 | memset(atkbd, 0, sizeof(struct atkbd)); | 806 | atkbd = kzalloc(sizeof(struct atkbd), GFP_KERNEL); |
807 | dev = input_allocate_device(); | ||
808 | if (!atkbd || !dev) | ||
809 | goto fail; | ||
805 | 810 | ||
811 | atkbd->dev = dev; | ||
806 | ps2_init(&atkbd->ps2dev, serio); | 812 | ps2_init(&atkbd->ps2dev, serio); |
807 | 813 | ||
808 | switch (serio->id.type) { | 814 | switch (serio->id.type) { |
@@ -828,19 +834,15 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
828 | serio_set_drvdata(serio, atkbd); | 834 | serio_set_drvdata(serio, atkbd); |
829 | 835 | ||
830 | err = serio_open(serio, drv); | 836 | err = serio_open(serio, drv); |
831 | if (err) { | 837 | if (err) |
832 | serio_set_drvdata(serio, NULL); | 838 | goto fail; |
833 | kfree(atkbd); | ||
834 | return err; | ||
835 | } | ||
836 | 839 | ||
837 | if (atkbd->write) { | 840 | if (atkbd->write) { |
838 | 841 | ||
839 | if (atkbd_probe(atkbd)) { | 842 | if (atkbd_probe(atkbd)) { |
840 | serio_close(serio); | 843 | serio_close(serio); |
841 | serio_set_drvdata(serio, NULL); | 844 | err = -ENODEV; |
842 | kfree(atkbd); | 845 | goto fail; |
843 | return -ENODEV; | ||
844 | } | 846 | } |
845 | 847 | ||
846 | atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); | 848 | atkbd->set = atkbd_select_set(atkbd, atkbd_set, atkbd_extra); |
@@ -851,19 +853,9 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
851 | atkbd->id = 0xab00; | 853 | atkbd->id = 0xab00; |
852 | } | 854 | } |
853 | 855 | ||
854 | if (atkbd->extra) | ||
855 | sprintf(atkbd->name, "AT Set 2 Extra keyboard"); | ||
856 | else | ||
857 | sprintf(atkbd->name, "AT %s Set %d keyboard", | ||
858 | atkbd->translated ? "Translated" : "Raw", atkbd->set); | ||
859 | |||
860 | sprintf(atkbd->phys, "%s/input0", serio->phys); | ||
861 | |||
862 | atkbd_set_keycode_table(atkbd); | 856 | atkbd_set_keycode_table(atkbd); |
863 | atkbd_set_device_attrs(atkbd); | 857 | atkbd_set_device_attrs(atkbd); |
864 | 858 | ||
865 | input_register_device(&atkbd->dev); | ||
866 | |||
867 | device_create_file(&serio->dev, &atkbd_attr_extra); | 859 | device_create_file(&serio->dev, &atkbd_attr_extra); |
868 | device_create_file(&serio->dev, &atkbd_attr_scroll); | 860 | device_create_file(&serio->dev, &atkbd_attr_scroll); |
869 | device_create_file(&serio->dev, &atkbd_attr_set); | 861 | device_create_file(&serio->dev, &atkbd_attr_set); |
@@ -872,9 +864,14 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
872 | 864 | ||
873 | atkbd_enable(atkbd); | 865 | atkbd_enable(atkbd); |
874 | 866 | ||
875 | printk(KERN_INFO "input: %s on %s\n", atkbd->name, serio->phys); | 867 | input_register_device(atkbd->dev); |
876 | 868 | ||
877 | return 0; | 869 | return 0; |
870 | |||
871 | fail: serio_set_drvdata(serio, NULL); | ||
872 | input_free_device(dev); | ||
873 | kfree(atkbd); | ||
874 | return err; | ||
878 | } | 875 | } |
879 | 876 | ||
880 | /* | 877 | /* |
@@ -896,9 +893,9 @@ static int atkbd_reconnect(struct serio *serio) | |||
896 | atkbd_disable(atkbd); | 893 | atkbd_disable(atkbd); |
897 | 894 | ||
898 | if (atkbd->write) { | 895 | if (atkbd->write) { |
899 | param[0] = (test_bit(LED_SCROLLL, atkbd->dev.led) ? 1 : 0) | 896 | param[0] = (test_bit(LED_SCROLLL, atkbd->dev->led) ? 1 : 0) |
900 | | (test_bit(LED_NUML, atkbd->dev.led) ? 2 : 0) | 897 | | (test_bit(LED_NUML, atkbd->dev->led) ? 2 : 0) |
901 | | (test_bit(LED_CAPSL, atkbd->dev.led) ? 4 : 0); | 898 | | (test_bit(LED_CAPSL, atkbd->dev->led) ? 4 : 0); |
902 | 899 | ||
903 | if (atkbd_probe(atkbd)) | 900 | if (atkbd_probe(atkbd)) |
904 | return -1; | 901 | return -1; |
@@ -1008,6 +1005,7 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf) | |||
1008 | 1005 | ||
1009 | static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) | 1006 | static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count) |
1010 | { | 1007 | { |
1008 | struct input_dev *new_dev; | ||
1011 | unsigned long value; | 1009 | unsigned long value; |
1012 | char *rest; | 1010 | char *rest; |
1013 | 1011 | ||
@@ -1019,12 +1017,19 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun | |||
1019 | return -EINVAL; | 1017 | return -EINVAL; |
1020 | 1018 | ||
1021 | if (atkbd->extra != value) { | 1019 | if (atkbd->extra != value) { |
1022 | /* unregister device as it's properties will change */ | 1020 | /* |
1023 | input_unregister_device(&atkbd->dev); | 1021 | * Since device's properties will change we need to |
1022 | * unregister old device. But allocate new one first | ||
1023 | * to make sure we have it. | ||
1024 | */ | ||
1025 | if (!(new_dev = input_allocate_device())) | ||
1026 | return -ENOMEM; | ||
1027 | input_unregister_device(atkbd->dev); | ||
1028 | atkbd->dev = new_dev; | ||
1024 | atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); | 1029 | atkbd->set = atkbd_select_set(atkbd, atkbd->set, value); |
1025 | atkbd_activate(atkbd); | 1030 | atkbd_activate(atkbd); |
1026 | atkbd_set_device_attrs(atkbd); | 1031 | atkbd_set_device_attrs(atkbd); |
1027 | input_register_device(&atkbd->dev); | 1032 | input_register_device(atkbd->dev); |
1028 | } | 1033 | } |
1029 | return count; | 1034 | return count; |
1030 | } | 1035 | } |
@@ -1036,6 +1041,7 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf) | |||
1036 | 1041 | ||
1037 | static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) | 1042 | static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count) |
1038 | { | 1043 | { |
1044 | struct input_dev *new_dev; | ||
1039 | unsigned long value; | 1045 | unsigned long value; |
1040 | char *rest; | 1046 | char *rest; |
1041 | 1047 | ||
@@ -1044,12 +1050,14 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou | |||
1044 | return -EINVAL; | 1050 | return -EINVAL; |
1045 | 1051 | ||
1046 | if (atkbd->scroll != value) { | 1052 | if (atkbd->scroll != value) { |
1047 | /* unregister device as it's properties will change */ | 1053 | if (!(new_dev = input_allocate_device())) |
1048 | input_unregister_device(&atkbd->dev); | 1054 | return -ENOMEM; |
1055 | input_unregister_device(atkbd->dev); | ||
1056 | atkbd->dev = new_dev; | ||
1049 | atkbd->scroll = value; | 1057 | atkbd->scroll = value; |
1050 | atkbd_set_keycode_table(atkbd); | 1058 | atkbd_set_keycode_table(atkbd); |
1051 | atkbd_set_device_attrs(atkbd); | 1059 | atkbd_set_device_attrs(atkbd); |
1052 | input_register_device(&atkbd->dev); | 1060 | input_register_device(atkbd->dev); |
1053 | } | 1061 | } |
1054 | return count; | 1062 | return count; |
1055 | } | 1063 | } |
@@ -1061,6 +1069,7 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf) | |||
1061 | 1069 | ||
1062 | static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) | 1070 | static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) |
1063 | { | 1071 | { |
1072 | struct input_dev *new_dev; | ||
1064 | unsigned long value; | 1073 | unsigned long value; |
1065 | char *rest; | 1074 | char *rest; |
1066 | 1075 | ||
@@ -1072,13 +1081,15 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) | |||
1072 | return -EINVAL; | 1081 | return -EINVAL; |
1073 | 1082 | ||
1074 | if (atkbd->set != value) { | 1083 | if (atkbd->set != value) { |
1075 | /* unregister device as it's properties will change */ | 1084 | if (!(new_dev = input_allocate_device())) |
1076 | input_unregister_device(&atkbd->dev); | 1085 | return -ENOMEM; |
1086 | input_unregister_device(atkbd->dev); | ||
1087 | atkbd->dev = new_dev; | ||
1077 | atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); | 1088 | atkbd->set = atkbd_select_set(atkbd, value, atkbd->extra); |
1078 | atkbd_activate(atkbd); | 1089 | atkbd_activate(atkbd); |
1079 | atkbd_set_keycode_table(atkbd); | 1090 | atkbd_set_keycode_table(atkbd); |
1080 | atkbd_set_device_attrs(atkbd); | 1091 | atkbd_set_device_attrs(atkbd); |
1081 | input_register_device(&atkbd->dev); | 1092 | input_register_device(atkbd->dev); |
1082 | } | 1093 | } |
1083 | return count; | 1094 | return count; |
1084 | } | 1095 | } |
@@ -1090,6 +1101,7 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf) | |||
1090 | 1101 | ||
1091 | static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) | 1102 | static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count) |
1092 | { | 1103 | { |
1104 | struct input_dev *new_dev; | ||
1093 | unsigned long value; | 1105 | unsigned long value; |
1094 | char *rest; | 1106 | char *rest; |
1095 | 1107 | ||
@@ -1101,15 +1113,16 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t | |||
1101 | return -EINVAL; | 1113 | return -EINVAL; |
1102 | 1114 | ||
1103 | if (atkbd->softrepeat != value) { | 1115 | if (atkbd->softrepeat != value) { |
1104 | /* unregister device as it's properties will change */ | 1116 | if (!(new_dev = input_allocate_device())) |
1105 | input_unregister_device(&atkbd->dev); | 1117 | return -ENOMEM; |
1118 | input_unregister_device(atkbd->dev); | ||
1119 | atkbd->dev = new_dev; | ||
1106 | atkbd->softrepeat = value; | 1120 | atkbd->softrepeat = value; |
1107 | if (atkbd->softrepeat) | 1121 | if (atkbd->softrepeat) |
1108 | atkbd->softraw = 1; | 1122 | atkbd->softraw = 1; |
1109 | atkbd_set_device_attrs(atkbd); | 1123 | atkbd_set_device_attrs(atkbd); |
1110 | input_register_device(&atkbd->dev); | 1124 | input_register_device(atkbd->dev); |
1111 | } | 1125 | } |
1112 | |||
1113 | return count; | 1126 | return count; |
1114 | } | 1127 | } |
1115 | 1128 | ||
@@ -1121,6 +1134,7 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf) | |||
1121 | 1134 | ||
1122 | static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) | 1135 | static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count) |
1123 | { | 1136 | { |
1137 | struct input_dev *new_dev; | ||
1124 | unsigned long value; | 1138 | unsigned long value; |
1125 | char *rest; | 1139 | char *rest; |
1126 | 1140 | ||
@@ -1129,11 +1143,13 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co | |||
1129 | return -EINVAL; | 1143 | return -EINVAL; |
1130 | 1144 | ||
1131 | if (atkbd->softraw != value) { | 1145 | if (atkbd->softraw != value) { |
1132 | /* unregister device as it's properties will change */ | 1146 | if (!(new_dev = input_allocate_device())) |
1133 | input_unregister_device(&atkbd->dev); | 1147 | return -ENOMEM; |
1148 | input_unregister_device(atkbd->dev); | ||
1149 | atkbd->dev = new_dev; | ||
1134 | atkbd->softraw = value; | 1150 | atkbd->softraw = value; |
1135 | atkbd_set_device_attrs(atkbd); | 1151 | atkbd_set_device_attrs(atkbd); |
1136 | input_register_device(&atkbd->dev); | 1152 | input_register_device(atkbd->dev); |
1137 | } | 1153 | } |
1138 | return count; | 1154 | return count; |
1139 | } | 1155 | } |
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index cd4b6e795013..564bb365f6fc 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -70,8 +70,7 @@ static unsigned char corgikbd_keycode[NR_SCANCODES] = { | |||
70 | 70 | ||
71 | struct corgikbd { | 71 | struct corgikbd { |
72 | unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; | 72 | unsigned char keycode[ARRAY_SIZE(corgikbd_keycode)]; |
73 | struct input_dev input; | 73 | struct input_dev *input; |
74 | char phys[32]; | ||
75 | 74 | ||
76 | spinlock_t lock; | 75 | spinlock_t lock; |
77 | struct timer_list timer; | 76 | struct timer_list timer; |
@@ -147,7 +146,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs | |||
147 | spin_lock_irqsave(&corgikbd_data->lock, flags); | 146 | spin_lock_irqsave(&corgikbd_data->lock, flags); |
148 | 147 | ||
149 | if (regs) | 148 | if (regs) |
150 | input_regs(&corgikbd_data->input, regs); | 149 | input_regs(corgikbd_data->input, regs); |
151 | 150 | ||
152 | num_pressed = 0; | 151 | num_pressed = 0; |
153 | for (col = 0; col < KB_COLS; col++) { | 152 | for (col = 0; col < KB_COLS; col++) { |
@@ -169,14 +168,14 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs | |||
169 | scancode = SCANCODE(row, col); | 168 | scancode = SCANCODE(row, col); |
170 | pressed = rowd & KB_ROWMASK(row); | 169 | pressed = rowd & KB_ROWMASK(row); |
171 | 170 | ||
172 | input_report_key(&corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); | 171 | input_report_key(corgikbd_data->input, corgikbd_data->keycode[scancode], pressed); |
173 | 172 | ||
174 | if (pressed) | 173 | if (pressed) |
175 | num_pressed++; | 174 | num_pressed++; |
176 | 175 | ||
177 | if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) | 176 | if (pressed && (corgikbd_data->keycode[scancode] == CORGI_KEY_OFF) |
178 | && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { | 177 | && time_after(jiffies, corgikbd_data->suspend_jiffies + HZ)) { |
179 | input_event(&corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); | 178 | input_event(corgikbd_data->input, EV_PWR, CORGI_KEY_OFF, 1); |
180 | corgikbd_data->suspend_jiffies=jiffies; | 179 | corgikbd_data->suspend_jiffies=jiffies; |
181 | } | 180 | } |
182 | } | 181 | } |
@@ -185,7 +184,7 @@ static void corgikbd_scankeyboard(struct corgikbd *corgikbd_data, struct pt_regs | |||
185 | 184 | ||
186 | corgikbd_activate_all(); | 185 | corgikbd_activate_all(); |
187 | 186 | ||
188 | input_sync(&corgikbd_data->input); | 187 | input_sync(corgikbd_data->input); |
189 | 188 | ||
190 | /* if any keys are pressed, enable the timer */ | 189 | /* if any keys are pressed, enable the timer */ |
191 | if (num_pressed) | 190 | if (num_pressed) |
@@ -249,9 +248,9 @@ static void corgikbd_hinge_timer(unsigned long data) | |||
249 | if (hinge_count >= HINGE_STABLE_COUNT) { | 248 | if (hinge_count >= HINGE_STABLE_COUNT) { |
250 | spin_lock_irqsave(&corgikbd_data->lock, flags); | 249 | spin_lock_irqsave(&corgikbd_data->lock, flags); |
251 | 250 | ||
252 | input_report_switch(&corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); | 251 | input_report_switch(corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); |
253 | input_report_switch(&corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); | 252 | input_report_switch(corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); |
254 | input_sync(&corgikbd_data->input); | 253 | input_sync(corgikbd_data->input); |
255 | 254 | ||
256 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | 255 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); |
257 | } | 256 | } |
@@ -287,16 +286,21 @@ static int corgikbd_resume(struct device *dev, uint32_t level) | |||
287 | 286 | ||
288 | static int __init corgikbd_probe(struct device *dev) | 287 | static int __init corgikbd_probe(struct device *dev) |
289 | { | 288 | { |
290 | int i; | ||
291 | struct corgikbd *corgikbd; | 289 | struct corgikbd *corgikbd; |
290 | struct input_dev *input_dev; | ||
291 | int i; | ||
292 | 292 | ||
293 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); | 293 | corgikbd = kzalloc(sizeof(struct corgikbd), GFP_KERNEL); |
294 | if (!corgikbd) | 294 | input_dev = input_allocate_device(); |
295 | if (!corgikbd || !input_dev) { | ||
296 | kfree(corgikbd); | ||
297 | input_free_device(input_dev); | ||
295 | return -ENOMEM; | 298 | return -ENOMEM; |
299 | } | ||
296 | 300 | ||
297 | dev_set_drvdata(dev,corgikbd); | 301 | dev_set_drvdata(dev, corgikbd); |
298 | strcpy(corgikbd->phys, "corgikbd/input0"); | ||
299 | 302 | ||
303 | corgikbd->input = input_dev; | ||
300 | spin_lock_init(&corgikbd->lock); | 304 | spin_lock_init(&corgikbd->lock); |
301 | 305 | ||
302 | /* Init Keyboard rescan timer */ | 306 | /* Init Keyboard rescan timer */ |
@@ -311,28 +315,30 @@ static int __init corgikbd_probe(struct device *dev) | |||
311 | 315 | ||
312 | corgikbd->suspend_jiffies=jiffies; | 316 | corgikbd->suspend_jiffies=jiffies; |
313 | 317 | ||
314 | init_input_dev(&corgikbd->input); | ||
315 | corgikbd->input.private = corgikbd; | ||
316 | corgikbd->input.name = "Corgi Keyboard"; | ||
317 | corgikbd->input.dev = dev; | ||
318 | corgikbd->input.phys = corgikbd->phys; | ||
319 | corgikbd->input.id.bustype = BUS_HOST; | ||
320 | corgikbd->input.id.vendor = 0x0001; | ||
321 | corgikbd->input.id.product = 0x0001; | ||
322 | corgikbd->input.id.version = 0x0100; | ||
323 | corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | ||
324 | corgikbd->input.keycode = corgikbd->keycode; | ||
325 | corgikbd->input.keycodesize = sizeof(unsigned char); | ||
326 | corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode); | ||
327 | |||
328 | memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); | 318 | memcpy(corgikbd->keycode, corgikbd_keycode, sizeof(corgikbd->keycode)); |
319 | |||
320 | input_dev->name = "Corgi Keyboard"; | ||
321 | input_dev->phys = "corgikbd/input0"; | ||
322 | input_dev->id.bustype = BUS_HOST; | ||
323 | input_dev->id.vendor = 0x0001; | ||
324 | input_dev->id.product = 0x0001; | ||
325 | input_dev->id.version = 0x0100; | ||
326 | input_dev->cdev.dev = dev; | ||
327 | input_dev->private = corgikbd; | ||
328 | |||
329 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | ||
330 | input_dev->keycode = corgikbd->keycode; | ||
331 | input_dev->keycodesize = sizeof(unsigned char); | ||
332 | input_dev->keycodemax = ARRAY_SIZE(corgikbd_keycode); | ||
333 | |||
329 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) | 334 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) |
330 | set_bit(corgikbd->keycode[i], corgikbd->input.keybit); | 335 | set_bit(corgikbd->keycode[i], input_dev->keybit); |
331 | clear_bit(0, corgikbd->input.keybit); | 336 | clear_bit(0, input_dev->keybit); |
332 | set_bit(SW_0, corgikbd->input.swbit); | 337 | set_bit(SW_0, input_dev->swbit); |
333 | set_bit(SW_1, corgikbd->input.swbit); | 338 | set_bit(SW_1, input_dev->swbit); |
339 | |||
340 | input_register_device(corgikbd->input); | ||
334 | 341 | ||
335 | input_register_device(&corgikbd->input); | ||
336 | mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); | 342 | mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); |
337 | 343 | ||
338 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | 344 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ |
@@ -349,8 +355,6 @@ static int __init corgikbd_probe(struct device *dev) | |||
349 | for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) | 355 | for (i = 0; i < CORGI_KEY_STROBE_NUM; i++) |
350 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); | 356 | pxa_gpio_mode(CORGI_GPIO_KEY_STROBE(i) | GPIO_OUT | GPIO_DFLT_HIGH); |
351 | 357 | ||
352 | printk(KERN_INFO "input: Corgi Keyboard Registered\n"); | ||
353 | |||
354 | return 0; | 358 | return 0; |
355 | } | 359 | } |
356 | 360 | ||
@@ -365,7 +369,7 @@ static int corgikbd_remove(struct device *dev) | |||
365 | del_timer_sync(&corgikbd->htimer); | 369 | del_timer_sync(&corgikbd->htimer); |
366 | del_timer_sync(&corgikbd->timer); | 370 | del_timer_sync(&corgikbd->timer); |
367 | 371 | ||
368 | input_unregister_device(&corgikbd->input); | 372 | input_unregister_device(corgikbd->input); |
369 | 373 | ||
370 | kfree(corgikbd); | 374 | kfree(corgikbd); |
371 | 375 | ||
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; /* % */ | |||
102 | module_param (ctrlclick_volume, int, 0); | 102 | module_param (ctrlclick_volume, int, 0); |
103 | MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%"); | 103 | MODULE_PARM_DESC (ctrlclick_volume, "Ctrlclick volume (in %), default is 100%"); |
104 | 104 | ||
105 | static int lk201_compose_is_alt = 0; | 105 | static int lk201_compose_is_alt; |
106 | module_param (lk201_compose_is_alt, int, 0); | 106 | module_param (lk201_compose_is_alt, int, 0); |
107 | MODULE_PARM_DESC (lk201_compose_is_alt, "If set non-zero, LK201' Compose key " | 107 | MODULE_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 | |||
627 | lkkbd_connect (struct serio *serio, struct serio_driver *drv) | 626 | lkkbd_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 | ||
diff --git a/drivers/input/keyboard/maple_keyb.c b/drivers/input/keyboard/maple_keyb.c index eecbde294f1f..cc6aaf9e85be 100644 --- a/drivers/input/keyboard/maple_keyb.c +++ b/drivers/input/keyboard/maple_keyb.c | |||
@@ -37,7 +37,7 @@ static unsigned char dc_kbd_keycode[256] = { | |||
37 | 37 | ||
38 | 38 | ||
39 | struct dc_kbd { | 39 | struct dc_kbd { |
40 | struct input_dev dev; | 40 | struct input_dev *dev; |
41 | unsigned char new[8]; | 41 | unsigned char new[8]; |
42 | unsigned char old[8]; | 42 | unsigned char old[8]; |
43 | }; | 43 | }; |
@@ -46,30 +46,24 @@ struct dc_kbd { | |||
46 | static void dc_scan_kbd(struct dc_kbd *kbd) | 46 | static void dc_scan_kbd(struct dc_kbd *kbd) |
47 | { | 47 | { |
48 | int i; | 48 | int i; |
49 | struct input_dev *dev = &kbd->dev; | 49 | struct input_dev *dev = kbd->dev; |
50 | 50 | ||
51 | for(i=0; i<8; i++) | 51 | for (i = 0; i < 8; i++) |
52 | input_report_key(dev, | 52 | input_report_key(dev, dc_kbd_keycode[i + 224], (kbd->new[0] >> i) & 1); |
53 | dc_kbd_keycode[i+224], | ||
54 | (kbd->new[0]>>i)&1); | ||
55 | 53 | ||
56 | for(i=2; i<8; i++) { | 54 | for (i = 2; i < 8; i++) { |
57 | 55 | ||
58 | if(kbd->old[i]>3&&memscan(kbd->new+2, kbd->old[i], 6)==NULL) { | 56 | if (kbd->old[i] > 3 && memscan(kbd->new + 2, kbd->old[i], 6) == NULL) { |
59 | if(dc_kbd_keycode[kbd->old[i]]) | 57 | if (dc_kbd_keycode[kbd->old[i]]) |
60 | input_report_key(dev, | 58 | input_report_key(dev, dc_kbd_keycode[kbd->old[i]], 0); |
61 | dc_kbd_keycode[kbd->old[i]], | ||
62 | 0); | ||
63 | else | 59 | else |
64 | printk("Unknown key (scancode %#x) released.", | 60 | printk("Unknown key (scancode %#x) released.", |
65 | kbd->old[i]); | 61 | kbd->old[i]); |
66 | } | 62 | } |
67 | 63 | ||
68 | if(kbd->new[i]>3&&memscan(kbd->old+2, kbd->new[i], 6)!=NULL) { | 64 | if (kbd->new[i] > 3 && memscan(kbd->old + 2, kbd->new[i], 6) != NULL) { |
69 | if(dc_kbd_keycode[kbd->new[i]]) | 65 | if(dc_kbd_keycode[kbd->new[i]]) |
70 | input_report_key(dev, | 66 | input_report_key(dev, dc_kbd_keycode[kbd->new[i]], 1); |
71 | dc_kbd_keycode[kbd->new[i]], | ||
72 | 1); | ||
73 | else | 67 | else |
74 | printk("Unknown key (scancode %#x) pressed.", | 68 | printk("Unknown key (scancode %#x) pressed.", |
75 | kbd->new[i]); | 69 | kbd->new[i]); |
@@ -89,43 +83,39 @@ static void dc_kbd_callback(struct mapleq *mq) | |||
89 | unsigned long *buf = mq->recvbuf; | 83 | unsigned long *buf = mq->recvbuf; |
90 | 84 | ||
91 | if (buf[1] == mapledev->function) { | 85 | if (buf[1] == mapledev->function) { |
92 | memcpy(kbd->new, buf+2, 8); | 86 | memcpy(kbd->new, buf + 2, 8); |
93 | dc_scan_kbd(kbd); | 87 | dc_scan_kbd(kbd); |
94 | } | 88 | } |
95 | } | 89 | } |
96 | 90 | ||
97 | static int dc_kbd_connect(struct maple_device *dev) | 91 | static int dc_kbd_connect(struct maple_device *dev) |
98 | { | 92 | { |
99 | int i; | ||
100 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | ||
101 | struct dc_kbd *kbd; | 93 | struct dc_kbd *kbd; |
94 | struct input_dev *input_dev; | ||
95 | unsigned long data = be32_to_cpu(dev->devinfo.function_data[0]); | ||
96 | int i; | ||
102 | 97 | ||
103 | if (!(kbd = kmalloc(sizeof(struct dc_kbd), GFP_KERNEL))) | 98 | dev->private_data = kbd = kzalloc(sizeof(struct dc_kbd), GFP_KERNEL); |
104 | return -1; | 99 | input_dev = input_allocate_device(); |
105 | memset(kbd, 0, sizeof(struct dc_kbd)); | 100 | if (!kbd || !input_dev) { |
106 | 101 | kfree(kbd); | |
107 | dev->private_data = kbd; | 102 | input_free_device(input_dev); |
108 | 103 | return -ENOMEM; | |
109 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 104 | } |
110 | |||
111 | init_input_dev(&kbd->dev); | ||
112 | |||
113 | for (i=0; i<255; i++) | ||
114 | set_bit(dc_kbd_keycode[i], kbd->dev.keybit); | ||
115 | |||
116 | clear_bit(0, kbd->dev.keybit); | ||
117 | 105 | ||
118 | kbd->dev.private = kbd; | 106 | kbd->dev = input_dev; |
119 | 107 | ||
120 | kbd->dev.name = dev->product_name; | 108 | input_dev->name = dev->product_name; |
121 | kbd->dev.id.bustype = BUS_MAPLE; | 109 | input_dev->id.bustype = BUS_MAPLE; |
110 | input_dev->private = kbd; | ||
111 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
112 | for (i = 0; i < 255; i++) | ||
113 | set_bit(dc_kbd_keycode[i], input_dev->keybit); | ||
114 | clear_bit(0, input_dev->keybit); | ||
122 | 115 | ||
123 | input_register_device(&kbd->dev); | 116 | input_register_device(kbd->dev); |
124 | 117 | ||
125 | maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); | 118 | maple_getcond_callback(dev, dc_kbd_callback, 1, MAPLE_FUNC_KEYBOARD); |
126 | |||
127 | printk(KERN_INFO "input: keyboard(0x%lx): %s\n", data, kbd->dev.name); | ||
128 | |||
129 | return 0; | 119 | return 0; |
130 | } | 120 | } |
131 | 121 | ||
@@ -134,7 +124,7 @@ static void dc_kbd_disconnect(struct maple_device *dev) | |||
134 | { | 124 | { |
135 | struct dc_kbd *kbd = dev->private_data; | 125 | struct dc_kbd *kbd = dev->private_data; |
136 | 126 | ||
137 | input_unregister_device(&kbd->dev); | 127 | input_unregister_device(kbd->dev); |
138 | kfree(kbd); | 128 | kfree(kbd); |
139 | } | 129 | } |
140 | 130 | ||
diff --git a/drivers/input/keyboard/newtonkbd.c b/drivers/input/keyboard/newtonkbd.c index 2e8ce1613eec..d10983c521e6 100644 --- a/drivers/input/keyboard/newtonkbd.c +++ b/drivers/input/keyboard/newtonkbd.c | |||
@@ -57,11 +57,9 @@ static unsigned char nkbd_keycode[128] = { | |||
57 | KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0 | 57 | KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0 |
58 | }; | 58 | }; |
59 | 59 | ||
60 | static char *nkbd_name = "Newton Keyboard"; | ||
61 | |||
62 | struct nkbd { | 60 | struct nkbd { |
63 | unsigned char keycode[128]; | 61 | unsigned char keycode[128]; |
64 | struct input_dev dev; | 62 | struct input_dev *dev; |
65 | struct serio *serio; | 63 | struct serio *serio; |
66 | char phys[32]; | 64 | char phys[32]; |
67 | }; | 65 | }; |
@@ -73,13 +71,13 @@ static irqreturn_t nkbd_interrupt(struct serio *serio, | |||
73 | 71 | ||
74 | /* invalid scan codes are probably the init sequence, so we ignore them */ | 72 | /* invalid scan codes are probably the init sequence, so we ignore them */ |
75 | if (nkbd->keycode[data & NKBD_KEY]) { | 73 | if (nkbd->keycode[data & NKBD_KEY]) { |
76 | input_regs(&nkbd->dev, regs); | 74 | input_regs(nkbd->dev, regs); |
77 | input_report_key(&nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS); | 75 | input_report_key(nkbd->dev, nkbd->keycode[data & NKBD_KEY], data & NKBD_PRESS); |
78 | input_sync(&nkbd->dev); | 76 | input_sync(nkbd->dev); |
79 | } | 77 | } |
80 | 78 | ||
81 | else if (data == 0xe7) /* end of init sequence */ | 79 | else if (data == 0xe7) /* end of init sequence */ |
82 | printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys); | 80 | printk(KERN_INFO "input: %s on %s\n", nkbd->dev->name, serio->phys); |
83 | return IRQ_HANDLED; | 81 | return IRQ_HANDLED; |
84 | 82 | ||
85 | } | 83 | } |
@@ -87,62 +85,59 @@ static irqreturn_t nkbd_interrupt(struct serio *serio, | |||
87 | static int nkbd_connect(struct serio *serio, struct serio_driver *drv) | 85 | static int nkbd_connect(struct serio *serio, struct serio_driver *drv) |
88 | { | 86 | { |
89 | struct nkbd *nkbd; | 87 | struct nkbd *nkbd; |
88 | struct input_dev *input_dev; | ||
89 | int err = -ENOMEM; | ||
90 | int i; | 90 | int i; |
91 | int err; | ||
92 | |||
93 | if (!(nkbd = kmalloc(sizeof(struct nkbd), GFP_KERNEL))) | ||
94 | return -ENOMEM; | ||
95 | |||
96 | memset(nkbd, 0, sizeof(struct nkbd)); | ||
97 | 91 | ||
98 | nkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 92 | nkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL); |
93 | input_dev = input_allocate_device(); | ||
94 | if (!nkbd || !input_dev) | ||
95 | goto fail; | ||
99 | 96 | ||
100 | nkbd->serio = serio; | 97 | nkbd->serio = serio; |
98 | nkbd->dev = input_dev; | ||
99 | sprintf(nkbd->phys, "%s/input0", serio->phys); | ||
100 | memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode)); | ||
101 | 101 | ||
102 | init_input_dev(&nkbd->dev); | 102 | input_dev->name = "Newton Keyboard"; |
103 | nkbd->dev.keycode = nkbd->keycode; | 103 | input_dev->phys = nkbd->phys; |
104 | nkbd->dev.keycodesize = sizeof(unsigned char); | 104 | input_dev->id.bustype = BUS_RS232; |
105 | nkbd->dev.keycodemax = ARRAY_SIZE(nkbd_keycode); | 105 | input_dev->id.vendor = SERIO_NEWTON; |
106 | nkbd->dev.private = nkbd; | 106 | input_dev->id.product = 0x0001; |
107 | input_dev->id.version = 0x0100; | ||
108 | input_dev->cdev.dev = &serio->dev; | ||
109 | input_dev->private = nkbd; | ||
110 | |||
111 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
112 | input_dev->keycode = nkbd->keycode; | ||
113 | input_dev->keycodesize = sizeof(unsigned char); | ||
114 | input_dev->keycodemax = ARRAY_SIZE(nkbd_keycode); | ||
115 | for (i = 0; i < 128; i++) | ||
116 | set_bit(nkbd->keycode[i], input_dev->keybit); | ||
117 | clear_bit(0, input_dev->keybit); | ||
107 | 118 | ||
108 | serio_set_drvdata(serio, nkbd); | 119 | serio_set_drvdata(serio, nkbd); |
109 | 120 | ||
110 | err = serio_open(serio, drv); | 121 | err = serio_open(serio, drv); |
111 | if (err) { | 122 | if (err) |
112 | serio_set_drvdata(serio, NULL); | 123 | goto fail; |
113 | kfree(nkbd); | ||
114 | return err; | ||
115 | } | ||
116 | |||
117 | memcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode)); | ||
118 | for (i = 0; i < 128; i++) | ||
119 | set_bit(nkbd->keycode[i], nkbd->dev.keybit); | ||
120 | clear_bit(0, nkbd->dev.keybit); | ||
121 | |||
122 | sprintf(nkbd->phys, "%s/input0", serio->phys); | ||
123 | |||
124 | nkbd->dev.name = nkbd_name; | ||
125 | nkbd->dev.phys = nkbd->phys; | ||
126 | nkbd->dev.id.bustype = BUS_RS232; | ||
127 | nkbd->dev.id.vendor = SERIO_NEWTON; | ||
128 | nkbd->dev.id.product = 0x0001; | ||
129 | nkbd->dev.id.version = 0x0100; | ||
130 | nkbd->dev.dev = &serio->dev; | ||
131 | |||
132 | input_register_device(&nkbd->dev); | ||
133 | |||
134 | printk(KERN_INFO "input: %s on %s\n", nkbd_name, serio->phys); | ||
135 | 124 | ||
125 | input_register_device(nkbd->dev); | ||
136 | return 0; | 126 | return 0; |
127 | |||
128 | fail: serio_set_drvdata(serio, NULL); | ||
129 | input_free_device(input_dev); | ||
130 | kfree(nkbd); | ||
131 | return err; | ||
137 | } | 132 | } |
138 | 133 | ||
139 | static void nkbd_disconnect(struct serio *serio) | 134 | static void nkbd_disconnect(struct serio *serio) |
140 | { | 135 | { |
141 | struct nkbd *nkbd = serio_get_drvdata(serio); | 136 | struct nkbd *nkbd = serio_get_drvdata(serio); |
142 | 137 | ||
143 | input_unregister_device(&nkbd->dev); | ||
144 | serio_close(serio); | 138 | serio_close(serio); |
145 | serio_set_drvdata(serio, NULL); | 139 | serio_set_drvdata(serio, NULL); |
140 | input_unregister_device(nkbd->dev); | ||
146 | kfree(nkbd); | 141 | kfree(nkbd); |
147 | } | 142 | } |
148 | 143 | ||
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index 344f46005401..732fb310e487 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -85,7 +85,7 @@ static int spitz_senses[] = { | |||
85 | 85 | ||
86 | struct spitzkbd { | 86 | struct spitzkbd { |
87 | unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; | 87 | unsigned char keycode[ARRAY_SIZE(spitzkbd_keycode)]; |
88 | struct input_dev input; | 88 | struct input_dev *input; |
89 | char phys[32]; | 89 | char phys[32]; |
90 | 90 | ||
91 | spinlock_t lock; | 91 | spinlock_t lock; |
@@ -187,8 +187,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs | |||
187 | 187 | ||
188 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | 188 | spin_lock_irqsave(&spitzkbd_data->lock, flags); |
189 | 189 | ||
190 | if (regs) | 190 | input_regs(spitzkbd_data->input, regs); |
191 | input_regs(&spitzkbd_data->input, regs); | ||
192 | 191 | ||
193 | num_pressed = 0; | 192 | num_pressed = 0; |
194 | for (col = 0; col < KB_COLS; col++) { | 193 | for (col = 0; col < KB_COLS; col++) { |
@@ -210,7 +209,7 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs | |||
210 | scancode = SCANCODE(row, col); | 209 | scancode = SCANCODE(row, col); |
211 | pressed = rowd & KB_ROWMASK(row); | 210 | pressed = rowd & KB_ROWMASK(row); |
212 | 211 | ||
213 | input_report_key(&spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); | 212 | input_report_key(spitzkbd_data->input, spitzkbd_data->keycode[scancode], pressed); |
214 | 213 | ||
215 | if (pressed) | 214 | if (pressed) |
216 | num_pressed++; | 215 | num_pressed++; |
@@ -220,15 +219,15 @@ static void spitzkbd_scankeyboard(struct spitzkbd *spitzkbd_data, struct pt_regs | |||
220 | 219 | ||
221 | spitzkbd_activate_all(); | 220 | spitzkbd_activate_all(); |
222 | 221 | ||
223 | input_report_key(&spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); | 222 | input_report_key(spitzkbd_data->input, SPITZ_KEY_SYNC, (GPLR(SPITZ_GPIO_SYNC) & GPIO_bit(SPITZ_GPIO_SYNC)) != 0 ); |
224 | input_report_key(&spitzkbd_data->input, KEY_SUSPEND, pwrkey); | 223 | input_report_key(spitzkbd_data->input, KEY_SUSPEND, pwrkey); |
225 | 224 | ||
226 | if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { | 225 | if (pwrkey && time_after(jiffies, spitzkbd_data->suspend_jiffies + msecs_to_jiffies(1000))) { |
227 | input_event(&spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); | 226 | input_event(spitzkbd_data->input, EV_PWR, KEY_SUSPEND, 1); |
228 | spitzkbd_data->suspend_jiffies = jiffies; | 227 | spitzkbd_data->suspend_jiffies = jiffies; |
229 | } | 228 | } |
230 | 229 | ||
231 | input_sync(&spitzkbd_data->input); | 230 | input_sync(spitzkbd_data->input); |
232 | 231 | ||
233 | /* if any keys are pressed, enable the timer */ | 232 | /* if any keys are pressed, enable the timer */ |
234 | if (num_pressed) | 233 | if (num_pressed) |
@@ -259,6 +258,7 @@ static irqreturn_t spitzkbd_interrupt(int irq, void *dev_id, struct pt_regs *reg | |||
259 | static void spitzkbd_timer_callback(unsigned long data) | 258 | static void spitzkbd_timer_callback(unsigned long data) |
260 | { | 259 | { |
261 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; | 260 | struct spitzkbd *spitzkbd_data = (struct spitzkbd *) data; |
261 | |||
262 | spitzkbd_scankeyboard(spitzkbd_data, NULL); | 262 | spitzkbd_scankeyboard(spitzkbd_data, NULL); |
263 | } | 263 | } |
264 | 264 | ||
@@ -298,9 +298,9 @@ static void spitzkbd_hinge_timer(unsigned long data) | |||
298 | if (hinge_count >= HINGE_STABLE_COUNT) { | 298 | if (hinge_count >= HINGE_STABLE_COUNT) { |
299 | spin_lock_irqsave(&spitzkbd_data->lock, flags); | 299 | spin_lock_irqsave(&spitzkbd_data->lock, flags); |
300 | 300 | ||
301 | input_report_switch(&spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); | 301 | input_report_switch(spitzkbd_data->input, SW_0, ((GPLR(SPITZ_GPIO_SWA) & GPIO_bit(SPITZ_GPIO_SWA)) != 0)); |
302 | input_report_switch(&spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); | 302 | input_report_switch(spitzkbd_data->input, SW_1, ((GPLR(SPITZ_GPIO_SWB) & GPIO_bit(SPITZ_GPIO_SWB)) != 0)); |
303 | input_sync(&spitzkbd_data->input); | 303 | input_sync(spitzkbd_data->input); |
304 | 304 | ||
305 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); | 305 | spin_unlock_irqrestore(&spitzkbd_data->lock, flags); |
306 | } else { | 306 | } else { |
@@ -346,14 +346,21 @@ static int spitzkbd_resume(struct device *dev, uint32_t level) | |||
346 | 346 | ||
347 | static int __init spitzkbd_probe(struct device *dev) | 347 | static int __init spitzkbd_probe(struct device *dev) |
348 | { | 348 | { |
349 | int i; | ||
350 | struct spitzkbd *spitzkbd; | 349 | struct spitzkbd *spitzkbd; |
350 | struct input_dev *input_dev; | ||
351 | int i; | ||
351 | 352 | ||
352 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); | 353 | spitzkbd = kzalloc(sizeof(struct spitzkbd), GFP_KERNEL); |
353 | if (!spitzkbd) | 354 | if (!spitzkbd) |
354 | return -ENOMEM; | 355 | return -ENOMEM; |
355 | 356 | ||
356 | dev_set_drvdata(dev,spitzkbd); | 357 | input_dev = input_allocate_device(); |
358 | if (!input_dev) { | ||
359 | kfree(spitzkbd); | ||
360 | return -ENOMEM; | ||
361 | } | ||
362 | |||
363 | dev_set_drvdata(dev, spitzkbd); | ||
357 | strcpy(spitzkbd->phys, "spitzkbd/input0"); | 364 | strcpy(spitzkbd->phys, "spitzkbd/input0"); |
358 | 365 | ||
359 | spin_lock_init(&spitzkbd->lock); | 366 | spin_lock_init(&spitzkbd->lock); |
@@ -368,30 +375,34 @@ static int __init spitzkbd_probe(struct device *dev) | |||
368 | spitzkbd->htimer.function = spitzkbd_hinge_timer; | 375 | spitzkbd->htimer.function = spitzkbd_hinge_timer; |
369 | spitzkbd->htimer.data = (unsigned long) spitzkbd; | 376 | spitzkbd->htimer.data = (unsigned long) spitzkbd; |
370 | 377 | ||
371 | spitzkbd->suspend_jiffies=jiffies; | 378 | spitzkbd->suspend_jiffies = jiffies; |
372 | 379 | ||
373 | init_input_dev(&spitzkbd->input); | 380 | spitzkbd->input = input_dev; |
374 | spitzkbd->input.private = spitzkbd; | 381 | |
375 | spitzkbd->input.name = "Spitz Keyboard"; | 382 | input_dev->private = spitzkbd; |
376 | spitzkbd->input.dev = dev; | 383 | input_dev->name = "Spitz Keyboard"; |
377 | spitzkbd->input.phys = spitzkbd->phys; | 384 | input_dev->phys = spitzkbd->phys; |
378 | spitzkbd->input.id.bustype = BUS_HOST; | 385 | input_dev->cdev.dev = dev; |
379 | spitzkbd->input.id.vendor = 0x0001; | 386 | |
380 | spitzkbd->input.id.product = 0x0001; | 387 | input_dev->id.bustype = BUS_HOST; |
381 | spitzkbd->input.id.version = 0x0100; | 388 | input_dev->id.vendor = 0x0001; |
382 | spitzkbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); | 389 | input_dev->id.product = 0x0001; |
383 | spitzkbd->input.keycode = spitzkbd->keycode; | 390 | input_dev->id.version = 0x0100; |
384 | spitzkbd->input.keycodesize = sizeof(unsigned char); | 391 | |
385 | spitzkbd->input.keycodemax = ARRAY_SIZE(spitzkbd_keycode); | 392 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); |
393 | input_dev->keycode = spitzkbd->keycode; | ||
394 | input_dev->keycodesize = sizeof(unsigned char); | ||
395 | input_dev->keycodemax = ARRAY_SIZE(spitzkbd_keycode); | ||
386 | 396 | ||
387 | memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); | 397 | memcpy(spitzkbd->keycode, spitzkbd_keycode, sizeof(spitzkbd->keycode)); |
388 | for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) | 398 | for (i = 0; i < ARRAY_SIZE(spitzkbd_keycode); i++) |
389 | set_bit(spitzkbd->keycode[i], spitzkbd->input.keybit); | 399 | set_bit(spitzkbd->keycode[i], input_dev->keybit); |
390 | clear_bit(0, spitzkbd->input.keybit); | 400 | clear_bit(0, input_dev->keybit); |
391 | set_bit(SW_0, spitzkbd->input.swbit); | 401 | set_bit(SW_0, input_dev->swbit); |
392 | set_bit(SW_1, spitzkbd->input.swbit); | 402 | set_bit(SW_1, input_dev->swbit); |
403 | |||
404 | input_register_device(input_dev); | ||
393 | 405 | ||
394 | input_register_device(&spitzkbd->input); | ||
395 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); | 406 | mod_timer(&spitzkbd->htimer, jiffies + msecs_to_jiffies(HINGE_SCAN_INTERVAL)); |
396 | 407 | ||
397 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ | 408 | /* Setup sense interrupts - RisingEdge Detect, sense lines as inputs */ |
@@ -444,7 +455,7 @@ static int spitzkbd_remove(struct device *dev) | |||
444 | del_timer_sync(&spitzkbd->htimer); | 455 | del_timer_sync(&spitzkbd->htimer); |
445 | del_timer_sync(&spitzkbd->timer); | 456 | del_timer_sync(&spitzkbd->timer); |
446 | 457 | ||
447 | input_unregister_device(&spitzkbd->input); | 458 | input_unregister_device(spitzkbd->input); |
448 | 459 | ||
449 | kfree(spitzkbd); | 460 | kfree(spitzkbd); |
450 | 461 | ||
diff --git a/drivers/input/keyboard/sunkbd.c b/drivers/input/keyboard/sunkbd.c index 4bae5d89348d..b15b6d8d4f83 100644 --- a/drivers/input/keyboard/sunkbd.c +++ b/drivers/input/keyboard/sunkbd.c | |||
@@ -76,13 +76,14 @@ static unsigned char sunkbd_keycode[128] = { | |||
76 | 76 | ||
77 | struct sunkbd { | 77 | struct sunkbd { |
78 | unsigned char keycode[128]; | 78 | unsigned char keycode[128]; |
79 | struct input_dev dev; | 79 | struct input_dev *dev; |
80 | struct serio *serio; | 80 | struct serio *serio; |
81 | struct work_struct tq; | 81 | struct work_struct tq; |
82 | wait_queue_head_t wait; | 82 | wait_queue_head_t wait; |
83 | char name[64]; | 83 | char name[64]; |
84 | char phys[32]; | 84 | char phys[32]; |
85 | char type; | 85 | char type; |
86 | unsigned char enabled; | ||
86 | volatile s8 reset; | 87 | volatile s8 reset; |
87 | volatile s8 layout; | 88 | volatile s8 layout; |
88 | }; | 89 | }; |
@@ -124,10 +125,13 @@ static irqreturn_t sunkbd_interrupt(struct serio *serio, | |||
124 | break; | 125 | break; |
125 | 126 | ||
126 | default: | 127 | default: |
128 | if (!sunkbd->enabled) | ||
129 | break; | ||
130 | |||
127 | if (sunkbd->keycode[data & SUNKBD_KEY]) { | 131 | if (sunkbd->keycode[data & SUNKBD_KEY]) { |
128 | input_regs(&sunkbd->dev, regs); | 132 | input_regs(sunkbd->dev, regs); |
129 | input_report_key(&sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); | 133 | input_report_key(sunkbd->dev, sunkbd->keycode[data & SUNKBD_KEY], !(data & SUNKBD_RELEASE)); |
130 | input_sync(&sunkbd->dev); | 134 | input_sync(sunkbd->dev); |
131 | } else { | 135 | } else { |
132 | printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n", | 136 | printk(KERN_WARNING "sunkbd.c: Unknown key (scancode %#x) %s.\n", |
133 | data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed"); | 137 | data & SUNKBD_KEY, data & SUNKBD_RELEASE ? "released" : "pressed"); |
@@ -184,7 +188,7 @@ static int sunkbd_initialize(struct sunkbd *sunkbd) | |||
184 | sunkbd->reset = -2; | 188 | sunkbd->reset = -2; |
185 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET); | 189 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_RESET); |
186 | wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); | 190 | wait_event_interruptible_timeout(sunkbd->wait, sunkbd->reset >= 0, HZ); |
187 | if (sunkbd->reset <0) | 191 | if (sunkbd->reset < 0) |
188 | return -1; | 192 | return -1; |
189 | 193 | ||
190 | sunkbd->type = sunkbd->reset; | 194 | sunkbd->type = sunkbd->reset; |
@@ -213,10 +217,17 @@ static void sunkbd_reinit(void *data) | |||
213 | 217 | ||
214 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED); | 218 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_SETLED); |
215 | sunkbd->serio->write(sunkbd->serio, | 219 | sunkbd->serio->write(sunkbd->serio, |
216 | (!!test_bit(LED_CAPSL, sunkbd->dev.led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev.led) << 2) | | 220 | (!!test_bit(LED_CAPSL, sunkbd->dev->led) << 3) | (!!test_bit(LED_SCROLLL, sunkbd->dev->led) << 2) | |
217 | (!!test_bit(LED_COMPOSE, sunkbd->dev.led) << 1) | !!test_bit(LED_NUML, sunkbd->dev.led)); | 221 | (!!test_bit(LED_COMPOSE, sunkbd->dev->led) << 1) | !!test_bit(LED_NUML, sunkbd->dev->led)); |
218 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev.snd)); | 222 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_NOCLICK - !!test_bit(SND_CLICK, sunkbd->dev->snd)); |
219 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev.snd)); | 223 | sunkbd->serio->write(sunkbd->serio, SUNKBD_CMD_BELLOFF - !!test_bit(SND_BELL, sunkbd->dev->snd)); |
224 | } | ||
225 | |||
226 | static void sunkbd_enable(struct sunkbd *sunkbd, int enable) | ||
227 | { | ||
228 | serio_pause_rx(sunkbd->serio); | ||
229 | sunkbd->enabled = 1; | ||
230 | serio_continue_rx(sunkbd->serio); | ||
220 | } | 231 | } |
221 | 232 | ||
222 | /* | 233 | /* |
@@ -226,70 +237,64 @@ static void sunkbd_reinit(void *data) | |||
226 | static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | 237 | static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) |
227 | { | 238 | { |
228 | struct sunkbd *sunkbd; | 239 | struct sunkbd *sunkbd; |
240 | struct input_dev *input_dev; | ||
241 | int err = -ENOMEM; | ||
229 | int i; | 242 | int i; |
230 | int err; | ||
231 | |||
232 | if (!(sunkbd = kmalloc(sizeof(struct sunkbd), GFP_KERNEL))) | ||
233 | return -ENOMEM; | ||
234 | 243 | ||
235 | memset(sunkbd, 0, sizeof(struct sunkbd)); | 244 | sunkbd = kzalloc(sizeof(struct sunkbd), GFP_KERNEL); |
236 | 245 | input_dev = input_allocate_device(); | |
237 | init_input_dev(&sunkbd->dev); | 246 | if (!sunkbd || !input_dev) |
238 | init_waitqueue_head(&sunkbd->wait); | 247 | goto fail; |
239 | |||
240 | sunkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP); | ||
241 | sunkbd->dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML); | ||
242 | sunkbd->dev.sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL); | ||
243 | 248 | ||
244 | sunkbd->serio = serio; | 249 | sunkbd->serio = serio; |
245 | 250 | sunkbd->dev = input_dev; | |
251 | init_waitqueue_head(&sunkbd->wait); | ||
246 | INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); | 252 | INIT_WORK(&sunkbd->tq, sunkbd_reinit, sunkbd); |
247 | 253 | snprintf(sunkbd->phys, sizeof(sunkbd->phys), "%s/input0", serio->phys); | |
248 | sunkbd->dev.keycode = sunkbd->keycode; | ||
249 | sunkbd->dev.keycodesize = sizeof(unsigned char); | ||
250 | sunkbd->dev.keycodemax = ARRAY_SIZE(sunkbd_keycode); | ||
251 | |||
252 | sunkbd->dev.event = sunkbd_event; | ||
253 | sunkbd->dev.private = sunkbd; | ||
254 | 254 | ||
255 | serio_set_drvdata(serio, sunkbd); | 255 | serio_set_drvdata(serio, sunkbd); |
256 | 256 | ||
257 | err = serio_open(serio, drv); | 257 | err = serio_open(serio, drv); |
258 | if (err) { | 258 | if (err) |
259 | serio_set_drvdata(serio, NULL); | 259 | goto fail; |
260 | kfree(sunkbd); | ||
261 | return err; | ||
262 | } | ||
263 | 260 | ||
264 | if (sunkbd_initialize(sunkbd) < 0) { | 261 | if (sunkbd_initialize(sunkbd) < 0) { |
265 | serio_close(serio); | 262 | serio_close(serio); |
266 | serio_set_drvdata(serio, NULL); | 263 | goto fail; |
267 | kfree(sunkbd); | ||
268 | return -ENODEV; | ||
269 | } | 264 | } |
270 | 265 | ||
271 | sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type); | 266 | sprintf(sunkbd->name, "Sun Type %d keyboard", sunkbd->type); |
272 | |||
273 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); | 267 | memcpy(sunkbd->keycode, sunkbd_keycode, sizeof(sunkbd->keycode)); |
274 | for (i = 0; i < 128; i++) | ||
275 | set_bit(sunkbd->keycode[i], sunkbd->dev.keybit); | ||
276 | clear_bit(0, sunkbd->dev.keybit); | ||
277 | |||
278 | sprintf(sunkbd->phys, "%s/input0", serio->phys); | ||
279 | |||
280 | sunkbd->dev.name = sunkbd->name; | ||
281 | sunkbd->dev.phys = sunkbd->phys; | ||
282 | sunkbd->dev.id.bustype = BUS_RS232; | ||
283 | sunkbd->dev.id.vendor = SERIO_SUNKBD; | ||
284 | sunkbd->dev.id.product = sunkbd->type; | ||
285 | sunkbd->dev.id.version = 0x0100; | ||
286 | sunkbd->dev.dev = &serio->dev; | ||
287 | 268 | ||
288 | input_register_device(&sunkbd->dev); | 269 | input_dev->name = sunkbd->name; |
289 | 270 | input_dev->phys = sunkbd->phys; | |
290 | printk(KERN_INFO "input: %s on %s\n", sunkbd->name, serio->phys); | 271 | input_dev->id.bustype = BUS_RS232; |
272 | input_dev->id.vendor = SERIO_SUNKBD; | ||
273 | input_dev->id.product = sunkbd->type; | ||
274 | input_dev->id.version = 0x0100; | ||
275 | input_dev->cdev.dev = &serio->dev; | ||
276 | input_dev->private = sunkbd; | ||
277 | input_dev->event = sunkbd_event; | ||
278 | |||
279 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_LED) | BIT(EV_SND) | BIT(EV_REP); | ||
280 | input_dev->ledbit[0] = BIT(LED_CAPSL) | BIT(LED_COMPOSE) | BIT(LED_SCROLLL) | BIT(LED_NUML); | ||
281 | input_dev->sndbit[0] = BIT(SND_CLICK) | BIT(SND_BELL); | ||
282 | |||
283 | input_dev->keycode = sunkbd->keycode; | ||
284 | input_dev->keycodesize = sizeof(unsigned char); | ||
285 | input_dev->keycodemax = ARRAY_SIZE(sunkbd_keycode); | ||
286 | for (i = 0; i < 128; i++) | ||
287 | set_bit(sunkbd->keycode[i], input_dev->keybit); | ||
288 | clear_bit(0, input_dev->keybit); | ||
291 | 289 | ||
290 | sunkbd_enable(sunkbd, 1); | ||
291 | input_register_device(sunkbd->dev); | ||
292 | return 0; | 292 | return 0; |
293 | |||
294 | fail: serio_set_drvdata(serio, NULL); | ||
295 | input_free_device(input_dev); | ||
296 | kfree(sunkbd); | ||
297 | return err; | ||
293 | } | 298 | } |
294 | 299 | ||
295 | /* | 300 | /* |
@@ -299,7 +304,9 @@ static int sunkbd_connect(struct serio *serio, struct serio_driver *drv) | |||
299 | static void sunkbd_disconnect(struct serio *serio) | 304 | static void sunkbd_disconnect(struct serio *serio) |
300 | { | 305 | { |
301 | struct sunkbd *sunkbd = serio_get_drvdata(serio); | 306 | struct sunkbd *sunkbd = serio_get_drvdata(serio); |
302 | input_unregister_device(&sunkbd->dev); | 307 | |
308 | sunkbd_enable(sunkbd, 0); | ||
309 | input_unregister_device(sunkbd->dev); | ||
303 | serio_close(serio); | 310 | serio_close(serio); |
304 | serio_set_drvdata(serio, NULL); | 311 | serio_set_drvdata(serio, NULL); |
305 | kfree(sunkbd); | 312 | kfree(sunkbd); |
diff --git a/drivers/input/keyboard/xtkbd.c b/drivers/input/keyboard/xtkbd.c index 19eaec7789d1..4135e3e16c51 100644 --- a/drivers/input/keyboard/xtkbd.c +++ b/drivers/input/keyboard/xtkbd.c | |||
@@ -56,11 +56,9 @@ static unsigned char xtkbd_keycode[256] = { | |||
56 | 106 | 56 | 106 |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static char *xtkbd_name = "XT Keyboard"; | ||
60 | |||
61 | struct xtkbd { | 59 | struct xtkbd { |
62 | unsigned char keycode[256]; | 60 | unsigned char keycode[256]; |
63 | struct input_dev dev; | 61 | struct input_dev *dev; |
64 | struct serio *serio; | 62 | struct serio *serio; |
65 | char phys[32]; | 63 | char phys[32]; |
66 | }; | 64 | }; |
@@ -77,9 +75,9 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio, | |||
77 | default: | 75 | default: |
78 | 76 | ||
79 | if (xtkbd->keycode[data & XTKBD_KEY]) { | 77 | if (xtkbd->keycode[data & XTKBD_KEY]) { |
80 | input_regs(&xtkbd->dev, regs); | 78 | input_regs(xtkbd->dev, regs); |
81 | input_report_key(&xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); | 79 | input_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE)); |
82 | input_sync(&xtkbd->dev); | 80 | input_sync(xtkbd->dev); |
83 | } else { | 81 | } else { |
84 | printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n", | 82 | printk(KERN_WARNING "xtkbd.c: Unknown key (scancode %#x) %s.\n", |
85 | data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed"); | 83 | data & XTKBD_KEY, data & XTKBD_RELEASE ? "released" : "pressed"); |
@@ -91,62 +89,60 @@ static irqreturn_t xtkbd_interrupt(struct serio *serio, | |||
91 | static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) | 89 | static int xtkbd_connect(struct serio *serio, struct serio_driver *drv) |
92 | { | 90 | { |
93 | struct xtkbd *xtkbd; | 91 | struct xtkbd *xtkbd; |
92 | struct input_dev *input_dev; | ||
93 | int err = -ENOMEM; | ||
94 | int i; | 94 | int i; |
95 | int err; | ||
96 | |||
97 | if (!(xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL))) | ||
98 | return -ENOMEM; | ||
99 | |||
100 | memset(xtkbd, 0, sizeof(struct xtkbd)); | ||
101 | 95 | ||
102 | xtkbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 96 | xtkbd = kmalloc(sizeof(struct xtkbd), GFP_KERNEL); |
97 | input_dev = input_allocate_device(); | ||
98 | if (!xtkbd || !input_dev) | ||
99 | goto fail; | ||
103 | 100 | ||
104 | xtkbd->serio = serio; | 101 | xtkbd->serio = serio; |
102 | xtkbd->dev = input_dev; | ||
103 | sprintf(xtkbd->phys, "%s/input0", serio->phys); | ||
104 | memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode)); | ||
105 | 105 | ||
106 | init_input_dev(&xtkbd->dev); | 106 | input_dev->name = "XT Keyboard"; |
107 | xtkbd->dev.keycode = xtkbd->keycode; | 107 | input_dev->phys = xtkbd->phys; |
108 | xtkbd->dev.keycodesize = sizeof(unsigned char); | 108 | input_dev->id.bustype = BUS_XTKBD; |
109 | xtkbd->dev.keycodemax = ARRAY_SIZE(xtkbd_keycode); | 109 | input_dev->id.vendor = 0x0001; |
110 | xtkbd->dev.private = xtkbd; | 110 | input_dev->id.product = 0x0001; |
111 | 111 | input_dev->id.version = 0x0100; | |
112 | serio_set_drvdata(serio, xtkbd); | 112 | input_dev->cdev.dev = &serio->dev; |
113 | input_dev->private = xtkbd; | ||
113 | 114 | ||
114 | err = serio_open(serio, drv); | 115 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
115 | if (err) { | 116 | input_dev->keycode = xtkbd->keycode; |
116 | serio_set_drvdata(serio, NULL); | 117 | input_dev->keycodesize = sizeof(unsigned char); |
117 | kfree(xtkbd); | 118 | input_dev->keycodemax = ARRAY_SIZE(xtkbd_keycode); |
118 | return err; | ||
119 | } | ||
120 | 119 | ||
121 | memcpy(xtkbd->keycode, xtkbd_keycode, sizeof(xtkbd->keycode)); | ||
122 | for (i = 0; i < 255; i++) | 120 | for (i = 0; i < 255; i++) |
123 | set_bit(xtkbd->keycode[i], xtkbd->dev.keybit); | 121 | set_bit(xtkbd->keycode[i], input_dev->keybit); |
124 | clear_bit(0, xtkbd->dev.keybit); | 122 | clear_bit(0, input_dev->keybit); |
125 | |||
126 | sprintf(xtkbd->phys, "%s/input0", serio->phys); | ||
127 | |||
128 | xtkbd->dev.name = xtkbd_name; | ||
129 | xtkbd->dev.phys = xtkbd->phys; | ||
130 | xtkbd->dev.id.bustype = BUS_XTKBD; | ||
131 | xtkbd->dev.id.vendor = 0x0001; | ||
132 | xtkbd->dev.id.product = 0x0001; | ||
133 | xtkbd->dev.id.version = 0x0100; | ||
134 | xtkbd->dev.dev = &serio->dev; | ||
135 | 123 | ||
136 | input_register_device(&xtkbd->dev); | 124 | serio_set_drvdata(serio, xtkbd); |
137 | 125 | ||
138 | printk(KERN_INFO "input: %s on %s\n", xtkbd_name, serio->phys); | 126 | err = serio_open(serio, drv); |
127 | if (err) | ||
128 | goto fail; | ||
139 | 129 | ||
130 | input_register_device(xtkbd->dev); | ||
140 | return 0; | 131 | return 0; |
132 | |||
133 | fail: serio_set_drvdata(serio, NULL); | ||
134 | input_free_device(input_dev); | ||
135 | kfree(xtkbd); | ||
136 | return err; | ||
141 | } | 137 | } |
142 | 138 | ||
143 | static void xtkbd_disconnect(struct serio *serio) | 139 | static void xtkbd_disconnect(struct serio *serio) |
144 | { | 140 | { |
145 | struct xtkbd *xtkbd = serio_get_drvdata(serio); | 141 | struct xtkbd *xtkbd = serio_get_drvdata(serio); |
146 | 142 | ||
147 | input_unregister_device(&xtkbd->dev); | ||
148 | serio_close(serio); | 143 | serio_close(serio); |
149 | serio_set_drvdata(serio, NULL); | 144 | serio_set_drvdata(serio, NULL); |
145 | input_unregister_device(xtkbd->dev); | ||
150 | kfree(xtkbd); | 146 | kfree(xtkbd); |
151 | } | 147 | } |
152 | 148 | ||