platform/chrome: cros_kbd_led_backlight: use matched ACPI device handle
Subsystems (2)
PATCH 1/1 platform/chrome: cros_kbd_led_backlight: use matched ACPI device handle
The ACPI backend hardcodes \_SB.KBLT for brightness get/set. Older coreboot ASL places GOOG0002 there, but newer builds can nest it under \_SB.CREC, so the absolute path lookup fails even though the driver already bound to the correct HID.
Evaluate KBQC/KBCM on the ACPI companion of the matched platform device instead of a fixed path, as done with the Chrome TBMC driver.
--- .../platform/chrome/cros_kbd_led_backlight.c | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-)
drivers/platform/chrome/cros_kbd_led_backlight.c +15 -16
@@ -47,14 +47,14 @@ struct keyboard_led_drvdata {#ifdef CONFIG_ACPI -/* Keyboard LED ACPI Device must be defined in firmware */ -#define ACPI_KEYBOARD_BACKLIGHT_DEVICE "\\_SB.KBLT" -#define ACPI_KEYBOARD_BACKLIGHT_READ ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC" -#define ACPI_KEYBOARD_BACKLIGHT_WRITE ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBCM" +/* Keyboard LED ACPI methods on the matched GOOG0002 device */ +#define ACPI_KEYBOARD_BACKLIGHT_READ "KBQC" +#define ACPI_KEYBOARD_BACKLIGHT_WRITE "KBCM"static void keyboard_led_set_brightness_acpi (struct led_classdev *cdev,enum led_brightness brightness) { +acpi_handle handle =ACPI_HANDLE (cdev->dev->parent);union acpi_object param;struct acpi_object_list input;acpi_status status;
@@ -64,7 +64,7 @@ static void keyboard_led_set_brightness_acpi(struct led_classdev *cdev, input.count =1 ; input.pointer = ¶m; - status =acpi_evaluate_object (NULL ,ACPI_KEYBOARD_BACKLIGHT_WRITE , + status =acpi_evaluate_object (handle,ACPI_KEYBOARD_BACKLIGHT_WRITE , &input,NULL );if (ACPI_FAILURE (status)) dev_err(cdev->dev, "Error setting keyboard LED value: %d\n",
@@ -74,10 +74,11 @@ static void keyboard_led_set_brightness_acpi(struct led_classdev *cdev,static enum led_brightness keyboard_led_get_brightness_acpi (struct led_classdev *cdev) { +acpi_handle handle =ACPI_HANDLE (cdev->dev->parent);unsigned long long brightness;acpi_status status; - status =acpi_evaluate_integer (NULL ,ACPI_KEYBOARD_BACKLIGHT_READ , + status =acpi_evaluate_integer (handle,ACPI_KEYBOARD_BACKLIGHT_READ ,NULL , &brightness);if (ACPI_FAILURE (status)) { dev_err(cdev->dev, "Error getting keyboard LED value: %d\n",
@@ -91,17 +92,15 @@ keyboard_led_get_brightness_acpi(struct led_classdev *cdev)static int keyboard_led_init_acpi (struct platform_device *pdev,struct keyboard_led *keyboard_led) { -acpi_handle handle; -acpi_status status; +acpi_handle handle =ACPI_HANDLE (&pdev->dev); -/* Look for the keyboard LED ACPI Device */ - status =acpi_get_handle (ACPI_ROOT_OBJECT , -ACPI_KEYBOARD_BACKLIGHT_DEVICE , - &handle); -if (ACPI_FAILURE (status)) { -dev_err (&pdev->dev,"Unable to find ACPI device %s: %d\n" , -ACPI_KEYBOARD_BACKLIGHT_DEVICE , status); -return -ENXIO ; +if (!handle) +return -ENODEV ; + +if (!acpi_has_method (handle,ACPI_KEYBOARD_BACKLIGHT_READ ) || + !acpi_has_method (handle,ACPI_KEYBOARD_BACKLIGHT_WRITE )) { +dev_err (&pdev->dev,"Missing keyboard LED ACPI methods\n" ); +return -ENODEV ; }return 0 ;
Signature · 1 line
2.53.0
Tzung-Bi Shih
maintainerQuoted 9 lines · Matt DeVillier
The ACPI backend hardcodes \_SB.KBLT for brightness get/set. Older coreboot ASL places GOOG0002 there, but newer builds can nest it under \_SB.CREC, so the absolute path lookup fails even though the driver already bound to the correct HID.
Evaluate KBQC/KBCM on the ACPI companion of the matched platform device instead of a fixed path, as done with the Chrome TBMC driver.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git for-next
[1/1] platform/chrome: cros_kbd_led_backlight: use matched ACPI device handle
commit: 71c3b4fe739123f9caca98cfbe274a85efa601a9
Thanks!