Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: wistron - add PM support

Register wistron-bios as a platform device, restore WIFI and
Bluetooth state upon resume.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>

+57 -5
+57 -5
drivers/input/misc/wistron_btns.c
··· 2 2 * Wistron laptop button driver 3 3 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz> 4 4 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org> 5 + * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> 5 6 * 6 7 * You can redistribute and/or modify this program under the terms of the 7 8 * GNU General Public License version 2 as published by the Free Software ··· 29 28 #include <linux/string.h> 30 29 #include <linux/timer.h> 31 30 #include <linux/types.h> 31 + #include <linux/platform_device.h> 32 32 33 33 /* 34 34 * Number of attempts to read data from queue per poll; ··· 59 57 static char *keymap_name; /* = NULL; */ 60 58 module_param_named(keymap, keymap_name, charp, 0); 61 59 MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected"); 60 + 61 + static struct platform_device *wistron_device; 62 62 63 63 /* BIOS interface implementation */ 64 64 ··· 360 356 input_dev->name = "Wistron laptop buttons"; 361 357 input_dev->phys = "wistron/input0"; 362 358 input_dev->id.bustype = BUS_HOST; 359 + input_dev->cdev.dev = &wistron_device->dev; 363 360 364 361 for (key = keymap; key->type != KE_END; key++) { 365 362 if (key->type == KE_KEY) { ··· 447 442 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY); 448 443 } 449 444 445 + static int wistron_suspend(struct platform_device *dev, pm_message_t state) 446 + { 447 + del_timer_sync(&poll_timer); 448 + 449 + return 0; 450 + } 451 + 452 + static int wistron_resume(struct platform_device *dev) 453 + { 454 + if (have_wifi) 455 + bios_set_state(WIFI, wifi_enabled); 456 + 457 + if (have_bluetooth) 458 + bios_set_state(BLUETOOTH, bluetooth_enabled); 459 + 460 + poll_bios(1); 461 + 462 + return 0; 463 + } 464 + 465 + static struct platform_driver wistron_driver = { 466 + .suspend = wistron_suspend, 467 + .resume = wistron_resume, 468 + .driver = { 469 + .name = "wistron-bios", 470 + }, 471 + }; 472 + 450 473 static int __init wb_module_init(void) 451 474 { 452 475 int err; ··· 489 456 490 457 bios_attach(); 491 458 cmos_address = bios_get_cmos_address(); 459 + 460 + err = platform_driver_register(&wistron_driver); 461 + if (err) 462 + goto err_detach_bios; 463 + 464 + wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0); 465 + if (IS_ERR(wistron_device)) { 466 + err = PTR_ERR(wistron_device); 467 + goto err_unregister_driver; 468 + } 492 469 493 470 if (have_wifi) { 494 471 u16 wifi = bios_get_default_setting(WIFI); ··· 523 480 } 524 481 525 482 err = setup_input_dev(); 526 - if (err) { 527 - bios_detach(); 528 - unmap_bios(); 529 - return err; 530 - } 483 + if (err) 484 + goto err_unregister_device; 531 485 532 486 poll_bios(1); /* Flush stale event queue and arm timer */ 533 487 534 488 return 0; 489 + 490 + err_unregister_device: 491 + platform_device_unregister(wistron_device); 492 + err_unregister_driver: 493 + platform_driver_unregister(&wistron_driver); 494 + err_detach_bios: 495 + bios_detach(); 496 + unmap_bios(); 497 + 498 + return err; 535 499 } 536 500 537 501 static void __exit wb_module_exit(void) 538 502 { 539 503 del_timer_sync(&poll_timer); 540 504 input_unregister_device(input_dev); 505 + platform_device_unregister(wistron_device); 506 + platform_driver_unregister(&wistron_driver); 541 507 bios_detach(); 542 508 unmap_bios(); 543 509 }