Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 24822
b: refs/heads/master
c: 102c8c7
h: refs/heads/master
v: v3
  • Loading branch information
Helge Deller authored and Kyle McMartin committed Mar 30, 2006
1 parent d17878a commit 9599039
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 94 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 10267cdd0c2dee46a3f59d93fbfac7229d416dba
refs/heads/master: 102c8c76f787add0790406d5c47e03cb6f8765c2
57 changes: 31 additions & 26 deletions trunk/drivers/input/keyboard/hil_kbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static unsigned int hil_kbd_set3[HIL_KEYCODES_SET3_TBLSIZE] =
static char hil_language[][16] = { HIL_LOCALE_MAP };

struct hil_kbd {
struct input_dev dev;
struct input_dev *dev;
struct serio *serio;

/* Input buffer and index for packets from HIL bus. */
Expand All @@ -86,7 +86,7 @@ struct hil_kbd {
/* Process a complete packet after transfer from the HIL */
static void hil_kbd_process_record(struct hil_kbd *kbd)
{
struct input_dev *dev = &kbd->dev;
struct input_dev *dev = kbd->dev;
hil_packet *data = kbd->data;
hil_packet p;
int idx, i, cnt;
Expand Down Expand Up @@ -240,8 +240,9 @@ static void hil_kbd_disconnect(struct serio *serio)
return;
}

input_unregister_device(&kbd->dev);
input_unregister_device(kbd->dev);
serio_close(serio);
input_free_device(kbd->dev);
kfree(kbd);
}

Expand All @@ -251,16 +252,18 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
uint8_t did, *idd;
int i;

kbd = kmalloc(sizeof(*kbd), GFP_KERNEL);
kbd = kzalloc(sizeof(*kbd), GFP_KERNEL);
if (!kbd)
return -ENOMEM;
memset(kbd, 0, sizeof(struct hil_kbd));

kbd->dev = input_allocate_device();
if (!kbd->dev) goto bail1;
kbd->dev->private = kbd;

if (serio_open(serio, drv)) goto bail0;

serio_set_drvdata(serio, kbd);
kbd->serio = serio;
kbd->dev.private = kbd;

init_MUTEX_LOCKED(&(kbd->sem));

Expand Down Expand Up @@ -302,38 +305,38 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]);
break;
default:
goto bail1;
goto bail2;
}

if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) {
printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n");
goto bail1;
goto bail2;
}


kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
kbd->dev.keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
kbd->dev.keycodesize = sizeof(hil_kbd_set1[0]);
kbd->dev.keycode = hil_kbd_set1;
kbd->dev.name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME;
kbd->dev.phys = "hpkbd/input0"; /* XXX */
kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
kbd->dev->keycodesize = sizeof(hil_kbd_set1[0]);
kbd->dev->keycode = hil_kbd_set1;
kbd->dev->name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME;
kbd->dev->phys = "hpkbd/input0"; /* XXX */

kbd->dev.id.bustype = BUS_HIL;
kbd->dev.id.vendor = PCI_VENDOR_ID_HP;
kbd->dev.id.product = 0x0001; /* TODO: get from kbd->rsc */
kbd->dev.id.version = 0x0100; /* TODO: get from kbd->rsc */
kbd->dev.dev = &serio->dev;
kbd->dev->id.bustype = BUS_HIL;
kbd->dev->id.vendor = PCI_VENDOR_ID_HP;
kbd->dev->id.product = 0x0001; /* TODO: get from kbd->rsc */
kbd->dev->id.version = 0x0100; /* TODO: get from kbd->rsc */
kbd->dev->dev = &serio->dev;

for (i = 0; i < 128; i++) {
set_bit(hil_kbd_set1[i], kbd->dev.keybit);
set_bit(hil_kbd_set3[i], kbd->dev.keybit);
set_bit(hil_kbd_set1[i], kbd->dev->keybit);
set_bit(hil_kbd_set3[i], kbd->dev->keybit);
}
clear_bit(0, kbd->dev.keybit);
clear_bit(0, kbd->dev->keybit);

input_register_device(&kbd->dev);
input_register_device(kbd->dev);
printk(KERN_INFO "input: %s, ID: %d\n",
kbd->dev.name, did);
kbd->dev->name, did);

serio->write(serio, 0);
serio->write(serio, 0);
Expand All @@ -343,8 +346,10 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
up(&(kbd->sem));

return 0;
bail1:
bail2:
serio_close(serio);
bail1:
input_free_device(kbd->dev);
bail0:
kfree(kbd);
serio_set_drvdata(serio, NULL);
Expand Down
54 changes: 30 additions & 24 deletions trunk/drivers/input/keyboard/hilkbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (C) 1998 Philip Blundell <philb@gnu.org>
* Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai>
* Copyright (C) 1999-2003 Helge Deller <deller@gmx.de>
* Copyright (C) 1999-2006 Helge Deller <deller@gmx.de>
*
* Very basic HP Human Interface Loop (HIL) driver.
* This driver handles the keyboard on HP300 (m68k) and on some
Expand Down Expand Up @@ -90,7 +90,7 @@ static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] =

/* HIL structure */
static struct {
struct input_dev dev;
struct input_dev *dev;

unsigned int curdev;

Expand All @@ -117,7 +117,7 @@ static void poll_finished(void)
down = (hil_dev.data[1] & 1) == 0;
scode = hil_dev.data[1] >> 1;
key = hphilkeyb_keycode[scode];
input_report_key(&hil_dev.dev, key, down);
input_report_key(hil_dev.dev, key, down);
break;
}
hil_dev.curdev = 0;
Expand Down Expand Up @@ -207,9 +207,14 @@ hil_keyb_init(void)
unsigned int i, kbid;
wait_queue_head_t hil_wait;

if (hil_dev.dev.id.bustype) {
if (hil_dev.dev) {
return -ENODEV; /* already initialized */
}

hil_dev.dev = input_allocate_device();
if (!hil_dev.dev)
return -ENOMEM;
hil_dev.dev->private = &hil_dev;

#if defined(CONFIG_HP300)
if (!hwreg_present((void *)(HILBASE + HIL_DATA)))
Expand Down Expand Up @@ -247,28 +252,26 @@ hil_keyb_init(void)
c = 0;
hil_do(HIL_WRITEKBDSADR, &c, 1);

init_input_dev(&hil_dev.dev);

for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++)
if (hphilkeyb_keycode[i] != KEY_RESERVED)
set_bit(hphilkeyb_keycode[i], hil_dev.dev.keybit);

hil_dev.dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
hil_dev.dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
hil_dev.dev.keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
hil_dev.dev.keycodesize = sizeof(hphilkeyb_keycode[0]);
hil_dev.dev.keycode = hphilkeyb_keycode;
hil_dev.dev.name = "HIL keyboard";
hil_dev.dev.phys = "hpkbd/input0";

hil_dev.dev.id.bustype = BUS_HIL;
hil_dev.dev.id.vendor = PCI_VENDOR_ID_HP;
hil_dev.dev.id.product = 0x0001;
hil_dev.dev.id.version = 0x0010;

input_register_device(&hil_dev.dev);
set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit);

hil_dev.dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
hil_dev.dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
hil_dev.dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
hil_dev.dev->keycodesize = sizeof(hphilkeyb_keycode[0]);
hil_dev.dev->keycode = hphilkeyb_keycode;
hil_dev.dev->name = "HIL keyboard";
hil_dev.dev->phys = "hpkbd/input0";

hil_dev.dev->id.bustype = BUS_HIL;
hil_dev.dev->id.vendor = PCI_VENDOR_ID_HP;
hil_dev.dev->id.product = 0x0001;
hil_dev.dev->id.version = 0x0010;

input_register_device(hil_dev.dev);
printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n",
hil_dev.dev.name, kbid, HILBASE, HIL_IRQ);
hil_dev.dev->name, kbid, HILBASE, HIL_IRQ);

return 0;
}
Expand Down Expand Up @@ -329,7 +332,10 @@ static void __exit hil_exit(void)
/* Turn off interrupts */
hil_do(HIL_INTOFF, NULL, 0);

input_unregister_device(&hil_dev.dev);
input_unregister_device(hil_dev.dev);

input_free_device(hil_dev.dev);
hil_dev.dev = NULL;

#if defined(CONFIG_PARISC)
unregister_parisc_driver(&hil_driver);
Expand Down
Loading

0 comments on commit 9599039

Please sign in to comment.