Re: [PATCH 2/2] platform/x86: lg-laptop: Improve keyboard backlight detection

From: Ilpo Järvinen

Date: Wed Nov 25 2026 - 17:16:25 EST


On Sat, 21 Nov 2026, Armin Wolf wrote:

> Not all devices support the keyboard backlight feature, instead they
> will return an error when trying to read/write the backlight level.
>
> Avoid registering the associated LED class device on such devices
> by first verifying that reading of the backlight level works. For
> this the get_kbd_backlight_level() function has to be modified to
> stop hiding any errors coming from the WMAB call.
>
> Reported-by: Carlos Javier Alvarez <daxter1992@xxxxxxxxx>
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=222275
> Tested-by: Carlos Javier Alvarez <daxter1992@xxxxxxxxx>
> Signed-off-by: Armin Wolf <W_Armin@xxxxxx>
> ---
> drivers/platform/x86/lg-laptop.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
> index a784071de8b3..72955fc868af 100644
> --- a/drivers/platform/x86/lg-laptop.c
> +++ b/drivers/platform/x86/lg-laptop.c
> @@ -641,10 +641,10 @@ static enum led_brightness get_kbd_backlight_level(struct device *dev)
>
> ret = lg_wmab_get(dev, WM_KEY_LIGHT, &value);
> if (ret < 0)
> - return LED_OFF;
> + return ret;
>
> if (FIELD_GET(KBD_LED_MAGIC_MASK, value) != KBD_LED_MAGIC)
> - return LED_OFF;
> + return -EIO;

Please check sashiko's complaint about missing error handling.

--
i.

> if (FIELD_GET(KBD_LED_MODE_MASK, value) == KBD_LED_MODE_OFF)
> return LED_OFF;
> @@ -823,6 +823,21 @@ static int lg_laptop_input_init(struct device *dev, acpi_handle handle)
> return 0;
> }
>
> +static int lg_laptop_kbd_backlight_init(struct device *dev)
> +{
> + int ret;
> +
> + /*
> + * Devices that do not support the keyboard backlight feature
> + * usually return a error when trying to read the backlight level.
> + */
> + ret = get_kbd_backlight_level(dev);
> + if (ret < 0)
> + return ret;
> +
> + return devm_led_classdev_register(dev, &kbd_backlight);
> +}
> +
> static acpi_status lg_laptop_address_space_write(struct device *dev, acpi_physical_address address,
> size_t size, u64 value)
> {
> @@ -1035,7 +1050,7 @@ static int acpi_probe(struct platform_device *pdev)
> battery_limit_use_wmbb = 1;
>
> /* LEDs are optional */
> - ret = devm_led_classdev_register(&pdev->dev, &kbd_backlight);
> + ret = lg_laptop_kbd_backlight_init(&pdev->dev);
> if (ret < 0)
> kbd_backlight_available = false;
> else
>