diff options
Diffstat (limited to 'drivers/input/keyboard/hil_kbd.c')
-rw-r--r-- | drivers/input/keyboard/hil_kbd.c | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 0a90962c38e7..63f387e4b783 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -66,7 +66,7 @@ static unsigned int hil_kbd_set3[HIL_KEYCODES_SET3_TBLSIZE] = | |||
66 | static char hil_language[][16] = { HIL_LOCALE_MAP }; | 66 | static char hil_language[][16] = { HIL_LOCALE_MAP }; |
67 | 67 | ||
68 | struct hil_kbd { | 68 | struct hil_kbd { |
69 | struct input_dev dev; | 69 | struct input_dev *dev; |
70 | struct serio *serio; | 70 | struct serio *serio; |
71 | 71 | ||
72 | /* Input buffer and index for packets from HIL bus. */ | 72 | /* Input buffer and index for packets from HIL bus. */ |
@@ -86,7 +86,7 @@ struct hil_kbd { | |||
86 | /* Process a complete packet after transfer from the HIL */ | 86 | /* Process a complete packet after transfer from the HIL */ |
87 | static void hil_kbd_process_record(struct hil_kbd *kbd) | 87 | static void hil_kbd_process_record(struct hil_kbd *kbd) |
88 | { | 88 | { |
89 | struct input_dev *dev = &kbd->dev; | 89 | struct input_dev *dev = kbd->dev; |
90 | hil_packet *data = kbd->data; | 90 | hil_packet *data = kbd->data; |
91 | hil_packet p; | 91 | hil_packet p; |
92 | int idx, i, cnt; | 92 | int idx, i, cnt; |
@@ -240,8 +240,8 @@ static void hil_kbd_disconnect(struct serio *serio) | |||
240 | return; | 240 | return; |
241 | } | 241 | } |
242 | 242 | ||
243 | input_unregister_device(&kbd->dev); | ||
244 | serio_close(serio); | 243 | serio_close(serio); |
244 | input_unregister_device(kbd->dev); | ||
245 | kfree(kbd); | 245 | kfree(kbd); |
246 | } | 246 | } |
247 | 247 | ||
@@ -251,16 +251,18 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
251 | uint8_t did, *idd; | 251 | uint8_t did, *idd; |
252 | int i; | 252 | int i; |
253 | 253 | ||
254 | kbd = kmalloc(sizeof(*kbd), GFP_KERNEL); | 254 | kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); |
255 | if (!kbd) | 255 | if (!kbd) |
256 | return -ENOMEM; | 256 | return -ENOMEM; |
257 | memset(kbd, 0, sizeof(struct hil_kbd)); | 257 | |
258 | kbd->dev = input_allocate_device(); | ||
259 | if (!kbd->dev) goto bail1; | ||
260 | kbd->dev->private = kbd; | ||
258 | 261 | ||
259 | if (serio_open(serio, drv)) goto bail0; | 262 | if (serio_open(serio, drv)) goto bail0; |
260 | 263 | ||
261 | serio_set_drvdata(serio, kbd); | 264 | serio_set_drvdata(serio, kbd); |
262 | kbd->serio = serio; | 265 | kbd->serio = serio; |
263 | kbd->dev.private = kbd; | ||
264 | 266 | ||
265 | init_MUTEX_LOCKED(&(kbd->sem)); | 267 | init_MUTEX_LOCKED(&(kbd->sem)); |
266 | 268 | ||
@@ -302,38 +304,38 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
302 | did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]); | 304 | did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]); |
303 | break; | 305 | break; |
304 | default: | 306 | default: |
305 | goto bail1; | 307 | goto bail2; |
306 | } | 308 | } |
307 | 309 | ||
308 | if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { | 310 | if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { |
309 | printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); | 311 | printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); |
310 | goto bail1; | 312 | goto bail2; |
311 | } | 313 | } |
312 | 314 | ||
313 | 315 | ||
314 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 316 | kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
315 | kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 317 | kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); |
316 | kbd->dev.keycodemax = HIL_KEYCODES_SET1_TBLSIZE; | 318 | kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
317 | kbd->dev.keycodesize = sizeof(hil_kbd_set1[0]); | 319 | kbd->dev->keycodesize = sizeof(hil_kbd_set1[0]); |
318 | kbd->dev.keycode = hil_kbd_set1; | 320 | kbd->dev->keycode = hil_kbd_set1; |
319 | kbd->dev.name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME; | 321 | kbd->dev->name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME; |
320 | kbd->dev.phys = "hpkbd/input0"; /* XXX */ | 322 | kbd->dev->phys = "hpkbd/input0"; /* XXX */ |
321 | 323 | ||
322 | kbd->dev.id.bustype = BUS_HIL; | 324 | kbd->dev->id.bustype = BUS_HIL; |
323 | kbd->dev.id.vendor = PCI_VENDOR_ID_HP; | 325 | kbd->dev->id.vendor = PCI_VENDOR_ID_HP; |
324 | kbd->dev.id.product = 0x0001; /* TODO: get from kbd->rsc */ | 326 | kbd->dev->id.product = 0x0001; /* TODO: get from kbd->rsc */ |
325 | kbd->dev.id.version = 0x0100; /* TODO: get from kbd->rsc */ | 327 | kbd->dev->id.version = 0x0100; /* TODO: get from kbd->rsc */ |
326 | kbd->dev.dev = &serio->dev; | 328 | kbd->dev->dev = &serio->dev; |
327 | 329 | ||
328 | for (i = 0; i < 128; i++) { | 330 | for (i = 0; i < 128; i++) { |
329 | set_bit(hil_kbd_set1[i], kbd->dev.keybit); | 331 | set_bit(hil_kbd_set1[i], kbd->dev->keybit); |
330 | set_bit(hil_kbd_set3[i], kbd->dev.keybit); | 332 | set_bit(hil_kbd_set3[i], kbd->dev->keybit); |
331 | } | 333 | } |
332 | clear_bit(0, kbd->dev.keybit); | 334 | clear_bit(0, kbd->dev->keybit); |
333 | 335 | ||
334 | input_register_device(&kbd->dev); | 336 | input_register_device(kbd->dev); |
335 | printk(KERN_INFO "input: %s, ID: %d\n", | 337 | printk(KERN_INFO "input: %s, ID: %d\n", |
336 | kbd->dev.name, did); | 338 | kbd->dev->name, did); |
337 | 339 | ||
338 | serio->write(serio, 0); | 340 | serio->write(serio, 0); |
339 | serio->write(serio, 0); | 341 | serio->write(serio, 0); |
@@ -343,8 +345,10 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
343 | up(&(kbd->sem)); | 345 | up(&(kbd->sem)); |
344 | 346 | ||
345 | return 0; | 347 | return 0; |
346 | bail1: | 348 | bail2: |
347 | serio_close(serio); | 349 | serio_close(serio); |
350 | bail1: | ||
351 | input_free_device(kbd->dev); | ||
348 | bail0: | 352 | bail0: |
349 | kfree(kbd); | 353 | kfree(kbd); |
350 | serio_set_drvdata(serio, NULL); | 354 | serio_set_drvdata(serio, NULL); |