aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc/wistron_btns.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-11-20 00:50:46 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2005-11-20 00:50:46 -0500
commit22a397e2c189dedf857836f2a49542b8aedfeb65 (patch)
tree308297aafad1841a44106cd29d7975ee5d07d197 /drivers/input/misc/wistron_btns.c
parent84b256a66360cedc25eb6e2ac6f167ca9778307b (diff)
Input: wistron - convert to dynamic input_dev allocation
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/misc/wistron_btns.c')
-rw-r--r--drivers/input/misc/wistron_btns.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 6d7e865f900..b64798d838a 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -149,7 +149,7 @@ err:
149 return -ENOMEM; 149 return -ENOMEM;
150} 150}
151 151
152static void __exit unmap_bios(void) 152static inline void unmap_bios(void)
153{ 153{
154 iounmap(bios_code_map_base); 154 iounmap(bios_code_map_base);
155 iounmap(bios_data_map_base); 155 iounmap(bios_data_map_base);
@@ -180,7 +180,7 @@ static void __init bios_attach(void)
180 call_bios(&regs); 180 call_bios(&regs);
181} 181}
182 182
183static void __exit bios_detach(void) 183static void bios_detach(void)
184{ 184{
185 struct regs regs; 185 struct regs regs;
186 186
@@ -342,31 +342,43 @@ static int __init select_keymap(void)
342 342
343 /* Input layer interface */ 343 /* Input layer interface */
344 344
345static struct input_dev input_dev = { 345static struct input_dev *input_dev;
346 .name = "Wistron laptop buttons",
347};
348 346
349static void __init setup_input_dev(void) 347static int __init setup_input_dev(void)
350{ 348{
351 const struct key_entry *key; 349 const struct key_entry *key;
350 int error;
351
352 input_dev = input_allocate_device();
353 if (!input_dev)
354 return -ENOMEM;
355
356 input_dev->name = "Wistron laptop buttons";
357 input_dev->phys = "wistron/input0";
358 input_dev->id.bustype = BUS_HOST;
352 359
353 for (key = keymap; key->type != KE_END; key++) { 360 for (key = keymap; key->type != KE_END; key++) {
354 if (key->type == KE_KEY) { 361 if (key->type == KE_KEY) {
355 input_dev.evbit[LONG(EV_KEY)] = BIT(EV_KEY); 362 input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY);
356 input_dev.keybit[LONG(key->keycode)] 363 set_bit(key->keycode, input_dev->keybit);
357 |= BIT(key->keycode);
358 } 364 }
359 } 365 }
360 366
361 input_register_device(&input_dev); 367 error = input_register_device(input_dev);
368 if (error) {
369 input_free_device(input_dev);
370 return error;
371 }
372
373 return 0;
362} 374}
363 375
364static void report_key(unsigned keycode) 376static void report_key(unsigned keycode)
365{ 377{
366 input_report_key(&input_dev, keycode, 1); 378 input_report_key(input_dev, keycode, 1);
367 input_sync(&input_dev); 379 input_sync(input_dev);
368 input_report_key(&input_dev, keycode, 0); 380 input_report_key(input_dev, keycode, 0);
369 input_sync(&input_dev); 381 input_sync(input_dev);
370} 382}
371 383
372 /* Driver core */ 384 /* Driver core */
@@ -437,11 +449,14 @@ static int __init wb_module_init(void)
437 err = select_keymap(); 449 err = select_keymap();
438 if (err) 450 if (err)
439 return err; 451 return err;
452
440 err = map_bios(); 453 err = map_bios();
441 if (err) 454 if (err)
442 return err; 455 return err;
456
443 bios_attach(); 457 bios_attach();
444 cmos_address = bios_get_cmos_address(); 458 cmos_address = bios_get_cmos_address();
459
445 if (have_wifi) { 460 if (have_wifi) {
446 u16 wifi = bios_get_default_setting(WIFI); 461 u16 wifi = bios_get_default_setting(WIFI);
447 if (wifi & 1) 462 if (wifi & 1)
@@ -452,6 +467,7 @@ static int __init wb_module_init(void)
452 if (have_wifi) 467 if (have_wifi)
453 bios_set_state(WIFI, wifi_enabled); 468 bios_set_state(WIFI, wifi_enabled);
454 } 469 }
470
455 if (have_bluetooth) { 471 if (have_bluetooth) {
456 u16 bt = bios_get_default_setting(BLUETOOTH); 472 u16 bt = bios_get_default_setting(BLUETOOTH);
457 if (bt & 1) 473 if (bt & 1)
@@ -463,7 +479,12 @@ static int __init wb_module_init(void)
463 bios_set_state(BLUETOOTH, bluetooth_enabled); 479 bios_set_state(BLUETOOTH, bluetooth_enabled);
464 } 480 }
465 481
466 setup_input_dev(); 482 err = setup_input_dev();
483 if (err) {
484 bios_detach();
485 unmap_bios();
486 return err;
487 }
467 488
468 poll_bios(1); /* Flush stale event queue and arm timer */ 489 poll_bios(1); /* Flush stale event queue and arm timer */
469 490
@@ -473,7 +494,7 @@ static int __init wb_module_init(void)
473static void __exit wb_module_exit(void) 494static void __exit wb_module_exit(void)
474{ 495{
475 del_timer_sync(&poll_timer); 496 del_timer_sync(&poll_timer);
476 input_unregister_device(&input_dev); 497 input_unregister_device(input_dev);
477 bios_detach(); 498 bios_detach();
478 unmap_bios(); 499 unmap_bios();
479} 500}