Linux Input/HID development
 help / color / mirror / Atom feed
* [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

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