Lines Matching +full:device +full:- +full:handle
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * asus-laptop.c - Asus Laptop Support
5 * Copyright (C) 2002-2005 Julien Lerouge, 2003-2006 Karol Kozimor
6 * Copyright (C) 2006-2007 Corentin Chary
13 * Pontus Fuchs - Helper functions, cleanup
14 * Johann Wiesner - Small compile fixes
15 * John Belmonte - ACPI code for Toshiba laptop was a good starting point.
16 * Eric Burghard - LED display support for W1N
17 * Josh Green - Light Sens support
18 * Thomas Tuttle - His first patch for led support was very helpful
19 * Sam Lin - GPS support
35 #include <linux/input/sparse-keymap.h>
82 static int wimax_status = -1;
83 static int wwan_status = -1;
88 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
89 "default is -1");
93 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
94 "default is -1");
98 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
99 "default is -1");
103 "(0 = disabled, 1 = enabled, -1 = don't do anything). "
104 "default is -1");
156 * they also control the WLAN/Bluetooth device.
178 /* R2H use different handle for GPS on/off */
233 * about the hotk device
240 struct acpi_device *device; /* the device we are in */ member
273 acpi_handle handle; /* the handle of the hotk device */ member
355 * method is searched within the scope of the handle, can be NULL. The output
358 * returns 0 if write is successful, -1 else.
360 static int write_acpi_int_ret(acpi_handle handle, const char *method, int val, in write_acpi_int_ret() argument
367 if (!handle) in write_acpi_int_ret()
368 return -1; in write_acpi_int_ret()
375 status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); in write_acpi_int_ret()
379 return -1; in write_acpi_int_ret()
382 static int write_acpi_int(acpi_handle handle, const char *method, int val) in write_acpi_int() argument
384 return write_acpi_int_ret(handle, method, val, NULL); in write_acpi_int()
387 static int acpi_check_handle(acpi_handle handle, const char *method, in acpi_check_handle() argument
393 return -ENODEV; in acpi_check_handle()
396 status = acpi_get_handle(handle, (char *)method, in acpi_check_handle()
401 status = acpi_get_handle(handle, (char *)method, in acpi_check_handle()
408 return -ENODEV; in acpi_check_handle()
415 return !strcmp(asus->name, DEVICE_NAME_PEGA) && in asus_check_pega_lucid()
416 !acpi_check_handle(asus->handle, METHOD_PEGA_ENABLE, NULL) && in asus_check_pega_lucid()
417 !acpi_check_handle(asus->handle, METHOD_PEGA_DISABLE, NULL) && in asus_check_pega_lucid()
418 !acpi_check_handle(asus->handle, METHOD_PEGA_READ, NULL); in asus_check_pega_lucid()
424 return write_acpi_int(asus->handle, method, unit); in asus_pega_lucid_set()
432 acpi_evaluate_integer(asus->handle, method, NULL, &val); in pega_acc_axis()
438 * between (for example) -1 and 0 could be read as in pega_acc_axis()
440 delta = abs(curr - (short)val); in pega_acc_axis()
444 return clamp_val((short)val, -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP); in pega_acc_axis()
449 struct device *parent = input->dev.parent; in pega_accel_poll()
455 * device, and perhaps a firmware bug. Fake the first report. */ in pega_accel_poll()
456 if (!asus->pega_acc_live) { in pega_accel_poll()
457 asus->pega_acc_live = true; in pega_accel_poll()
465 asus->pega_acc_x = pega_acc_axis(asus, asus->pega_acc_x, METHOD_XLRX); in pega_accel_poll()
466 asus->pega_acc_y = pega_acc_axis(asus, asus->pega_acc_y, METHOD_XLRY); in pega_accel_poll()
467 asus->pega_acc_z = pega_acc_axis(asus, asus->pega_acc_z, METHOD_XLRZ); in pega_accel_poll()
471 * "real up" in the device's cartiesian coordinates). */ in pega_accel_poll()
472 input_report_abs(input, ABS_X, -asus->pega_acc_x); in pega_accel_poll()
473 input_report_abs(input, ABS_Y, -asus->pega_acc_y); in pega_accel_poll()
474 input_report_abs(input, ABS_Z, asus->pega_acc_z); in pega_accel_poll()
480 if (asus->pega_accel_poll) { in pega_accel_exit()
481 input_unregister_device(asus->pega_accel_poll); in pega_accel_exit()
482 asus->pega_accel_poll = NULL; in pega_accel_exit()
491 if (!asus->is_pega_lucid) in pega_accel_init()
492 return -ENODEV; in pega_accel_init()
494 if (acpi_check_handle(asus->handle, METHOD_XLRX, NULL) || in pega_accel_init()
495 acpi_check_handle(asus->handle, METHOD_XLRY, NULL) || in pega_accel_init()
496 acpi_check_handle(asus->handle, METHOD_XLRZ, NULL)) in pega_accel_init()
497 return -ENODEV; in pega_accel_init()
501 return -ENOMEM; in pega_accel_init()
503 input->name = PEGA_ACCEL_DESC; in pega_accel_init()
504 input->phys = PEGA_ACCEL_NAME "/input0"; in pega_accel_init()
505 input->dev.parent = &asus->platform_device->dev; in pega_accel_init()
506 input->id.bustype = BUS_HOST; in pega_accel_init()
509 -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0); in pega_accel_init()
511 -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0); in pega_accel_init()
513 -PEGA_ACC_CLAMP, PEGA_ACC_CLAMP, 0, 0); in pega_accel_init()
527 asus->pega_accel_poll = input; in pega_accel_init()
546 return write_acpi_int(asus->handle, method, value); in asus_led_set()
557 struct asus_laptop *asus = led->asus; in asus_led_cdev_set()
559 led->wk = !!value; in asus_led_cdev_set()
560 queue_work(asus->led_workqueue, &led->work); in asus_led_cdev_set()
566 struct asus_laptop *asus = led->asus; in asus_led_cdev_update()
568 asus_led_set(asus, led->method, led->wk); in asus_led_cdev_update()
573 return led_cdev->brightness; in asus_led_cdev_get()
591 rv = acpi_evaluate_integer(asus->handle, METHOD_KBD_LIGHT_GET, in asus_kled_lvl()
595 return -ENODEV; in asus_kled_lvl()
607 if (write_acpi_int(asus->handle, METHOD_KBD_LIGHT_SET, kblv)) { in asus_kled_set()
609 return -EINVAL; in asus_kled_set()
618 struct asus_laptop *asus = led->asus; in asus_kled_cdev_set()
620 led->wk = value; in asus_kled_cdev_set()
621 queue_work(asus->led_workqueue, &led->work); in asus_kled_cdev_set()
627 struct asus_laptop *asus = led->asus; in asus_kled_cdev_update()
629 asus_kled_set(asus, led->wk); in asus_kled_cdev_update()
635 struct asus_laptop *asus = led->asus; in asus_kled_cdev_get()
642 led_classdev_unregister(&asus->wled.led); in asus_led_exit()
643 led_classdev_unregister(&asus->bled.led); in asus_led_exit()
644 led_classdev_unregister(&asus->mled.led); in asus_led_exit()
645 led_classdev_unregister(&asus->tled.led); in asus_led_exit()
646 led_classdev_unregister(&asus->pled.led); in asus_led_exit()
647 led_classdev_unregister(&asus->rled.led); in asus_led_exit()
648 led_classdev_unregister(&asus->gled.led); in asus_led_exit()
649 led_classdev_unregister(&asus->kled.led); in asus_led_exit()
651 if (asus->led_workqueue) { in asus_led_exit()
652 destroy_workqueue(asus->led_workqueue); in asus_led_exit()
653 asus->led_workqueue = NULL; in asus_led_exit()
662 struct led_classdev *led_cdev = &led->led; in asus_led_register()
664 if (!method || acpi_check_handle(asus->handle, method, NULL)) in asus_led_register()
667 led->asus = asus; in asus_led_register()
668 led->method = method; in asus_led_register()
670 INIT_WORK(&led->work, asus_led_cdev_update); in asus_led_register()
671 led_cdev->name = name; in asus_led_register()
672 led_cdev->brightness_set = asus_led_cdev_set; in asus_led_register()
673 led_cdev->brightness_get = asus_led_cdev_get; in asus_led_register()
674 led_cdev->max_brightness = 1; in asus_led_register()
675 return led_classdev_register(&asus->platform_device->dev, led_cdev); in asus_led_register()
686 if (asus->is_pega_lucid) in asus_led_init()
695 asus->led_workqueue = create_singlethread_workqueue("led_workqueue"); in asus_led_init()
696 if (!asus->led_workqueue) in asus_led_init()
697 return -ENOMEM; in asus_led_init()
699 if (asus->wled_type == TYPE_LED) in asus_led_init()
700 r = asus_led_register(asus, &asus->wled, "asus::wlan", in asus_led_init()
704 if (asus->bled_type == TYPE_LED) in asus_led_init()
705 r = asus_led_register(asus, &asus->bled, "asus::bluetooth", in asus_led_init()
709 r = asus_led_register(asus, &asus->mled, "asus::mail", METHOD_MLED); in asus_led_init()
712 r = asus_led_register(asus, &asus->tled, "asus::touchpad", METHOD_TLED); in asus_led_init()
715 r = asus_led_register(asus, &asus->rled, "asus::record", METHOD_RLED); in asus_led_init()
718 r = asus_led_register(asus, &asus->pled, "asus::phone", METHOD_PLED); in asus_led_init()
721 r = asus_led_register(asus, &asus->gled, "asus::gaming", METHOD_GLED); in asus_led_init()
724 if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL) && in asus_led_init()
725 !acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_GET, NULL)) { in asus_led_init()
726 struct asus_led *led = &asus->kled; in asus_led_init()
727 struct led_classdev *cdev = &led->led; in asus_led_init()
729 led->asus = asus; in asus_led_init()
731 INIT_WORK(&led->work, asus_kled_cdev_update); in asus_led_init()
732 cdev->name = "asus::kbd_backlight"; in asus_led_init()
733 cdev->brightness_set = asus_kled_cdev_set; in asus_led_init()
734 cdev->brightness_get = asus_kled_cdev_get; in asus_led_init()
735 cdev->max_brightness = 3; in asus_led_init()
736 r = led_classdev_register(&asus->platform_device->dev, cdev); in asus_led_init()
745 * Backlight device
753 rv = acpi_evaluate_integer(asus->handle, METHOD_BRIGHTNESS_GET, in asus_read_brightness()
767 if (write_acpi_int(asus->handle, METHOD_BRIGHTNESS_SET, value)) { in asus_set_brightness()
769 return -EIO; in asus_set_brightness()
776 int value = bd->props.brightness; in update_bl_status()
788 struct backlight_device *bd = asus->backlight_device; in asus_backlight_notify()
789 int old = bd->props.brightness; in asus_backlight_notify()
801 if (acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_GET, NULL) || in asus_backlight_init()
802 acpi_check_handle(asus->handle, METHOD_BRIGHTNESS_SET, NULL)) in asus_backlight_init()
810 &asus->platform_device->dev, asus, in asus_backlight_init()
813 pr_err("Could not register asus backlight device\n"); in asus_backlight_init()
814 asus->backlight_device = NULL; in asus_backlight_init()
818 asus->backlight_device = bd; in asus_backlight_init()
819 bd->props.brightness = asus_read_brightness(bd); in asus_backlight_init()
820 bd->props.power = BACKLIGHT_POWER_ON; in asus_backlight_init()
827 backlight_device_unregister(asus->backlight_device); in asus_backlight_exit()
828 asus->backlight_device = NULL; in asus_backlight_exit()
832 * Platform device handlers
837 * than count bytes. We set eof to 1 if we handle those 2 values. We return the
840 static ssize_t infos_show(struct device *dev, struct device_attribute *attr, in infos_show()
855 len += sysfs_emit_at(page, len, "Model reference : %s\n", asus->name); in infos_show()
859 * bit signifies that the laptop is equipped with a Wi-Fi MiniPCI card. in infos_show()
862 rv = acpi_evaluate_integer(asus->handle, "SFUN", NULL, &temp); in infos_show()
871 * We don't currently use this for device detection, and it in infos_show()
874 rv = acpi_evaluate_integer(asus->handle, "HWRS", NULL, &temp); in infos_show()
885 rv = acpi_evaluate_integer(asus->handle, "ASYM", NULL, &temp); in infos_show()
889 if (asus->dsdt_info) { in infos_show()
890 snprintf(buf, 16, "%d", asus->dsdt_info->length); in infos_show()
892 snprintf(buf, 16, "%d", asus->dsdt_info->checksum); in infos_show()
894 snprintf(buf, 16, "%d", asus->dsdt_info->revision); in infos_show()
896 snprintf(buf, 7, "%s", asus->dsdt_info->oem_id); in infos_show()
898 snprintf(buf, 9, "%s", asus->dsdt_info->oem_table_id); in infos_show()
900 snprintf(buf, 16, "%x", asus->dsdt_info->oem_revision); in infos_show()
902 snprintf(buf, 5, "%s", asus->dsdt_info->asl_compiler_id); in infos_show()
904 snprintf(buf, 16, "%x", asus->dsdt_info->asl_compiler_revision); in infos_show()
922 if (write_acpi_int(asus->handle, method, value)) in sysfs_acpi_set()
923 return -ENODEV; in sysfs_acpi_set()
930 static ssize_t ledd_show(struct device *dev, struct device_attribute *attr, in ledd_show()
935 return sysfs_emit(buf, "0x%08x\n", asus->ledd_status); in ledd_show()
938 static ssize_t ledd_store(struct device *dev, struct device_attribute *attr, in ledd_store()
948 if (write_acpi_int(asus->handle, METHOD_LEDD, value)) { in ledd_store()
950 return -ENODEV; in ledd_store()
953 asus->ledd_status = (u32) value; in ledd_store()
966 if (!asus->have_rsts) in asus_wireless_status()
967 return (asus->wireless_status & mask) ? 1 : 0; in asus_wireless_status()
969 rv = acpi_evaluate_integer(asus->handle, METHOD_WL_STATUS, in asus_wireless_status()
973 return -EINVAL; in asus_wireless_status()
983 if (write_acpi_int(asus->handle, METHOD_WLAN, !!status)) { in asus_wlan_set()
985 return -EIO; in asus_wlan_set()
990 static ssize_t wlan_show(struct device *dev, struct device_attribute *attr, in wlan_show()
998 static ssize_t wlan_store(struct device *dev, struct device_attribute *attr, in wlan_store()
1012 if (write_acpi_int(asus->handle, METHOD_BLUETOOTH, !!status)) { in asus_bluetooth_set()
1014 return -EIO; in asus_bluetooth_set()
1019 static ssize_t bluetooth_show(struct device *dev, struct device_attribute *attr, in bluetooth_show()
1027 static ssize_t bluetooth_store(struct device *dev, in bluetooth_store()
1042 if (write_acpi_int(asus->handle, METHOD_WIMAX, !!status)) { in asus_wimax_set()
1044 return -EIO; in asus_wimax_set()
1049 static ssize_t wimax_show(struct device *dev, struct device_attribute *attr, in wimax_show()
1057 static ssize_t wimax_store(struct device *dev, struct device_attribute *attr, in wimax_store()
1071 if (write_acpi_int(asus->handle, METHOD_WWAN, !!status)) { in asus_wwan_set()
1073 return -EIO; in asus_wwan_set()
1078 static ssize_t wwan_show(struct device *dev, struct device_attribute *attr, in wwan_show()
1086 static ssize_t wwan_store(struct device *dev, struct device_attribute *attr, in wwan_store()
1101 if (write_acpi_int(asus->handle, METHOD_SWITCH_DISPLAY, value)) in asus_set_display()
1108 * the LCD output, 2 should do for CRT, 4 for TV-Out and 8 for DVI.
1113 static ssize_t display_store(struct device *dev, struct device_attribute *attr, in display_store()
1135 if (asus->is_pega_lucid) { in asus_als_switch()
1140 ret = write_acpi_int(asus->handle, METHOD_ALS_CONTROL, value); in asus_als_switch()
1145 asus->light_switch = value; in asus_als_switch()
1148 static ssize_t ls_switch_show(struct device *dev, struct device_attribute *attr, in ls_switch_show()
1153 return sysfs_emit(buf, "%d\n", asus->light_switch); in ls_switch_show()
1156 static ssize_t ls_switch_store(struct device *dev, in ls_switch_store()
1174 if (write_acpi_int(asus->handle, METHOD_ALS_LEVEL, value)) in asus_als_level()
1176 asus->light_level = value; in asus_als_level()
1179 static ssize_t ls_level_show(struct device *dev, struct device_attribute *attr, in ls_level_show()
1184 return sysfs_emit(buf, "%d\n", asus->light_level); in ls_level_show()
1187 static ssize_t ls_level_store(struct device *dev, struct device_attribute *attr, in ls_level_store()
1208 int err = write_acpi_int_ret(asus->handle, METHOD_PEGA_READ, arg, in pega_int_read()
1212 if (obj && obj->type == ACPI_TYPE_INTEGER) in pega_int_read()
1213 *result = obj->integer.value; in pega_int_read()
1215 err = -EIO; in pega_int_read()
1220 static ssize_t ls_value_show(struct device *dev, struct device_attribute *attr, in ls_value_show()
1243 rv = acpi_evaluate_integer(asus->handle, METHOD_GPS_STATUS, in asus_gps_status()
1247 return -ENODEV; in asus_gps_status()
1256 if (write_acpi_int(asus->handle, meth, 0x02)) in asus_gps_switch()
1257 return -ENODEV; in asus_gps_switch()
1261 static ssize_t gps_show(struct device *dev, struct device_attribute *attr, in gps_show()
1269 static ssize_t gps_store(struct device *dev, struct device_attribute *attr, in gps_store()
1282 rfkill_set_sw_state(asus->gps.rfkill, !value); in gps_store()
1304 struct asus_laptop *asus = rfk->asus; in asus_rfkill_set()
1306 if (rfk->control_id == WL_RSTS) in asus_rfkill_set()
1308 else if (rfk->control_id == BT_RSTS) in asus_rfkill_set()
1310 else if (rfk->control_id == WM_RSTS) in asus_rfkill_set()
1312 else if (rfk->control_id == WW_RSTS) in asus_rfkill_set()
1315 return -EINVAL; in asus_rfkill_set()
1324 if (!rfk->rfkill) in asus_rfkill_terminate()
1327 rfkill_unregister(rfk->rfkill); in asus_rfkill_terminate()
1328 rfkill_destroy(rfk->rfkill); in asus_rfkill_terminate()
1329 rfk->rfkill = NULL; in asus_rfkill_terminate()
1334 asus_rfkill_terminate(&asus->wwan); in asus_rfkill_exit()
1335 asus_rfkill_terminate(&asus->bluetooth); in asus_rfkill_exit()
1336 asus_rfkill_terminate(&asus->wlan); in asus_rfkill_exit()
1337 asus_rfkill_terminate(&asus->gps); in asus_rfkill_exit()
1346 rfk->control_id = control_id; in asus_rfkill_setup()
1347 rfk->asus = asus; in asus_rfkill_setup()
1348 rfk->rfkill = rfkill_alloc(name, &asus->platform_device->dev, in asus_rfkill_setup()
1350 if (!rfk->rfkill) in asus_rfkill_setup()
1351 return -EINVAL; in asus_rfkill_setup()
1353 result = rfkill_register(rfk->rfkill); in asus_rfkill_setup()
1355 rfkill_destroy(rfk->rfkill); in asus_rfkill_setup()
1356 rfk->rfkill = NULL; in asus_rfkill_setup()
1366 if (asus->is_pega_lucid) in asus_rfkill_init()
1367 return -ENODEV; in asus_rfkill_init()
1369 if (!acpi_check_handle(asus->handle, METHOD_GPS_ON, NULL) && in asus_rfkill_init()
1370 !acpi_check_handle(asus->handle, METHOD_GPS_OFF, NULL) && in asus_rfkill_init()
1371 !acpi_check_handle(asus->handle, METHOD_GPS_STATUS, NULL)) in asus_rfkill_init()
1372 result = asus_rfkill_setup(asus, &asus->gps, "asus-gps", in asus_rfkill_init()
1373 -1, RFKILL_TYPE_GPS, in asus_rfkill_init()
1379 if (!acpi_check_handle(asus->handle, METHOD_WLAN, NULL) && in asus_rfkill_init()
1380 asus->wled_type == TYPE_RFKILL) in asus_rfkill_init()
1381 result = asus_rfkill_setup(asus, &asus->wlan, "asus-wlan", in asus_rfkill_init()
1387 if (!acpi_check_handle(asus->handle, METHOD_BLUETOOTH, NULL) && in asus_rfkill_init()
1388 asus->bled_type == TYPE_RFKILL) in asus_rfkill_init()
1389 result = asus_rfkill_setup(asus, &asus->bluetooth, in asus_rfkill_init()
1390 "asus-bluetooth", BT_RSTS, in asus_rfkill_init()
1396 if (!acpi_check_handle(asus->handle, METHOD_WWAN, NULL)) in asus_rfkill_init()
1397 result = asus_rfkill_setup(asus, &asus->wwan, "asus-wwan", in asus_rfkill_init()
1403 if (!acpi_check_handle(asus->handle, METHOD_WIMAX, NULL)) in asus_rfkill_init()
1404 result = asus_rfkill_setup(asus, &asus->wimax, "asus-wimax", in asus_rfkill_init()
1421 int ret = asus_pega_lucid_set(rfk->asus, rfk->control_id, !blocked); in pega_rfkill_set()
1440 if(!asus->is_pega_lucid) in pega_rfkill_init()
1441 return -ENODEV; in pega_rfkill_init()
1443 ret = pega_rfkill_setup(asus, &asus->wlan, "pega-wlan", in pega_rfkill_init()
1448 ret = pega_rfkill_setup(asus, &asus->bluetooth, "pega-bt", in pega_rfkill_init()
1453 ret = pega_rfkill_setup(asus, &asus->wwan, "pega-wwan", in pega_rfkill_init()
1464 * Input device (i.e. hotkeys)
1468 if (!asus->inputdev) in asus_input_notify()
1470 if (!sparse_keymap_report_event(asus->inputdev, event, 1, true)) in asus_input_notify()
1481 return -ENOMEM; in asus_input_init()
1483 input->name = "Asus Laptop extra buttons"; in asus_input_init()
1484 input->phys = ASUS_LAPTOP_FILE "/input0"; in asus_input_init()
1485 input->id.bustype = BUS_HOST; in asus_input_init()
1486 input->dev.parent = &asus->platform_device->dev; in asus_input_init()
1490 pr_err("Unable to setup input device keymap\n"); in asus_input_init()
1495 pr_warn("Unable to register input device\n"); in asus_input_init()
1499 asus->inputdev = input; in asus_input_init()
1509 if (asus->inputdev) in asus_input_exit()
1510 input_unregister_device(asus->inputdev); in asus_input_exit()
1511 asus->inputdev = NULL; in asus_input_exit()
1517 static void asus_acpi_notify(struct acpi_device *device, u32 event) in asus_acpi_notify() argument
1519 struct asus_laptop *asus = acpi_driver_data(device); in asus_acpi_notify()
1522 /* TODO Find a better way to handle events count. */ in asus_acpi_notify()
1523 count = asus->event_count[event % 128]++; in asus_acpi_notify()
1524 acpi_bus_generate_netlink_event(asus->device->pnp.device_class, in asus_acpi_notify()
1525 dev_name(&asus->device->dev), event, in asus_acpi_notify()
1536 if (asus->backlight_device != NULL) { in asus_acpi_notify()
1537 /* Update the backlight device. */ in asus_acpi_notify()
1544 if (asus->pega_accel_poll && event == 0xEA) { in asus_acpi_notify()
1545 kobject_uevent(&asus->pega_accel_poll->dev.kobj, KOBJ_CHANGE); in asus_acpi_notify()
1571 struct device *dev = kobj_to_dev(kobj); in asus_sysfs_is_visible()
1573 acpi_handle handle = asus->handle; in asus_sysfs_is_visible() local
1576 if (asus->is_pega_lucid) { in asus_sysfs_is_visible()
1585 return supported ? attr->mode : 0; in asus_sysfs_is_visible()
1590 supported = !acpi_check_handle(handle, METHOD_WLAN, NULL); in asus_sysfs_is_visible()
1593 supported = !acpi_check_handle(handle, METHOD_BLUETOOTH, NULL); in asus_sysfs_is_visible()
1596 supported = !acpi_check_handle(handle, METHOD_SWITCH_DISPLAY, NULL); in asus_sysfs_is_visible()
1600 !acpi_check_handle(asus->handle, METHOD_WIMAX, NULL); in asus_sysfs_is_visible()
1603 supported = !acpi_check_handle(asus->handle, METHOD_WWAN, NULL); in asus_sysfs_is_visible()
1606 supported = !acpi_check_handle(handle, METHOD_LEDD, NULL); in asus_sysfs_is_visible()
1610 supported = !acpi_check_handle(handle, METHOD_ALS_CONTROL, NULL) && in asus_sysfs_is_visible()
1611 !acpi_check_handle(handle, METHOD_ALS_LEVEL, NULL); in asus_sysfs_is_visible()
1613 supported = asus->is_pega_lucid; in asus_sysfs_is_visible()
1615 supported = !acpi_check_handle(handle, METHOD_GPS_ON, NULL) && in asus_sysfs_is_visible()
1616 !acpi_check_handle(handle, METHOD_GPS_OFF, NULL) && in asus_sysfs_is_visible()
1617 !acpi_check_handle(handle, METHOD_GPS_STATUS, NULL); in asus_sysfs_is_visible()
1622 return supported ? attr->mode : 0; in asus_sysfs_is_visible()
1635 asus->platform_device = platform_device_alloc(ASUS_LAPTOP_FILE, PLATFORM_DEVID_NONE); in asus_platform_init()
1636 if (!asus->platform_device) in asus_platform_init()
1637 return -ENOMEM; in asus_platform_init()
1638 platform_set_drvdata(asus->platform_device, asus); in asus_platform_init()
1640 result = platform_device_add(asus->platform_device); in asus_platform_init()
1644 result = sysfs_create_group(&asus->platform_device->dev.kobj, in asus_platform_init()
1652 platform_device_del(asus->platform_device); in asus_platform_init()
1654 platform_device_put(asus->platform_device); in asus_platform_init()
1660 sysfs_remove_group(&asus->platform_device->dev.kobj, &asus_attr_group); in asus_platform_exit()
1661 platform_device_unregister(asus->platform_device); in asus_platform_exit()
1686 * before doing anything ACPI-specific. Should we encounter a machine, in asus_laptop_get_info()
1687 * which needs special handling (i.e. its hotkey device has a different in asus_laptop_get_info()
1690 status = acpi_get_table(ACPI_SIG_DSDT, 1, &asus->dsdt_info); in asus_laptop_get_info()
1695 if (write_acpi_int_ret(asus->handle, "INIT", 0, &buffer)) { in asus_laptop_get_info()
1697 return -ENODEV; in asus_laptop_get_info()
1702 acpi_evaluate_integer(asus->handle, "BSTS", NULL, &bsts_result); in asus_laptop_get_info()
1710 if (write_acpi_int(asus->handle, "CWAP", wapf)) in asus_laptop_get_info()
1714 * Handle every possible object (or the lack of thereof) the DSDT in asus_laptop_get_info()
1720 switch (model->type) { in asus_laptop_get_info()
1722 string = model->string.pointer; in asus_laptop_get_info()
1725 string = model->buffer.pointer; in asus_laptop_get_info()
1732 asus->name = kstrdup(string, GFP_KERNEL); in asus_laptop_get_info()
1733 if (!asus->name) { in asus_laptop_get_info()
1735 return -ENOMEM; in asus_laptop_get_info()
1741 if (!acpi_check_handle(asus->handle, METHOD_WL_STATUS, NULL)) in asus_laptop_get_info()
1742 asus->have_rsts = true; in asus_laptop_get_info()
1753 result = acpi_bus_get_status(asus->device); in asus_acpi_init()
1756 if (!asus->device->status.present) { in asus_acpi_init()
1757 pr_err("Hotkey device not present, aborting\n"); in asus_acpi_init()
1758 return -ENODEV; in asus_acpi_init()
1766 asus->bled_type = TYPE_LED; in asus_acpi_init()
1768 asus->bled_type = TYPE_RFKILL; in asus_acpi_init()
1771 asus->wled_type = TYPE_LED; in asus_acpi_init()
1773 asus->wled_type = TYPE_RFKILL; in asus_acpi_init()
1788 if (!acpi_check_handle(asus->handle, METHOD_KBD_LIGHT_SET, NULL)) in asus_acpi_init()
1792 asus->ledd_status = 0xFFF; in asus_acpi_init()
1795 asus->light_switch = !!als_status; in asus_acpi_init()
1796 asus->light_level = 5; /* level 5 for sensor sensitivity */ in asus_acpi_init()
1798 if (asus->is_pega_lucid) { in asus_acpi_init()
1799 asus_als_switch(asus, asus->light_switch); in asus_acpi_init()
1800 } else if (!acpi_check_handle(asus->handle, METHOD_ALS_CONTROL, NULL) && in asus_acpi_init()
1801 !acpi_check_handle(asus->handle, METHOD_ALS_LEVEL, NULL)) { in asus_acpi_init()
1802 asus_als_switch(asus, asus->light_switch); in asus_acpi_init()
1803 asus_als_level(asus, asus->light_level); in asus_acpi_init()
1819 wlan_status = -1; in asus_dmi_check()
1824 static int asus_acpi_add(struct acpi_device *device) in asus_acpi_add() argument
1833 return -ENOMEM; in asus_acpi_add()
1834 asus->handle = device->handle; in asus_acpi_add()
1835 strcpy(acpi_device_name(device), ASUS_LAPTOP_DEVICE_NAME); in asus_acpi_add()
1836 strcpy(acpi_device_class(device), ASUS_LAPTOP_CLASS); in asus_acpi_add()
1837 device->driver_data = asus; in asus_acpi_add()
1838 asus->device = device; in asus_acpi_add()
1848 * device. It is used as a parent for the sub-devices below. in asus_acpi_add()
1850 asus->is_pega_lucid = asus_check_pega_lucid(asus); in asus_acpi_add()
1870 if (result && result != -ENODEV) in asus_acpi_add()
1874 if (result && result != -ENODEV) in asus_acpi_add()
1878 if (result && result != -ENODEV) in asus_acpi_add()
1902 static void asus_acpi_remove(struct acpi_device *device) in asus_acpi_remove() argument
1904 struct asus_laptop *asus = acpi_driver_data(device); in asus_acpi_remove()
1913 kfree(asus->name); in asus_acpi_remove()
1948 result = -ENODEV; in asus_laptop_init()