Skip to content

Commit 7a3c36e

Browse files
stuarthayhurstij-intel
authored andcommitted
platform/x86: ideapad-laptop: Set max_brightness before using it
max_brightness is used in ideapad_kbd_bl_brightness_get() before it's set, causing ideapad_kbd_bl_brightness_get() to return -EINVAL sometimes. Fixes: ecaa186 ("platform/x86: ideapad-laptop: Add support for keyboard backlights using KBLC ACPI symbol") Signed-off-by: Stuart Hayhurst <[email protected]> Cc: [email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 9fadd45 commit 7a3c36e

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/platform/x86/ideapad-laptop.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,18 +1425,17 @@ static int ideapad_kbd_bl_init(struct ideapad_private *priv)
14251425
if (WARN_ON(priv->kbd_bl.initialized))
14261426
return -EEXIST;
14271427

1428-
brightness = ideapad_kbd_bl_brightness_get(priv);
1429-
if (brightness < 0)
1430-
return brightness;
1431-
1432-
priv->kbd_bl.last_brightness = brightness;
1433-
14341428
if (ideapad_kbd_bl_check_tristate(priv->kbd_bl.type)) {
14351429
priv->kbd_bl.led.max_brightness = 2;
14361430
} else {
14371431
priv->kbd_bl.led.max_brightness = 1;
14381432
}
14391433

1434+
brightness = ideapad_kbd_bl_brightness_get(priv);
1435+
if (brightness < 0)
1436+
return brightness;
1437+
1438+
priv->kbd_bl.last_brightness = brightness;
14401439
priv->kbd_bl.led.name = "platform::" LED_FUNCTION_KBD_BACKLIGHT;
14411440
priv->kbd_bl.led.brightness_get = ideapad_kbd_bl_led_cdev_brightness_get;
14421441
priv->kbd_bl.led.brightness_set_blocking = ideapad_kbd_bl_led_cdev_brightness_set;

0 commit comments

Comments
 (0)