Input: wistron_btns - switch to using dev_pm_ops
Also start using 'bool' where it makes sense. Tested-by: Giuseppe Mazzotta <g.mazzotta@iragan.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
This commit is contained in:
parent
dd0d5443da
commit
67dbe83adc
1 changed files with 37 additions and 29 deletions
|
@ -243,9 +243,9 @@ enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
|
||||||
#define FE_UNTESTED 0x80
|
#define FE_UNTESTED 0x80
|
||||||
|
|
||||||
static struct key_entry *keymap; /* = NULL; Current key map */
|
static struct key_entry *keymap; /* = NULL; Current key map */
|
||||||
static int have_wifi;
|
static bool have_wifi;
|
||||||
static int have_bluetooth;
|
static bool have_bluetooth;
|
||||||
static int have_leds;
|
static int leds_present; /* bitmask of leds present */
|
||||||
|
|
||||||
static int __init dmi_matched(const struct dmi_system_id *dmi)
|
static int __init dmi_matched(const struct dmi_system_id *dmi)
|
||||||
{
|
{
|
||||||
|
@ -254,11 +254,11 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
|
||||||
keymap = dmi->driver_data;
|
keymap = dmi->driver_data;
|
||||||
for (key = keymap; key->type != KE_END; key++) {
|
for (key = keymap; key->type != KE_END; key++) {
|
||||||
if (key->type == KE_WIFI)
|
if (key->type == KE_WIFI)
|
||||||
have_wifi = 1;
|
have_wifi = true;
|
||||||
else if (key->type == KE_BLUETOOTH)
|
else if (key->type == KE_BLUETOOTH)
|
||||||
have_bluetooth = 1;
|
have_bluetooth = true;
|
||||||
}
|
}
|
||||||
have_leds = key->code & (FE_MAIL_LED | FE_WIFI_LED);
|
leds_present = key->code & (FE_MAIL_LED | FE_WIFI_LED);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -993,8 +993,8 @@ static int __init select_keymap(void)
|
||||||
|
|
||||||
static struct input_polled_dev *wistron_idev;
|
static struct input_polled_dev *wistron_idev;
|
||||||
static unsigned long jiffies_last_press;
|
static unsigned long jiffies_last_press;
|
||||||
static int wifi_enabled;
|
static bool wifi_enabled;
|
||||||
static int bluetooth_enabled;
|
static bool bluetooth_enabled;
|
||||||
|
|
||||||
static void report_key(struct input_dev *dev, unsigned int keycode)
|
static void report_key(struct input_dev *dev, unsigned int keycode)
|
||||||
{
|
{
|
||||||
|
@ -1037,24 +1037,24 @@ static struct led_classdev wistron_wifi_led = {
|
||||||
|
|
||||||
static void __devinit wistron_led_init(struct device *parent)
|
static void __devinit wistron_led_init(struct device *parent)
|
||||||
{
|
{
|
||||||
if (have_leds & FE_WIFI_LED) {
|
if (leds_present & FE_WIFI_LED) {
|
||||||
u16 wifi = bios_get_default_setting(WIFI);
|
u16 wifi = bios_get_default_setting(WIFI);
|
||||||
if (wifi & 1) {
|
if (wifi & 1) {
|
||||||
wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF;
|
wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF;
|
||||||
if (led_classdev_register(parent, &wistron_wifi_led))
|
if (led_classdev_register(parent, &wistron_wifi_led))
|
||||||
have_leds &= ~FE_WIFI_LED;
|
leds_present &= ~FE_WIFI_LED;
|
||||||
else
|
else
|
||||||
bios_set_state(WIFI, wistron_wifi_led.brightness);
|
bios_set_state(WIFI, wistron_wifi_led.brightness);
|
||||||
|
|
||||||
} else
|
} else
|
||||||
have_leds &= ~FE_WIFI_LED;
|
leds_present &= ~FE_WIFI_LED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_leds & FE_MAIL_LED) {
|
if (leds_present & FE_MAIL_LED) {
|
||||||
/* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
|
/* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
|
||||||
wistron_mail_led.brightness = LED_OFF;
|
wistron_mail_led.brightness = LED_OFF;
|
||||||
if (led_classdev_register(parent, &wistron_mail_led))
|
if (led_classdev_register(parent, &wistron_mail_led))
|
||||||
have_leds &= ~FE_MAIL_LED;
|
leds_present &= ~FE_MAIL_LED;
|
||||||
else
|
else
|
||||||
bios_set_state(MAIL_LED, wistron_mail_led.brightness);
|
bios_set_state(MAIL_LED, wistron_mail_led.brightness);
|
||||||
}
|
}
|
||||||
|
@ -1062,28 +1062,28 @@ static void __devinit wistron_led_init(struct device *parent)
|
||||||
|
|
||||||
static void __devexit wistron_led_remove(void)
|
static void __devexit wistron_led_remove(void)
|
||||||
{
|
{
|
||||||
if (have_leds & FE_MAIL_LED)
|
if (leds_present & FE_MAIL_LED)
|
||||||
led_classdev_unregister(&wistron_mail_led);
|
led_classdev_unregister(&wistron_mail_led);
|
||||||
|
|
||||||
if (have_leds & FE_WIFI_LED)
|
if (leds_present & FE_WIFI_LED)
|
||||||
led_classdev_unregister(&wistron_wifi_led);
|
led_classdev_unregister(&wistron_wifi_led);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void wistron_led_suspend(void)
|
static inline void wistron_led_suspend(void)
|
||||||
{
|
{
|
||||||
if (have_leds & FE_MAIL_LED)
|
if (leds_present & FE_MAIL_LED)
|
||||||
led_classdev_suspend(&wistron_mail_led);
|
led_classdev_suspend(&wistron_mail_led);
|
||||||
|
|
||||||
if (have_leds & FE_WIFI_LED)
|
if (leds_present & FE_WIFI_LED)
|
||||||
led_classdev_suspend(&wistron_wifi_led);
|
led_classdev_suspend(&wistron_wifi_led);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void wistron_led_resume(void)
|
static inline void wistron_led_resume(void)
|
||||||
{
|
{
|
||||||
if (have_leds & FE_MAIL_LED)
|
if (leds_present & FE_MAIL_LED)
|
||||||
led_classdev_resume(&wistron_mail_led);
|
led_classdev_resume(&wistron_mail_led);
|
||||||
|
|
||||||
if (have_leds & FE_WIFI_LED)
|
if (leds_present & FE_WIFI_LED)
|
||||||
led_classdev_resume(&wistron_wifi_led);
|
led_classdev_resume(&wistron_wifi_led);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1296,7 +1296,7 @@ static int __devinit wistron_probe(struct platform_device *dev)
|
||||||
if (have_wifi) {
|
if (have_wifi) {
|
||||||
u16 wifi = bios_get_default_setting(WIFI);
|
u16 wifi = bios_get_default_setting(WIFI);
|
||||||
if (wifi & 1)
|
if (wifi & 1)
|
||||||
wifi_enabled = (wifi & 2) ? 1 : 0;
|
wifi_enabled = wifi & 2;
|
||||||
else
|
else
|
||||||
have_wifi = 0;
|
have_wifi = 0;
|
||||||
|
|
||||||
|
@ -1307,15 +1307,16 @@ static int __devinit wistron_probe(struct platform_device *dev)
|
||||||
if (have_bluetooth) {
|
if (have_bluetooth) {
|
||||||
u16 bt = bios_get_default_setting(BLUETOOTH);
|
u16 bt = bios_get_default_setting(BLUETOOTH);
|
||||||
if (bt & 1)
|
if (bt & 1)
|
||||||
bluetooth_enabled = (bt & 2) ? 1 : 0;
|
bluetooth_enabled = bt & 2;
|
||||||
else
|
else
|
||||||
have_bluetooth = 0;
|
have_bluetooth = false;
|
||||||
|
|
||||||
if (have_bluetooth)
|
if (have_bluetooth)
|
||||||
bios_set_state(BLUETOOTH, bluetooth_enabled);
|
bios_set_state(BLUETOOTH, bluetooth_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
wistron_led_init(&dev->dev);
|
wistron_led_init(&dev->dev);
|
||||||
|
|
||||||
err = setup_input_dev();
|
err = setup_input_dev();
|
||||||
if (err) {
|
if (err) {
|
||||||
bios_detach();
|
bios_detach();
|
||||||
|
@ -1336,7 +1337,7 @@ static int __devexit wistron_remove(struct platform_device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
static int wistron_suspend(struct platform_device *dev, pm_message_t state)
|
static int wistron_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
if (have_wifi)
|
if (have_wifi)
|
||||||
bios_set_state(WIFI, 0);
|
bios_set_state(WIFI, 0);
|
||||||
|
@ -1345,10 +1346,11 @@ static int wistron_suspend(struct platform_device *dev, pm_message_t state)
|
||||||
bios_set_state(BLUETOOTH, 0);
|
bios_set_state(BLUETOOTH, 0);
|
||||||
|
|
||||||
wistron_led_suspend();
|
wistron_led_suspend();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wistron_resume(struct platform_device *dev)
|
static int wistron_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
if (have_wifi)
|
if (have_wifi)
|
||||||
bios_set_state(WIFI, wifi_enabled);
|
bios_set_state(WIFI, wifi_enabled);
|
||||||
|
@ -1357,24 +1359,30 @@ static int wistron_resume(struct platform_device *dev)
|
||||||
bios_set_state(BLUETOOTH, bluetooth_enabled);
|
bios_set_state(BLUETOOTH, bluetooth_enabled);
|
||||||
|
|
||||||
wistron_led_resume();
|
wistron_led_resume();
|
||||||
|
|
||||||
poll_bios(true);
|
poll_bios(true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define wistron_suspend NULL
|
static const struct dev_pm_ops wistron_pm_ops = {
|
||||||
#define wistron_resume NULL
|
.suspend = wistron_suspend,
|
||||||
|
.resume = wistron_resume,
|
||||||
|
.poweroff = wistron_suspend,
|
||||||
|
.restore = wistron_resume,
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct platform_driver wistron_driver = {
|
static struct platform_driver wistron_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "wistron-bios",
|
.name = "wistron-bios",
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
|
#if CONFIG_PM
|
||||||
|
.pm = &wistron_pm_ops,
|
||||||
|
#endif
|
||||||
},
|
},
|
||||||
.probe = wistron_probe,
|
.probe = wistron_probe,
|
||||||
.remove = __devexit_p(wistron_remove),
|
.remove = __devexit_p(wistron_remove),
|
||||||
.suspend = wistron_suspend,
|
|
||||||
.resume = wistron_resume,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init wb_module_init(void)
|
static int __init wb_module_init(void)
|
||||||
|
|
Reference in a new issue