mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt DeVillier <matt.devillier@gmail.com>
To: Benson Leung <bleung@chromium.org>, Tzung-Bi Shih <tzungbi@kernel.org>
Cc: chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
	Matt DeVillier <matt.devillier@gmail.com>
Subject: [PATCH] platform/chrome: cros_kbd_led_backlight: use matched ACPI device handle
Date: Wed, 11 Nov 2026 11:25:17 -0600	[thread overview]
Message-ID: <20261111172517.1407888-1-matt.devillier@gmail.com> (raw)

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.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
---
 .../platform/chrome/cros_kbd_led_backlight.c  | 31 +++++++++----------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index 8f992a8f79d05..ad267eee8cadb 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -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 = &param;
 
-	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;
-- 
2.53.0


                 reply	other threads:[~2026-11-11 17:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261111172517.1407888-1-matt.devillier@gmail.com \
    --to=matt.devillier@gmail.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tzungbi@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®