Re: [PATCH] platform/x86: asus-wmi: Clamp keyboard backlight level from hotkeys
From: alex
Date: Sun Oct 25 2026 - 01:47:33 EST
Hi Denis,
thanks for the review!
On Monday, October 19th, 2026 at 5:52 PM, Denis Benato <denis.benato@xxxxxxxxx> wrote:
> Is the change of type really necessary? I think clamp_value does everything required already.
Hi Denis, thanks for the reply,
clamp_val() without the type change wouldn't fix the problem, as
at level 0, led_value - 1 is an unsigned type and wraps around. clamp_val() then clamps this to 3, setting the leds to max
brightness
> Honestly I don't like the change of type... I would prefer something that prevents the
> bad thing from happening without changing the type.
My reasoning for int was consistency, as asus_hid_event() and
do_kbd_led_set() already do this arithmetic as int, and the comment
on enum led_brightness in leds.h describes it as obsolete.
That said, if you prefer keeping the enum, one could avoid the
wraparound instead with the call
kbd_led_set_by_kbd(asus, led_value ? led_value - 1 : 0);
and keep the clamp in kbd_led_set_by_kbd() for the upper bound.
Thanks,
Alex