* Wistron laptop button driver
* Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
* Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
+ * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
*
* You can redistribute and/or modify this program under the terms of the
* GNU General Public License version 2 as published by the Free Software
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/types.h>
+#include <linux/platform_device.h>
/*
* Number of attempts to read data from queue per poll;
module_param_named(keymap, keymap_name, charp, 0);
MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected");
+static struct platform_device *wistron_device;
+
/* BIOS interface implementation */
static void __iomem *bios_entry_point; /* BIOS routine entry point */
input_dev->name = "Wistron laptop buttons";
input_dev->phys = "wistron/input0";
input_dev->id.bustype = BUS_HOST;
+ input_dev->cdev.dev = &wistron_device->dev;
for (key = keymap; key->type != KE_END; key++) {
if (key->type == KE_KEY) {
mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
}
+static int wistron_suspend(struct platform_device *dev, pm_message_t state)
+{
+ del_timer_sync(&poll_timer);
+
+ return 0;
+}
+
+static int wistron_resume(struct platform_device *dev)
+{
+ if (have_wifi)
+ bios_set_state(WIFI, wifi_enabled);
+
+ if (have_bluetooth)
+ bios_set_state(BLUETOOTH, bluetooth_enabled);
+
+ poll_bios(1);
+
+ return 0;
+}
+
+static struct platform_driver wistron_driver = {
+ .suspend = wistron_suspend,
+ .resume = wistron_resume,
+ .driver = {
+ .name = "wistron-bios",
+ },
+};
+
static int __init wb_module_init(void)
{
int err;
bios_attach();
cmos_address = bios_get_cmos_address();
+ err = platform_driver_register(&wistron_driver);
+ if (err)
+ goto err_detach_bios;
+
+ wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0);
+ if (IS_ERR(wistron_device)) {
+ err = PTR_ERR(wistron_device);
+ goto err_unregister_driver;
+ }
+
if (have_wifi) {
u16 wifi = bios_get_default_setting(WIFI);
if (wifi & 1)
}
err = setup_input_dev();
- if (err) {
- bios_detach();
- unmap_bios();
- return err;
- }
+ if (err)
+ goto err_unregister_device;
poll_bios(1); /* Flush stale event queue and arm timer */
return 0;
+
+ err_unregister_device:
+ platform_device_unregister(wistron_device);
+ err_unregister_driver:
+ platform_driver_unregister(&wistron_driver);
+ err_detach_bios:
+ bios_detach();
+ unmap_bios();
+
+ return err;
}
static void __exit wb_module_exit(void)
{
del_timer_sync(&poll_timer);
input_unregister_device(input_dev);
+ platform_device_unregister(wistron_device);
+ platform_driver_unregister(&wistron_driver);
bios_detach();
unmap_bios();
}