Re: [PATCH v2 2/2] HID: lenovo-legion: Add keyboard backlight driver for Legion Gen 10
From: Ciro Pedrini
Date: Thu Nov 26 2026 - 20:14:43 EST
Hi Ilpo,
On Wed, 11 Nov 2026, Ilpo Järvinen wrote:
> Thanks for the update, this one looks much cleaner already. :-)
Thanks! All of these are done in v3:
https://lore.kernel.org/r/20261127-legion-lighting-rfc-v3-0-15c55d9f15b7@xxxxxxxxx
> > + if (ret <= (int)sizeof(*msg) || msg->report_id != LEGION_REPORT_ID ||
>
> Just remove this cast.
Removed, also the one in raw_event.
> > + hid_warn(hdev, "unexpected answer to 0x%02x: %*ph\n", op,
> > + min(ret, 8), msg);
>
> Printing data like this looks more like debug level stuff.
It's hid_dbg() now, without the dump.
> > + WRITE_ONCE(kbd->led.brightness, level);
>
> Please add include for this.
That write is gone (brightness_get reads the hardware). The driver now
keeps the last known level for brightness_hw_changed with
READ_ONCE()/WRITE_ONCE(), so it includes <asm/rwonce.h>.
> > + * LED_BRIGHT_HW_CHANGED: Fn+Up/Down are reported to userspace.
> > + */
>
> This only documents what these flags are so why a driver needs such a
> comment?
Dropped.
> But could you solve this with devm_add_action_or_reset() (for hid
> teardown) and use devm for everything?
Yes: hid_hw_start()/hid_hw_open() with a devm action that closes and
stops, then devm_led_classdev_register(). The .remove callback stays,
empty with a comment, because without it hid-core calls hid_hw_stop()
itself before releasing the devm resources.
> > +MODULE_DESCRIPTION("Keyboard backlight of Lenovo Legion laptops (2025)");
>
> I don't think we should put year into this
Removed here and in the file header.
Thanks,
Ciro