* [PATCH] HID: lg4ff: use IS_REACHABLE(CONFIG_LEDS_CLASS) for wheel LEDs
@ 2026-12-04 2:25 Pengpeng Hou
2026-12-04 2:37 ` sashiko-bot
0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-12-04 2:25 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires; +Cc: linux-input, Pengpeng Hou
The Logitech wheel driver omits the RPM LED class integration when both
it and the LED class are modules. This affects the supported wheel
models even when their LED hardware is present.
Use IS_REACHABLE for the state, callbacks, registration and teardown;
leave the model selection unchanged.
The issue was found by our static-analysis tool and manually reviewed.
Fixes: 22bcefdc8838 ("HID: hid-lg4ff: Add support for G27 LEDs")
Signed-off-by: Pengpeng Hou <hppiscas@163.com>
---
The original patch was prepared with Gemini. Codex assisted with this
review and revision (Assisted-by: gpt 5).
Built hid-lg4ff.o on x86-64 with GCC 11.4 and W=1
(CONFIG_HID_LOGITECH=m, CONFIG_LOGIWHEELS_FF=y, CONFIG_LEDS_CLASS=m). No
runtime or hardware test was performed.
drivers/hid/hid-lg4ff.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
index 62f99a93210c9d28b91b64236874dfd7d3127f75..d4411a696cc48eca1c30e9571ce97f047f5349e1 100644
--- a/drivers/hid/hid-lg4ff.c
+++ b/drivers/hid/hid-lg4ff.c
@@ -67,7 +67,7 @@ struct lg4ff_wheel_data {
u16 range;
const u16 min_range;
const u16 max_range;
-#ifdef CONFIG_LEDS_CLASS
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
u8 led_state;
struct led_classdev *led[5];
#endif
@@ -1092,7 +1092,7 @@ static ssize_t lg4ff_real_id_store(struct device *dev, struct device_attribute *
}
static DEVICE_ATTR(real_id, S_IRUGO, lg4ff_real_id_show, lg4ff_real_id_store);
-#ifdef CONFIG_LEDS_CLASS
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
static void lg4ff_set_leds(struct hid_device *hid, u8 leds)
{
struct lg_drv_data *drv_data;
@@ -1399,7 +1399,7 @@ int lg4ff_init(struct hid_device *hid)
if (entry->wdata.set_range)
entry->wdata.set_range(hid, entry->wdata.range);
-#ifdef CONFIG_LEDS_CLASS
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
/* register led subsystem - G27/G29 only */
entry->wdata.led_state = 0;
for (j = 0; j < 5; j++)
@@ -1482,7 +1482,7 @@ int lg4ff_deinit(struct hid_device *hid)
device_remove_file(&hid->dev, &dev_attr_combine_pedals);
device_remove_file(&hid->dev, &dev_attr_range);
-#ifdef CONFIG_LEDS_CLASS
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
{
int j;
struct led_classdev *led;
base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] HID: lg4ff: use IS_REACHABLE(CONFIG_LEDS_CLASS) for wheel LEDs
2026-12-04 2:25 [PATCH] HID: lg4ff: use IS_REACHABLE(CONFIG_LEDS_CLASS) for wheel LEDs Pengpeng Hou
@ 2026-12-04 2:37 ` sashiko-bot
0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-04 2:37 UTC (permalink / raw)
To: Pengpeng Hou; +Cc: linux-input, dmitry.torokhov
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] HID: lg4ff: redundant IS_REACHABLE(CONFIG_LEDS_CLASS)
preprocessor guards
--
commit a37dabf5bd6831438894f407db9423b32e6bd057
Author: Pengpeng Hou <hppiscas@163.com>
HID: lg4ff: use IS_REACHABLE(CONFIG_LEDS_CLASS) for wheel LEDs
This commit replaces the #ifdef CONFIG_LEDS_CLASS guards in
drivers/hid/hid-lg4ff.c with #if IS_REACHABLE(CONFIG_LEDS_CLASS) so wheel
RPM LED support is compiled when both the driver and the LED class are
modules.
> diff --git a/drivers/hid/hid-lg4ff.c b/drivers/hid/hid-lg4ff.c
> index 62f99a93210c9..d4411a696cc48 100644
> --- a/drivers/hid/hid-lg4ff.c
> +++ b/drivers/hid/hid-lg4ff.c
> @@ -67,7 +67,7 @@ struct lg4ff_wheel_data {
> u16 range;
> const u16 min_range;
> const u16 max_range;
> -#ifdef CONFIG_LEDS_CLASS
> +#if IS_REACHABLE(CONFIG_LEDS_CLASS)
> u8 led_state;
> struct led_classdev *led[5];
> #endif
[Severity: Low]
Are these IS_REACHABLE(CONFIG_LEDS_CLASS) guards needed at all?
In drivers/hid/Kconfig, HID_LOGITECH unconditionally depends on
LEDS_CLASS and LOGIWHEELS_FF depends on HID_LOGITECH. Since hid-lg4ff.o
is only linked into hid-logitech.o, CONFIG_LEDS_CLASS is always reachable
whenever hid-lg4ff.c is built.
Removing all four preprocessor guards and the extra scoping block in
lg4ff_deinit() would be simpler and avoid suggesting that LED class
support is optional.
--
Sashiko AI review · https://sashiko.dev/#/patchset/179635115621.74470.12359277234264394358@163.com?part=1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-04 2:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 2:25 [PATCH] HID: lg4ff: use IS_REACHABLE(CONFIG_LEDS_CLASS) for wheel LEDs Pengpeng Hou
2026-12-04 2:37 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox