aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-08-08 02:17:39 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-08-08 12:29:23 -0400
commit67dbe83adca4415e210e436bf961e8a833030d1e (patch)
tree2c9d3d4c75ea9587c67eb4a645f10d3b33831678 /drivers/input/misc
parentdd0d5443da02b091636e967407805f0b7712fd44 (diff)
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>
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/wistron_btns.c66
1 files changed, 37 insertions, 29 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 26e17a9a22eb..bc3116bebfe9 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -243,9 +243,9 @@ enum { KE_END, KE_KEY, KE_SW, KE_WIFI, KE_BLUETOOTH };
243#define FE_UNTESTED 0x80 243#define FE_UNTESTED 0x80
244 244
245static struct key_entry *keymap; /* = NULL; Current key map */ 245static struct key_entry *keymap; /* = NULL; Current key map */
246static int have_wifi; 246static bool have_wifi;
247static int have_bluetooth; 247static bool have_bluetooth;
248static int have_leds; 248static int leds_present; /* bitmask of leds present */
249 249
250static int __init dmi_matched(const struct dmi_system_id *dmi) 250static int __init dmi_matched(const struct dmi_system_id *dmi)
251{ 251{
@@ -254,11 +254,11 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
254 keymap = dmi->driver_data; 254 keymap = dmi->driver_data;
255 for (key = keymap; key->type != KE_END; key++) { 255 for (key = keymap; key->type != KE_END; key++) {
256 if (key->type == KE_WIFI) 256 if (key->type == KE_WIFI)
257 have_wifi = 1; 257 have_wifi = true;
258 else if (key->type == KE_BLUETOOTH) 258 else if (key->type == KE_BLUETOOTH)
259 have_bluetooth = 1; 259 have_bluetooth = true;
260 } 260 }
261 have_leds = key->code & (FE_MAIL_LED | FE_WIFI_LED); 261 leds_present = key->code & (FE_MAIL_LED | FE_WIFI_LED);
262 262
263 return 1; 263 return 1;
264} 264}
@@ -993,8 +993,8 @@ static int __init select_keymap(void)
993 993
994static struct input_polled_dev *wistron_idev; 994static struct input_polled_dev *wistron_idev;
995static unsigned long jiffies_last_press; 995static unsigned long jiffies_last_press;
996static int wifi_enabled; 996static bool wifi_enabled;
997static int bluetooth_enabled; 997static bool bluetooth_enabled;
998 998
999static void report_key(struct input_dev *dev, unsigned int keycode) 999static void report_key(struct input_dev *dev, unsigned int keycode)
1000{ 1000{
@@ -1037,24 +1037,24 @@ static struct led_classdev wistron_wifi_led = {
1037 1037
1038static void __devinit wistron_led_init(struct device *parent) 1038static void __devinit wistron_led_init(struct device *parent)
1039{ 1039{
1040 if (have_leds & FE_WIFI_LED) { 1040 if (leds_present & FE_WIFI_LED) {
1041 u16 wifi = bios_get_default_setting(WIFI); 1041 u16 wifi = bios_get_default_setting(WIFI);
1042 if (wifi & 1) { 1042 if (wifi & 1) {
1043 wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF; 1043 wistron_wifi_led.brightness = (wifi & 2) ? LED_FULL : LED_OFF;
1044 if (led_classdev_register(parent, &wistron_wifi_led)) 1044 if (led_classdev_register(parent, &wistron_wifi_led))
1045 have_leds &= ~FE_WIFI_LED; 1045 leds_present &= ~FE_WIFI_LED;
1046 else 1046 else
1047 bios_set_state(WIFI, wistron_wifi_led.brightness); 1047 bios_set_state(WIFI, wistron_wifi_led.brightness);
1048 1048
1049 } else 1049 } else
1050 have_leds &= ~FE_WIFI_LED; 1050 leds_present &= ~FE_WIFI_LED;
1051 } 1051 }
1052 1052
1053 if (have_leds & FE_MAIL_LED) { 1053 if (leds_present & FE_MAIL_LED) {
1054 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */ 1054 /* bios_get_default_setting(MAIL) always retuns 0, so just turn the led off */
1055 wistron_mail_led.brightness = LED_OFF; 1055 wistron_mail_led.brightness = LED_OFF;
1056 if (led_classdev_register(parent, &wistron_mail_led)) 1056 if (led_classdev_register(parent, &wistron_mail_led))
1057 have_leds &= ~FE_MAIL_LED; 1057 leds_present &= ~FE_MAIL_LED;
1058 else 1058 else
1059 bios_set_state(MAIL_LED, wistron_mail_led.brightness); 1059 bios_set_state(MAIL_LED, wistron_mail_led.brightness);
1060 } 1060 }
@@ -1062,28 +1062,28 @@ static void __devinit wistron_led_init(struct device *parent)
1062 1062
1063static void __devexit wistron_led_remove(void) 1063static void __devexit wistron_led_remove(void)
1064{ 1064{
1065 if (have_leds & FE_MAIL_LED) 1065 if (leds_present & FE_MAIL_LED)
1066 led_classdev_unregister(&wistron_mail_led); 1066 led_classdev_unregister(&wistron_mail_led);
1067 1067
1068 if (have_leds & FE_WIFI_LED) 1068 if (leds_present & FE_WIFI_LED)
1069 led_classdev_unregister(&wistron_wifi_led); 1069 led_classdev_unregister(&wistron_wifi_led);
1070} 1070}
1071 1071
1072static inline void wistron_led_suspend(void) 1072static inline void wistron_led_suspend(void)
1073{ 1073{
1074 if (have_leds & FE_MAIL_LED) 1074 if (leds_present & FE_MAIL_LED)
1075 led_classdev_suspend(&wistron_mail_led); 1075 led_classdev_suspend(&wistron_mail_led);
1076 1076
1077 if (have_leds & FE_WIFI_LED) 1077 if (leds_present & FE_WIFI_LED)
1078 led_classdev_suspend(&wistron_wifi_led); 1078 led_classdev_suspend(&wistron_wifi_led);
1079} 1079}
1080 1080
1081static inline void wistron_led_resume(void) 1081static inline void wistron_led_resume(void)
1082{ 1082{
1083 if (have_leds & FE_MAIL_LED) 1083 if (leds_present & FE_MAIL_LED)
1084 led_classdev_resume(&wistron_mail_led); 1084 led_classdev_resume(&wistron_mail_led);
1085 1085
1086 if (have_leds & FE_WIFI_LED) 1086 if (leds_present & FE_WIFI_LED)
1087 led_classdev_resume(&wistron_wifi_led); 1087 led_classdev_resume(&wistron_wifi_led);
1088} 1088}
1089 1089
@@ -1296,7 +1296,7 @@ static int __devinit wistron_probe(struct platform_device *dev)
1296 if (have_wifi) { 1296 if (have_wifi) {
1297 u16 wifi = bios_get_default_setting(WIFI); 1297 u16 wifi = bios_get_default_setting(WIFI);
1298 if (wifi & 1) 1298 if (wifi & 1)
1299 wifi_enabled = (wifi & 2) ? 1 : 0; 1299 wifi_enabled = wifi & 2;
1300 else 1300 else
1301 have_wifi = 0; 1301 have_wifi = 0;
1302 1302
@@ -1307,15 +1307,16 @@ static int __devinit wistron_probe(struct platform_device *dev)
1307 if (have_bluetooth) { 1307 if (have_bluetooth) {
1308 u16 bt = bios_get_default_setting(BLUETOOTH); 1308 u16 bt = bios_get_default_setting(BLUETOOTH);
1309 if (bt & 1) 1309 if (bt & 1)
1310 bluetooth_enabled = (bt & 2) ? 1 : 0; 1310 bluetooth_enabled = bt & 2;
1311 else 1311 else
1312 have_bluetooth = 0; 1312 have_bluetooth = false;
1313 1313
1314 if (have_bluetooth) 1314 if (have_bluetooth)
1315 bios_set_state(BLUETOOTH, bluetooth_enabled); 1315 bios_set_state(BLUETOOTH, bluetooth_enabled);
1316 } 1316 }
1317 1317
1318 wistron_led_init(&dev->dev); 1318 wistron_led_init(&dev->dev);
1319
1319 err = setup_input_dev(); 1320 err = setup_input_dev();
1320 if (err) { 1321 if (err) {
1321 bios_detach(); 1322 bios_detach();
@@ -1336,7 +1337,7 @@ static int __devexit wistron_remove(struct platform_device *dev)
1336} 1337}
1337 1338
1338#ifdef CONFIG_PM 1339#ifdef CONFIG_PM
1339static int wistron_suspend(struct platform_device *dev, pm_message_t state) 1340static int wistron_suspend(struct device *dev)
1340{ 1341{
1341 if (have_wifi) 1342 if (have_wifi)
1342 bios_set_state(WIFI, 0); 1343 bios_set_state(WIFI, 0);
@@ -1345,10 +1346,11 @@ static int wistron_suspend(struct platform_device *dev, pm_message_t state)
1345 bios_set_state(BLUETOOTH, 0); 1346 bios_set_state(BLUETOOTH, 0);
1346 1347
1347 wistron_led_suspend(); 1348 wistron_led_suspend();
1349
1348 return 0; 1350 return 0;
1349} 1351}
1350 1352
1351static int wistron_resume(struct platform_device *dev) 1353static int wistron_resume(struct device *dev)
1352{ 1354{
1353 if (have_wifi) 1355 if (have_wifi)
1354 bios_set_state(WIFI, wifi_enabled); 1356 bios_set_state(WIFI, wifi_enabled);
@@ -1357,24 +1359,30 @@ static int wistron_resume(struct platform_device *dev)
1357 bios_set_state(BLUETOOTH, bluetooth_enabled); 1359 bios_set_state(BLUETOOTH, bluetooth_enabled);
1358 1360
1359 wistron_led_resume(); 1361 wistron_led_resume();
1362
1360 poll_bios(true); 1363 poll_bios(true);
1361 1364
1362 return 0; 1365 return 0;
1363} 1366}
1364#else 1367
1365#define wistron_suspend NULL 1368static const struct dev_pm_ops wistron_pm_ops = {
1366#define wistron_resume NULL 1369 .suspend = wistron_suspend,
1370 .resume = wistron_resume,
1371 .poweroff = wistron_suspend,
1372 .restore = wistron_resume,
1373};
1367#endif 1374#endif
1368 1375
1369static struct platform_driver wistron_driver = { 1376static struct platform_driver wistron_driver = {
1370 .driver = { 1377 .driver = {
1371 .name = "wistron-bios", 1378 .name = "wistron-bios",
1372 .owner = THIS_MODULE, 1379 .owner = THIS_MODULE,
1380#if CONFIG_PM
1381 .pm = &wistron_pm_ops,
1382#endif
1373 }, 1383 },
1374 .probe = wistron_probe, 1384 .probe = wistron_probe,
1375 .remove = __devexit_p(wistron_remove), 1385 .remove = __devexit_p(wistron_remove),
1376 .suspend = wistron_suspend,
1377 .resume = wistron_resume,
1378}; 1386};
1379 1387
1380static int __init wb_module_init(void) 1388static int __init wb_module_init(void)