aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2005-12-28 01:26:24 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2005-12-28 01:26:24 -0500
commite7c3aad53dba54d375b632f2a21b680546828dec (patch)
treeb724a6939a3d01d2edffce2e654e10f33876f5f3 /drivers/input/misc
parent9d6c25029db6de7fc375b07da936c3341af0accf (diff)
Input: wistron - convert to the new platform device interface
Do not use platform_device_register_simple() as it is going away, implement ->probe() and ->remove() functions so manual binding and unbinding would work. Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/wistron_btns.c114
1 files changed, 68 insertions, 46 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index b77e2692ba3a..a05b8557842f 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -174,7 +174,7 @@ static u16 bios_pop_queue(void)
174 return regs.eax; 174 return regs.eax;
175} 175}
176 176
177static void __init bios_attach(void) 177static void __devinit bios_attach(void)
178{ 178{
179 struct regs regs; 179 struct regs regs;
180 180
@@ -194,7 +194,7 @@ static void bios_detach(void)
194 call_bios(&regs); 194 call_bios(&regs);
195} 195}
196 196
197static u8 __init bios_get_cmos_address(void) 197static u8 __devinit bios_get_cmos_address(void)
198{ 198{
199 struct regs regs; 199 struct regs regs;
200 200
@@ -206,7 +206,7 @@ static u8 __init bios_get_cmos_address(void)
206 return regs.ecx; 206 return regs.ecx;
207} 207}
208 208
209static u16 __init bios_get_default_setting(u8 subsys) 209static u16 __devinit bios_get_default_setting(u8 subsys)
210{ 210{
211 struct regs regs; 211 struct regs regs;
212 212
@@ -367,7 +367,7 @@ static int __init select_keymap(void)
367 367
368static struct input_dev *input_dev; 368static struct input_dev *input_dev;
369 369
370static int __init setup_input_dev(void) 370static int __devinit setup_input_dev(void)
371{ 371{
372 const struct key_entry *key; 372 const struct key_entry *key;
373 int error; 373 int error;
@@ -466,6 +466,52 @@ static void poll_bios(unsigned long discard)
466 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); 466 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
467} 467}
468 468
469static int __devinit wistron_probe(struct platform_device *dev)
470{
471 int err = setup_input_dev();
472 if (err)
473 return err;
474
475 bios_attach();
476 cmos_address = bios_get_cmos_address();
477
478 if (have_wifi) {
479 u16 wifi = bios_get_default_setting(WIFI);
480 if (wifi & 1)
481 wifi_enabled = (wifi & 2) ? 1 : 0;
482 else
483 have_wifi = 0;
484
485 if (have_wifi)
486 bios_set_state(WIFI, wifi_enabled);
487 }
488
489 if (have_bluetooth) {
490 u16 bt = bios_get_default_setting(BLUETOOTH);
491 if (bt & 1)
492 bluetooth_enabled = (bt & 2) ? 1 : 0;
493 else
494 have_bluetooth = 0;
495
496 if (have_bluetooth)
497 bios_set_state(BLUETOOTH, bluetooth_enabled);
498 }
499
500 poll_bios(1); /* Flush stale event queue and arm timer */
501
502 return 0;
503}
504
505static int __devexit wistron_remove(struct platform_device *dev)
506{
507 del_timer_sync(&poll_timer);
508 input_unregister_device(input_dev);
509 bios_detach();
510
511 return 0;
512}
513
514#ifdef CONFIG_PM
469static int wistron_suspend(struct platform_device *dev, pm_message_t state) 515static int wistron_suspend(struct platform_device *dev, pm_message_t state)
470{ 516{
471 del_timer_sync(&poll_timer); 517 del_timer_sync(&poll_timer);
@@ -491,13 +537,20 @@ static int wistron_resume(struct platform_device *dev)
491 537
492 return 0; 538 return 0;
493} 539}
540#else
541#define wistron_suspend NULL
542#define wistron_resume NULL
543#endif
494 544
495static struct platform_driver wistron_driver = { 545static struct platform_driver wistron_driver = {
496 .suspend = wistron_suspend,
497 .resume = wistron_resume,
498 .driver = { 546 .driver = {
499 .name = "wistron-bios", 547 .name = "wistron-bios",
548 .owner = THIS_MODULE,
500 }, 549 },
550 .probe = wistron_probe,
551 .remove = __devexit_p(wistron_remove),
552 .suspend = wistron_suspend,
553 .resume = wistron_resume,
501}; 554};
502 555
503static int __init wb_module_init(void) 556static int __init wb_module_init(void)
@@ -512,55 +565,27 @@ static int __init wb_module_init(void)
512 if (err) 565 if (err)
513 return err; 566 return err;
514 567
515 bios_attach();
516 cmos_address = bios_get_cmos_address();
517
518 err = platform_driver_register(&wistron_driver); 568 err = platform_driver_register(&wistron_driver);
519 if (err) 569 if (err)
520 goto err_detach_bios; 570 goto err_unmap_bios;
521 571
522 wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0); 572 wistron_device = platform_device_alloc("wistron-bios", -1);
523 if (IS_ERR(wistron_device)) { 573 if (!wistron_device) {
524 err = PTR_ERR(wistron_device); 574 err = -ENOMEM;
525 goto err_unregister_driver; 575 goto err_unregister_driver;
526 } 576 }
527 577
528 if (have_wifi) { 578 err = platform_device_add(wistron_device);
529 u16 wifi = bios_get_default_setting(WIFI);
530 if (wifi & 1)
531 wifi_enabled = (wifi & 2) ? 1 : 0;
532 else
533 have_wifi = 0;
534
535 if (have_wifi)
536 bios_set_state(WIFI, wifi_enabled);
537 }
538
539 if (have_bluetooth) {
540 u16 bt = bios_get_default_setting(BLUETOOTH);
541 if (bt & 1)
542 bluetooth_enabled = (bt & 2) ? 1 : 0;
543 else
544 have_bluetooth = 0;
545
546 if (have_bluetooth)
547 bios_set_state(BLUETOOTH, bluetooth_enabled);
548 }
549
550 err = setup_input_dev();
551 if (err) 579 if (err)
552 goto err_unregister_device; 580 goto err_free_device;
553
554 poll_bios(1); /* Flush stale event queue and arm timer */
555 581
556 return 0; 582 return 0;
557 583
558 err_unregister_device: 584 err_free_device:
559 platform_device_unregister(wistron_device); 585 platform_device_put(wistron_device);
560 err_unregister_driver: 586 err_unregister_driver:
561 platform_driver_unregister(&wistron_driver); 587 platform_driver_unregister(&wistron_driver);
562 err_detach_bios: 588 err_unmap_bios:
563 bios_detach();
564 unmap_bios(); 589 unmap_bios();
565 590
566 return err; 591 return err;
@@ -568,11 +593,8 @@ static int __init wb_module_init(void)
568 593
569static void __exit wb_module_exit(void) 594static void __exit wb_module_exit(void)
570{ 595{
571 del_timer_sync(&poll_timer);
572 input_unregister_device(input_dev);
573 platform_device_unregister(wistron_device); 596 platform_device_unregister(wistron_device);
574 platform_driver_unregister(&wistron_driver); 597 platform_driver_unregister(&wistron_driver);
575 bios_detach();
576 unmap_bios(); 598 unmap_bios();
577} 599}
578 600