diff options
Diffstat (limited to 'drivers/input/keyboard/hil_kbd.c')
-rw-r--r-- | drivers/input/keyboard/hil_kbd.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index ed3271b71400..1dca3cf42a54 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 | ||
@@ -250,16 +250,22 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
250 | struct hil_kbd *kbd; | 250 | struct hil_kbd *kbd; |
251 | uint8_t did, *idd; | 251 | uint8_t did, *idd; |
252 | int i; | 252 | int i; |
253 | 253 | ||
254 | kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); | 254 | kbd = kzalloc(sizeof(*kbd), GFP_KERNEL); |
255 | if (!kbd) | 255 | if (!kbd) |
256 | return -ENOMEM; | 256 | return -ENOMEM; |
257 | 257 | ||
258 | if (serio_open(serio, drv)) goto bail0; | 258 | kbd->dev = input_allocate_device(); |
259 | if (!kbd->dev) | ||
260 | goto bail0; | ||
261 | |||
262 | kbd->dev->private = kbd; | ||
263 | |||
264 | if (serio_open(serio, drv)) | ||
265 | goto bail1; | ||
259 | 266 | ||
260 | serio_set_drvdata(serio, kbd); | 267 | serio_set_drvdata(serio, kbd); |
261 | kbd->serio = serio; | 268 | kbd->serio = serio; |
262 | kbd->dev.private = kbd; | ||
263 | 269 | ||
264 | init_MUTEX_LOCKED(&(kbd->sem)); | 270 | init_MUTEX_LOCKED(&(kbd->sem)); |
265 | 271 | ||
@@ -301,38 +307,38 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
301 | did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]); | 307 | did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]); |
302 | break; | 308 | break; |
303 | default: | 309 | default: |
304 | goto bail1; | 310 | goto bail2; |
305 | } | 311 | } |
306 | 312 | ||
307 | if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { | 313 | if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { |
308 | printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); | 314 | printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n"); |
309 | goto bail1; | 315 | goto bail2; |
310 | } | 316 | } |
311 | 317 | ||
312 | 318 | ||
313 | kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | 319 | kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); |
314 | kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); | 320 | kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); |
315 | kbd->dev.keycodemax = HIL_KEYCODES_SET1_TBLSIZE; | 321 | kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE; |
316 | kbd->dev.keycodesize = sizeof(hil_kbd_set1[0]); | 322 | kbd->dev->keycodesize = sizeof(hil_kbd_set1[0]); |
317 | kbd->dev.keycode = hil_kbd_set1; | 323 | kbd->dev->keycode = hil_kbd_set1; |
318 | kbd->dev.name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME; | 324 | kbd->dev->name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME; |
319 | kbd->dev.phys = "hpkbd/input0"; /* XXX */ | 325 | kbd->dev->phys = "hpkbd/input0"; /* XXX */ |
320 | 326 | ||
321 | kbd->dev.id.bustype = BUS_HIL; | 327 | kbd->dev->id.bustype = BUS_HIL; |
322 | kbd->dev.id.vendor = PCI_VENDOR_ID_HP; | 328 | kbd->dev->id.vendor = PCI_VENDOR_ID_HP; |
323 | kbd->dev.id.product = 0x0001; /* TODO: get from kbd->rsc */ | 329 | kbd->dev->id.product = 0x0001; /* TODO: get from kbd->rsc */ |
324 | kbd->dev.id.version = 0x0100; /* TODO: get from kbd->rsc */ | 330 | kbd->dev->id.version = 0x0100; /* TODO: get from kbd->rsc */ |
325 | kbd->dev.dev = &serio->dev; | 331 | kbd->dev->dev = &serio->dev; |
326 | 332 | ||
327 | for (i = 0; i < 128; i++) { | 333 | for (i = 0; i < 128; i++) { |
328 | set_bit(hil_kbd_set1[i], kbd->dev.keybit); | 334 | set_bit(hil_kbd_set1[i], kbd->dev->keybit); |
329 | set_bit(hil_kbd_set3[i], kbd->dev.keybit); | 335 | set_bit(hil_kbd_set3[i], kbd->dev->keybit); |
330 | } | 336 | } |
331 | clear_bit(0, kbd->dev.keybit); | 337 | clear_bit(0, kbd->dev->keybit); |
332 | 338 | ||
333 | input_register_device(&kbd->dev); | 339 | input_register_device(kbd->dev); |
334 | printk(KERN_INFO "input: %s, ID: %d\n", | 340 | printk(KERN_INFO "input: %s, ID: %d\n", |
335 | kbd->dev.name, did); | 341 | kbd->dev->name, did); |
336 | 342 | ||
337 | serio->write(serio, 0); | 343 | serio->write(serio, 0); |
338 | serio->write(serio, 0); | 344 | serio->write(serio, 0); |
@@ -342,8 +348,10 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
342 | up(&(kbd->sem)); | 348 | up(&(kbd->sem)); |
343 | 349 | ||
344 | return 0; | 350 | return 0; |
345 | bail1: | 351 | bail2: |
346 | serio_close(serio); | 352 | serio_close(serio); |
353 | bail1: | ||
354 | input_free_device(kbd->dev); | ||
347 | bail0: | 355 | bail0: |
348 | kfree(kbd); | 356 | kfree(kbd); |
349 | serio_set_drvdata(serio, NULL); | 357 | serio_set_drvdata(serio, NULL); |