Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 14530
b: refs/heads/master
c: a5b0cc8
h: refs/heads/master
v: v3
  • Loading branch information
Dmitry Torokhov committed Nov 20, 2005
1 parent 1a8a1b5 commit 4dfa66d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 22a397e2c189dedf857836f2a49542b8aedfeb65
refs/heads/master: a5b0cc80bc3cc98809c7674bda9928db497f0ebb
62 changes: 57 additions & 5 deletions trunk/drivers/input/misc/wistron_btns.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* 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
Expand All @@ -28,6 +29,7 @@
#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;
Expand Down Expand Up @@ -58,6 +60,8 @@ static char *keymap_name; /* = NULL; */
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 */
Expand Down Expand Up @@ -356,6 +360,7 @@ static int __init setup_input_dev(void)
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) {
Expand Down Expand Up @@ -442,6 +447,34 @@ static void poll_bios(unsigned long discard)
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;
Expand All @@ -457,6 +490,16 @@ static int __init wb_module_init(void)
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)
Expand All @@ -480,21 +523,30 @@ static int __init wb_module_init(void)
}

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();
}
Expand Down

0 comments on commit 4dfa66d

Please sign in to comment.