aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/asus-laptop.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/asus-laptop.c')
-rw-r--r--drivers/platform/x86/asus-laptop.c111
1 files changed, 49 insertions, 62 deletions
diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index bfc1a8892a32..db657bbeec90 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -33,6 +33,8 @@
33 * Sam Lin - GPS support 33 * Sam Lin - GPS support
34 */ 34 */
35 35
36#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
37
36#include <linux/kernel.h> 38#include <linux/kernel.h>
37#include <linux/module.h> 39#include <linux/module.h>
38#include <linux/init.h> 40#include <linux/init.h>
@@ -53,9 +55,10 @@
53#define ASUS_HOTK_NAME "Asus Laptop Support" 55#define ASUS_HOTK_NAME "Asus Laptop Support"
54#define ASUS_HOTK_CLASS "hotkey" 56#define ASUS_HOTK_CLASS "hotkey"
55#define ASUS_HOTK_DEVICE_NAME "Hotkey" 57#define ASUS_HOTK_DEVICE_NAME "Hotkey"
56#define ASUS_HOTK_FILE "asus-laptop" 58#define ASUS_HOTK_FILE KBUILD_MODNAME
57#define ASUS_HOTK_PREFIX "\\_SB.ATKD." 59#define ASUS_HOTK_PREFIX "\\_SB.ATKD."
58 60
61
59/* 62/*
60 * Some events we use, same for all Asus 63 * Some events we use, same for all Asus
61 */ 64 */
@@ -207,13 +210,17 @@ MODULE_DEVICE_TABLE(acpi, asus_device_ids);
207 210
208static int asus_hotk_add(struct acpi_device *device); 211static int asus_hotk_add(struct acpi_device *device);
209static int asus_hotk_remove(struct acpi_device *device, int type); 212static int asus_hotk_remove(struct acpi_device *device, int type);
213static void asus_hotk_notify(struct acpi_device *device, u32 event);
214
210static struct acpi_driver asus_hotk_driver = { 215static struct acpi_driver asus_hotk_driver = {
211 .name = ASUS_HOTK_NAME, 216 .name = ASUS_HOTK_NAME,
212 .class = ASUS_HOTK_CLASS, 217 .class = ASUS_HOTK_CLASS,
213 .ids = asus_device_ids, 218 .ids = asus_device_ids,
219 .flags = ACPI_DRIVER_ALL_NOTIFY_EVENTS,
214 .ops = { 220 .ops = {
215 .add = asus_hotk_add, 221 .add = asus_hotk_add,
216 .remove = asus_hotk_remove, 222 .remove = asus_hotk_remove,
223 .notify = asus_hotk_notify,
217 }, 224 },
218}; 225};
219 226
@@ -323,7 +330,7 @@ static int read_wireless_status(int mask)
323 330
324 rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status); 331 rv = acpi_evaluate_integer(wireless_status_handle, NULL, NULL, &status);
325 if (ACPI_FAILURE(rv)) 332 if (ACPI_FAILURE(rv))
326 printk(ASUS_WARNING "Error reading Wireless status\n"); 333 pr_warning("Error reading Wireless status\n");
327 else 334 else
328 return (status & mask) ? 1 : 0; 335 return (status & mask) ? 1 : 0;
329 336
@@ -337,7 +344,7 @@ static int read_gps_status(void)
337 344
338 rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status); 345 rv = acpi_evaluate_integer(gps_status_handle, NULL, NULL, &status);
339 if (ACPI_FAILURE(rv)) 346 if (ACPI_FAILURE(rv))
340 printk(ASUS_WARNING "Error reading GPS status\n"); 347 pr_warning("Error reading GPS status\n");
341 else 348 else
342 return status ? 1 : 0; 349 return status ? 1 : 0;
343 350
@@ -377,7 +384,7 @@ static void write_status(acpi_handle handle, int out, int mask)
377 } 384 }
378 385
379 if (write_acpi_int(handle, NULL, out, NULL)) 386 if (write_acpi_int(handle, NULL, out, NULL))
380 printk(ASUS_WARNING " write failed %x\n", mask); 387 pr_warning(" write failed %x\n", mask);
381} 388}
382 389
383/* /sys/class/led handlers */ 390/* /sys/class/led handlers */
@@ -420,7 +427,7 @@ static int set_lcd_state(int value)
420 NULL, NULL, NULL); 427 NULL, NULL, NULL);
421 428
422 if (ACPI_FAILURE(status)) 429 if (ACPI_FAILURE(status))
423 printk(ASUS_WARNING "Error switching LCD\n"); 430 pr_warning("Error switching LCD\n");
424 } 431 }
425 432
426 write_status(NULL, lcd, LCD_ON); 433 write_status(NULL, lcd, LCD_ON);
@@ -444,7 +451,7 @@ static int read_brightness(struct backlight_device *bd)
444 451
445 rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value); 452 rv = acpi_evaluate_integer(brightness_get_handle, NULL, NULL, &value);
446 if (ACPI_FAILURE(rv)) 453 if (ACPI_FAILURE(rv))
447 printk(ASUS_WARNING "Error reading brightness\n"); 454 pr_warning("Error reading brightness\n");
448 455
449 return value; 456 return value;
450} 457}
@@ -457,7 +464,7 @@ static int set_brightness(struct backlight_device *bd, int value)
457 /* 0 <= value <= 15 */ 464 /* 0 <= value <= 15 */
458 465
459 if (write_acpi_int(brightness_set_handle, NULL, value, NULL)) { 466 if (write_acpi_int(brightness_set_handle, NULL, value, NULL)) {
460 printk(ASUS_WARNING "Error changing brightness\n"); 467 pr_warning("Error changing brightness\n");
461 ret = -EIO; 468 ret = -EIO;
462 } 469 }
463 470
@@ -587,7 +594,7 @@ static ssize_t store_ledd(struct device *dev, struct device_attribute *attr,
587 rv = parse_arg(buf, count, &value); 594 rv = parse_arg(buf, count, &value);
588 if (rv > 0) { 595 if (rv > 0) {
589 if (write_acpi_int(ledd_set_handle, NULL, value, NULL)) 596 if (write_acpi_int(ledd_set_handle, NULL, value, NULL))
590 printk(ASUS_WARNING "LED display write failed\n"); 597 pr_warning("LED display write failed\n");
591 else 598 else
592 hotk->ledd_status = (u32) value; 599 hotk->ledd_status = (u32) value;
593 } 600 }
@@ -632,7 +639,7 @@ static void set_display(int value)
632{ 639{
633 /* no sanity check needed for now */ 640 /* no sanity check needed for now */
634 if (write_acpi_int(display_set_handle, NULL, value, NULL)) 641 if (write_acpi_int(display_set_handle, NULL, value, NULL))
635 printk(ASUS_WARNING "Error setting display\n"); 642 pr_warning("Error setting display\n");
636 return; 643 return;
637} 644}
638 645
@@ -647,7 +654,7 @@ static int read_display(void)
647 rv = acpi_evaluate_integer(display_get_handle, NULL, 654 rv = acpi_evaluate_integer(display_get_handle, NULL,
648 NULL, &value); 655 NULL, &value);
649 if (ACPI_FAILURE(rv)) 656 if (ACPI_FAILURE(rv))
650 printk(ASUS_WARNING "Error reading display status\n"); 657 pr_warning("Error reading display status\n");
651 } 658 }
652 659
653 value &= 0x0F; /* needed for some models, shouldn't hurt others */ 660 value &= 0x0F; /* needed for some models, shouldn't hurt others */
@@ -689,7 +696,7 @@ static ssize_t store_disp(struct device *dev, struct device_attribute *attr,
689static void set_light_sens_switch(int value) 696static void set_light_sens_switch(int value)
690{ 697{
691 if (write_acpi_int(ls_switch_handle, NULL, value, NULL)) 698 if (write_acpi_int(ls_switch_handle, NULL, value, NULL))
692 printk(ASUS_WARNING "Error setting light sensor switch\n"); 699 pr_warning("Error setting light sensor switch\n");
693 hotk->light_switch = value; 700 hotk->light_switch = value;
694} 701}
695 702
@@ -714,7 +721,7 @@ static ssize_t store_lssw(struct device *dev, struct device_attribute *attr,
714static void set_light_sens_level(int value) 721static void set_light_sens_level(int value)
715{ 722{
716 if (write_acpi_int(ls_level_handle, NULL, value, NULL)) 723 if (write_acpi_int(ls_level_handle, NULL, value, NULL))
717 printk(ASUS_WARNING "Error setting light sensor level\n"); 724 pr_warning("Error setting light sensor level\n");
718 hotk->light_level = value; 725 hotk->light_level = value;
719} 726}
720 727
@@ -812,7 +819,7 @@ static int asus_setkeycode(struct input_dev *dev, int scancode, int keycode)
812 return -EINVAL; 819 return -EINVAL;
813} 820}
814 821
815static void asus_hotk_notify(acpi_handle handle, u32 event, void *data) 822static void asus_hotk_notify(struct acpi_device *device, u32 event)
816{ 823{
817 static struct key_entry *key; 824 static struct key_entry *key;
818 u16 count; 825 u16 count;
@@ -975,11 +982,11 @@ static int asus_hotk_get_info(void)
975 */ 982 */
976 status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info); 983 status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus_info);
977 if (ACPI_FAILURE(status)) 984 if (ACPI_FAILURE(status))
978 printk(ASUS_WARNING "Couldn't get the DSDT table header\n"); 985 pr_warning("Couldn't get the DSDT table header\n");
979 986
980 /* We have to write 0 on init this far for all ASUS models */ 987 /* We have to write 0 on init this far for all ASUS models */
981 if (write_acpi_int(hotk->handle, "INIT", 0, &buffer)) { 988 if (write_acpi_int(hotk->handle, "INIT", 0, &buffer)) {
982 printk(ASUS_ERR "Hotkey initialization failed\n"); 989 pr_err("Hotkey initialization failed\n");
983 return -ENODEV; 990 return -ENODEV;
984 } 991 }
985 992
@@ -987,9 +994,9 @@ static int asus_hotk_get_info(void)
987 status = 994 status =
988 acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result); 995 acpi_evaluate_integer(hotk->handle, "BSTS", NULL, &bsts_result);
989 if (ACPI_FAILURE(status)) 996 if (ACPI_FAILURE(status))
990 printk(ASUS_WARNING "Error calling BSTS\n"); 997 pr_warning("Error calling BSTS\n");
991 else if (bsts_result) 998 else if (bsts_result)
992 printk(ASUS_NOTICE "BSTS called, 0x%02x returned\n", 999 pr_notice("BSTS called, 0x%02x returned\n",
993 (uint) bsts_result); 1000 (uint) bsts_result);
994 1001
995 /* This too ... */ 1002 /* This too ... */
@@ -1020,7 +1027,7 @@ static int asus_hotk_get_info(void)
1020 return -ENOMEM; 1027 return -ENOMEM;
1021 1028
1022 if (*string) 1029 if (*string)
1023 printk(ASUS_NOTICE " %s model detected\n", string); 1030 pr_notice(" %s model detected\n", string);
1024 1031
1025 ASUS_HANDLE_INIT(mled_set); 1032 ASUS_HANDLE_INIT(mled_set);
1026 ASUS_HANDLE_INIT(tled_set); 1033 ASUS_HANDLE_INIT(tled_set);
@@ -1077,7 +1084,7 @@ static int asus_input_init(void)
1077 1084
1078 hotk->inputdev = input_allocate_device(); 1085 hotk->inputdev = input_allocate_device();
1079 if (!hotk->inputdev) { 1086 if (!hotk->inputdev) {
1080 printk(ASUS_INFO "Unable to allocate input device\n"); 1087 pr_info("Unable to allocate input device\n");
1081 return 0; 1088 return 0;
1082 } 1089 }
1083 hotk->inputdev->name = "Asus Laptop extra buttons"; 1090 hotk->inputdev->name = "Asus Laptop extra buttons";
@@ -1096,7 +1103,7 @@ static int asus_input_init(void)
1096 } 1103 }
1097 result = input_register_device(hotk->inputdev); 1104 result = input_register_device(hotk->inputdev);
1098 if (result) { 1105 if (result) {
1099 printk(ASUS_INFO "Unable to register input device\n"); 1106 pr_info("Unable to register input device\n");
1100 input_free_device(hotk->inputdev); 1107 input_free_device(hotk->inputdev);
1101 } 1108 }
1102 return result; 1109 return result;
@@ -1113,7 +1120,7 @@ static int asus_hotk_check(void)
1113 if (hotk->device->status.present) { 1120 if (hotk->device->status.present) {
1114 result = asus_hotk_get_info(); 1121 result = asus_hotk_get_info();
1115 } else { 1122 } else {
1116 printk(ASUS_ERR "Hotkey device not present, aborting\n"); 1123 pr_err("Hotkey device not present, aborting\n");
1117 return -EINVAL; 1124 return -EINVAL;
1118 } 1125 }
1119 1126
@@ -1124,13 +1131,12 @@ static int asus_hotk_found;
1124 1131
1125static int asus_hotk_add(struct acpi_device *device) 1132static int asus_hotk_add(struct acpi_device *device)
1126{ 1133{
1127 acpi_status status = AE_OK;
1128 int result; 1134 int result;
1129 1135
1130 if (!device) 1136 if (!device)
1131 return -EINVAL; 1137 return -EINVAL;
1132 1138
1133 printk(ASUS_NOTICE "Asus Laptop Support version %s\n", 1139 pr_notice("Asus Laptop Support version %s\n",
1134 ASUS_LAPTOP_VERSION); 1140 ASUS_LAPTOP_VERSION);
1135 1141
1136 hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL); 1142 hotk = kzalloc(sizeof(struct asus_hotk), GFP_KERNEL);
@@ -1149,15 +1155,6 @@ static int asus_hotk_add(struct acpi_device *device)
1149 1155
1150 asus_hotk_add_fs(); 1156 asus_hotk_add_fs();
1151 1157
1152 /*
1153 * We install the handler, it will receive the hotk in parameter, so, we
1154 * could add other data to the hotk struct
1155 */
1156 status = acpi_install_notify_handler(hotk->handle, ACPI_ALL_NOTIFY,
1157 asus_hotk_notify, hotk);
1158 if (ACPI_FAILURE(status))
1159 printk(ASUS_ERR "Error installing notify handler\n");
1160
1161 asus_hotk_found = 1; 1158 asus_hotk_found = 1;
1162 1159
1163 /* WLED and BLED are on by default */ 1160 /* WLED and BLED are on by default */
@@ -1198,16 +1195,9 @@ end:
1198 1195
1199static int asus_hotk_remove(struct acpi_device *device, int type) 1196static int asus_hotk_remove(struct acpi_device *device, int type)
1200{ 1197{
1201 acpi_status status = 0;
1202
1203 if (!device || !acpi_driver_data(device)) 1198 if (!device || !acpi_driver_data(device))
1204 return -EINVAL; 1199 return -EINVAL;
1205 1200
1206 status = acpi_remove_notify_handler(hotk->handle, ACPI_ALL_NOTIFY,
1207 asus_hotk_notify);
1208 if (ACPI_FAILURE(status))
1209 printk(ASUS_ERR "Error removing notify handler\n");
1210
1211 kfree(hotk->name); 1201 kfree(hotk->name);
1212 kfree(hotk); 1202 kfree(hotk);
1213 1203
@@ -1260,8 +1250,7 @@ static int asus_backlight_init(struct device *dev)
1260 bd = backlight_device_register(ASUS_HOTK_FILE, dev, 1250 bd = backlight_device_register(ASUS_HOTK_FILE, dev,
1261 NULL, &asusbl_ops); 1251 NULL, &asusbl_ops);
1262 if (IS_ERR(bd)) { 1252 if (IS_ERR(bd)) {
1263 printk(ASUS_ERR 1253 pr_err("Could not register asus backlight device\n");
1264 "Could not register asus backlight device\n");
1265 asus_backlight_device = NULL; 1254 asus_backlight_device = NULL;
1266 return PTR_ERR(bd); 1255 return PTR_ERR(bd);
1267 } 1256 }
@@ -1334,7 +1323,6 @@ out:
1334 1323
1335static int __init asus_laptop_init(void) 1324static int __init asus_laptop_init(void)
1336{ 1325{
1337 struct device *dev;
1338 int result; 1326 int result;
1339 1327
1340 if (acpi_disabled) 1328 if (acpi_disabled)
@@ -1356,24 +1344,10 @@ static int __init asus_laptop_init(void)
1356 return -ENODEV; 1344 return -ENODEV;
1357 } 1345 }
1358 1346
1359 dev = acpi_get_physical_device(hotk->device->handle);
1360
1361 if (!acpi_video_backlight_support()) {
1362 result = asus_backlight_init(dev);
1363 if (result)
1364 goto fail_backlight;
1365 } else
1366 printk(ASUS_INFO "Brightness ignored, must be controlled by "
1367 "ACPI video driver\n");
1368
1369 result = asus_input_init(); 1347 result = asus_input_init();
1370 if (result) 1348 if (result)
1371 goto fail_input; 1349 goto fail_input;
1372 1350
1373 result = asus_led_init(dev);
1374 if (result)
1375 goto fail_led;
1376
1377 /* Register platform stuff */ 1351 /* Register platform stuff */
1378 result = platform_driver_register(&asuspf_driver); 1352 result = platform_driver_register(&asuspf_driver);
1379 if (result) 1353 if (result)
@@ -1394,8 +1368,27 @@ static int __init asus_laptop_init(void)
1394 if (result) 1368 if (result)
1395 goto fail_sysfs; 1369 goto fail_sysfs;
1396 1370
1371 result = asus_led_init(&asuspf_device->dev);
1372 if (result)
1373 goto fail_led;
1374
1375 if (!acpi_video_backlight_support()) {
1376 result = asus_backlight_init(&asuspf_device->dev);
1377 if (result)
1378 goto fail_backlight;
1379 } else
1380 pr_info("Brightness ignored, must be controlled by "
1381 "ACPI video driver\n");
1382
1397 return 0; 1383 return 0;
1398 1384
1385fail_backlight:
1386 asus_led_exit();
1387
1388fail_led:
1389 sysfs_remove_group(&asuspf_device->dev.kobj,
1390 &asuspf_attribute_group);
1391
1399fail_sysfs: 1392fail_sysfs:
1400 platform_device_del(asuspf_device); 1393 platform_device_del(asuspf_device);
1401 1394
@@ -1406,15 +1399,9 @@ fail_platform_device1:
1406 platform_driver_unregister(&asuspf_driver); 1399 platform_driver_unregister(&asuspf_driver);
1407 1400
1408fail_platform_driver: 1401fail_platform_driver:
1409 asus_led_exit();
1410
1411fail_led:
1412 asus_input_exit(); 1402 asus_input_exit();
1413 1403
1414fail_input: 1404fail_input:
1415 asus_backlight_exit();
1416
1417fail_backlight:
1418 1405
1419 return result; 1406 return result;
1420} 1407}