aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
authorHelge Deller <deller@parisc-linux.org>2006-03-26 09:41:55 -0500
committerKyle McMartin <kyle@hera.kernel.org>2006-03-30 12:48:53 -0500
commit102c8c76f787add0790406d5c47e03cb6f8765c2 (patch)
treefc61e0f94c48b051bd12590abd085e12d14e8ef1 /drivers/input/keyboard
parent10267cdd0c2dee46a3f59d93fbfac7229d416dba (diff)
[PARISC] Convert HIL drivers to use input_allocate_device
Convert HIL drivers to use input_allocate_device() - avoids crashes. Signed-off-by: Helge Deller <deller@parisc-linux.org> Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/hil_kbd.c57
-rw-r--r--drivers/input/keyboard/hilkbd.c54
2 files changed, 61 insertions, 50 deletions
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c
index 0a90962c38e7..99f8c5b4cd50 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] =
66static char hil_language[][16] = { HIL_LOCALE_MAP }; 66static char hil_language[][16] = { HIL_LOCALE_MAP };
67 67
68struct hil_kbd { 68struct 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 */
87static void hil_kbd_process_record(struct hil_kbd *kbd) 87static 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,9 @@ static void hil_kbd_disconnect(struct serio *serio)
240 return; 240 return;
241 } 241 }
242 242
243 input_unregister_device(&kbd->dev); 243 input_unregister_device(kbd->dev);
244 serio_close(serio); 244 serio_close(serio);
245 input_free_device(kbd->dev);
245 kfree(kbd); 246 kfree(kbd);
246} 247}
247 248
@@ -251,16 +252,18 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
251 uint8_t did, *idd; 252 uint8_t did, *idd;
252 int i; 253 int i;
253 254
254 kbd = kmalloc(sizeof(*kbd), GFP_KERNEL); 255 kbd = kzalloc(sizeof(*kbd), GFP_KERNEL);
255 if (!kbd) 256 if (!kbd)
256 return -ENOMEM; 257 return -ENOMEM;
257 memset(kbd, 0, sizeof(struct hil_kbd)); 258
259 kbd->dev = input_allocate_device();
260 if (!kbd->dev) goto bail1;
261 kbd->dev->private = kbd;
258 262
259 if (serio_open(serio, drv)) goto bail0; 263 if (serio_open(serio, drv)) goto bail0;
260 264
261 serio_set_drvdata(serio, kbd); 265 serio_set_drvdata(serio, kbd);
262 kbd->serio = serio; 266 kbd->serio = serio;
263 kbd->dev.private = kbd;
264 267
265 init_MUTEX_LOCKED(&(kbd->sem)); 268 init_MUTEX_LOCKED(&(kbd->sem));
266 269
@@ -302,38 +305,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]); 305 did, hil_language[did & HIL_IDD_DID_TYPE_KB_LANG_MASK]);
303 break; 306 break;
304 default: 307 default:
305 goto bail1; 308 goto bail2;
306 } 309 }
307 310
308 if(HIL_IDD_NUM_BUTTONS(idd) || HIL_IDD_NUM_AXES_PER_SET(*idd)) { 311 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"); 312 printk(KERN_INFO PREFIX "keyboards only, no combo devices supported.\n");
310 goto bail1; 313 goto bail2;
311 } 314 }
312 315
313 316
314 kbd->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 317 kbd->dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
315 kbd->dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); 318 kbd->dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
316 kbd->dev.keycodemax = HIL_KEYCODES_SET1_TBLSIZE; 319 kbd->dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
317 kbd->dev.keycodesize = sizeof(hil_kbd_set1[0]); 320 kbd->dev->keycodesize = sizeof(hil_kbd_set1[0]);
318 kbd->dev.keycode = hil_kbd_set1; 321 kbd->dev->keycode = hil_kbd_set1;
319 kbd->dev.name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME; 322 kbd->dev->name = strlen(kbd->rnm) ? kbd->rnm : HIL_GENERIC_NAME;
320 kbd->dev.phys = "hpkbd/input0"; /* XXX */ 323 kbd->dev->phys = "hpkbd/input0"; /* XXX */
321 324
322 kbd->dev.id.bustype = BUS_HIL; 325 kbd->dev->id.bustype = BUS_HIL;
323 kbd->dev.id.vendor = PCI_VENDOR_ID_HP; 326 kbd->dev->id.vendor = PCI_VENDOR_ID_HP;
324 kbd->dev.id.product = 0x0001; /* TODO: get from kbd->rsc */ 327 kbd->dev->id.product = 0x0001; /* TODO: get from kbd->rsc */
325 kbd->dev.id.version = 0x0100; /* TODO: get from kbd->rsc */ 328 kbd->dev->id.version = 0x0100; /* TODO: get from kbd->rsc */
326 kbd->dev.dev = &serio->dev; 329 kbd->dev->dev = &serio->dev;
327 330
328 for (i = 0; i < 128; i++) { 331 for (i = 0; i < 128; i++) {
329 set_bit(hil_kbd_set1[i], kbd->dev.keybit); 332 set_bit(hil_kbd_set1[i], kbd->dev->keybit);
330 set_bit(hil_kbd_set3[i], kbd->dev.keybit); 333 set_bit(hil_kbd_set3[i], kbd->dev->keybit);
331 } 334 }
332 clear_bit(0, kbd->dev.keybit); 335 clear_bit(0, kbd->dev->keybit);
333 336
334 input_register_device(&kbd->dev); 337 input_register_device(kbd->dev);
335 printk(KERN_INFO "input: %s, ID: %d\n", 338 printk(KERN_INFO "input: %s, ID: %d\n",
336 kbd->dev.name, did); 339 kbd->dev->name, did);
337 340
338 serio->write(serio, 0); 341 serio->write(serio, 0);
339 serio->write(serio, 0); 342 serio->write(serio, 0);
@@ -343,8 +346,10 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv)
343 up(&(kbd->sem)); 346 up(&(kbd->sem));
344 347
345 return 0; 348 return 0;
346 bail1: 349 bail2:
347 serio_close(serio); 350 serio_close(serio);
351 bail1:
352 input_free_device(kbd->dev);
348 bail0: 353 bail0:
349 kfree(kbd); 354 kfree(kbd);
350 serio_set_drvdata(serio, NULL); 355 serio_set_drvdata(serio, NULL);
diff --git a/drivers/input/keyboard/hilkbd.c b/drivers/input/keyboard/hilkbd.c
index e95bc052e32a..452c5f3e6129 100644
--- a/drivers/input/keyboard/hilkbd.c
+++ b/drivers/input/keyboard/hilkbd.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (C) 1998 Philip Blundell <philb@gnu.org> 4 * Copyright (C) 1998 Philip Blundell <philb@gnu.org>
5 * Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai> 5 * Copyright (C) 1999 Matthew Wilcox <willy@bofh.ai>
6 * Copyright (C) 1999-2003 Helge Deller <deller@gmx.de> 6 * Copyright (C) 1999-2006 Helge Deller <deller@gmx.de>
7 * 7 *
8 * Very basic HP Human Interface Loop (HIL) driver. 8 * Very basic HP Human Interface Loop (HIL) driver.
9 * This driver handles the keyboard on HP300 (m68k) and on some 9 * This driver handles the keyboard on HP300 (m68k) and on some
@@ -90,7 +90,7 @@ static unsigned int hphilkeyb_keycode[HIL_KEYCODES_SET1_TBLSIZE] =
90 90
91/* HIL structure */ 91/* HIL structure */
92static struct { 92static struct {
93 struct input_dev dev; 93 struct input_dev *dev;
94 94
95 unsigned int curdev; 95 unsigned int curdev;
96 96
@@ -117,7 +117,7 @@ static void poll_finished(void)
117 down = (hil_dev.data[1] & 1) == 0; 117 down = (hil_dev.data[1] & 1) == 0;
118 scode = hil_dev.data[1] >> 1; 118 scode = hil_dev.data[1] >> 1;
119 key = hphilkeyb_keycode[scode]; 119 key = hphilkeyb_keycode[scode];
120 input_report_key(&hil_dev.dev, key, down); 120 input_report_key(hil_dev.dev, key, down);
121 break; 121 break;
122 } 122 }
123 hil_dev.curdev = 0; 123 hil_dev.curdev = 0;
@@ -207,9 +207,14 @@ hil_keyb_init(void)
207 unsigned int i, kbid; 207 unsigned int i, kbid;
208 wait_queue_head_t hil_wait; 208 wait_queue_head_t hil_wait;
209 209
210 if (hil_dev.dev.id.bustype) { 210 if (hil_dev.dev) {
211 return -ENODEV; /* already initialized */ 211 return -ENODEV; /* already initialized */
212 } 212 }
213
214 hil_dev.dev = input_allocate_device();
215 if (!hil_dev.dev)
216 return -ENOMEM;
217 hil_dev.dev->private = &hil_dev;
213 218
214#if defined(CONFIG_HP300) 219#if defined(CONFIG_HP300)
215 if (!hwreg_present((void *)(HILBASE + HIL_DATA))) 220 if (!hwreg_present((void *)(HILBASE + HIL_DATA)))
@@ -247,28 +252,26 @@ hil_keyb_init(void)
247 c = 0; 252 c = 0;
248 hil_do(HIL_WRITEKBDSADR, &c, 1); 253 hil_do(HIL_WRITEKBDSADR, &c, 1);
249 254
250 init_input_dev(&hil_dev.dev);
251
252 for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++) 255 for (i = 0; i < HIL_KEYCODES_SET1_TBLSIZE; i++)
253 if (hphilkeyb_keycode[i] != KEY_RESERVED) 256 if (hphilkeyb_keycode[i] != KEY_RESERVED)
254 set_bit(hphilkeyb_keycode[i], hil_dev.dev.keybit); 257 set_bit(hphilkeyb_keycode[i], hil_dev.dev->keybit);
255 258
256 hil_dev.dev.evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 259 hil_dev.dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
257 hil_dev.dev.ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL); 260 hil_dev.dev->ledbit[0] = BIT(LED_NUML) | BIT(LED_CAPSL) | BIT(LED_SCROLLL);
258 hil_dev.dev.keycodemax = HIL_KEYCODES_SET1_TBLSIZE; 261 hil_dev.dev->keycodemax = HIL_KEYCODES_SET1_TBLSIZE;
259 hil_dev.dev.keycodesize = sizeof(hphilkeyb_keycode[0]); 262 hil_dev.dev->keycodesize = sizeof(hphilkeyb_keycode[0]);
260 hil_dev.dev.keycode = hphilkeyb_keycode; 263 hil_dev.dev->keycode = hphilkeyb_keycode;
261 hil_dev.dev.name = "HIL keyboard"; 264 hil_dev.dev->name = "HIL keyboard";
262 hil_dev.dev.phys = "hpkbd/input0"; 265 hil_dev.dev->phys = "hpkbd/input0";
263 266
264 hil_dev.dev.id.bustype = BUS_HIL; 267 hil_dev.dev->id.bustype = BUS_HIL;
265 hil_dev.dev.id.vendor = PCI_VENDOR_ID_HP; 268 hil_dev.dev->id.vendor = PCI_VENDOR_ID_HP;
266 hil_dev.dev.id.product = 0x0001; 269 hil_dev.dev->id.product = 0x0001;
267 hil_dev.dev.id.version = 0x0010; 270 hil_dev.dev->id.version = 0x0010;
268 271
269 input_register_device(&hil_dev.dev); 272 input_register_device(hil_dev.dev);
270 printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n", 273 printk(KERN_INFO "input: %s, ID %d at 0x%08lx (irq %d) found and attached\n",
271 hil_dev.dev.name, kbid, HILBASE, HIL_IRQ); 274 hil_dev.dev->name, kbid, HILBASE, HIL_IRQ);
272 275
273 return 0; 276 return 0;
274} 277}
@@ -329,7 +332,10 @@ static void __exit hil_exit(void)
329 /* Turn off interrupts */ 332 /* Turn off interrupts */
330 hil_do(HIL_INTOFF, NULL, 0); 333 hil_do(HIL_INTOFF, NULL, 0);
331 334
332 input_unregister_device(&hil_dev.dev); 335 input_unregister_device(hil_dev.dev);
336
337 input_free_device(hil_dev.dev);
338 hil_dev.dev = NULL;
333 339
334#if defined(CONFIG_PARISC) 340#if defined(CONFIG_PARISC)
335 unregister_parisc_driver(&hil_driver); 341 unregister_parisc_driver(&hil_driver);