Skip to contentSkip to conversation

Input: cap11xx - use IS_REACHABLE(CONFIG_LEDS_CLASS) for LED support

PATCH New Pengpeng Hou 1 participant 1 message Dec 4

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Input: cap11xx - use IS_REACHABLE(CONFIG_LEDS_CLASS) for LED support

CAP11xx skips LED class registration when the input driver and LED class are modules. The sleep decision also needs to agree with whether that integration was compiled.

Use reachability consistently for registration and the sleep check. The existing device capabilities and firmware LED descriptions still decide whether any LEDs are registered.

The issue was found by our static-analysis tool and manually reviewed.

Fixes efe3b616f88c ("Input: cap11xx - add LED support")

---
The original patch was prepared with Gemini. Codex assisted with this review and revision (Assisted-by: gpt 5).
Built cap11xx.o on x86-64 with GCC 11.4 and W=1 (CONFIG_KEYBOARD_CAP11XX=m, CONFIG_LEDS_CLASS=m). No runtime or hardware test was performed.

 drivers/input/keyboard/cap11xx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/input/keyboard/cap11xx.c +3 -3
index 6ef70bc52640d8814636da238cc73e8cba8092cc..1f9014ebfcbe4dd5e327c59225fe5ce324b2528d 100644
@@ -55,7 +55,7 @@
 #define CAP11XX_T_RST_FILT_MIN_US	10000
 #define CAP11XX_T_RST_ON_MIN_MS		400
 
-#ifdef CONFIG_LEDS_CLASS
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
 struct cap11xx_led {
 	struct cap11xx_priv *priv;
 	struct led_classdev cdev;
@@ -377,7 +377,7 @@ static int cap11xx_set_sleep(struct cap11xx_priv *priv, bool sleep)
 	/*
 	 * DLSEEP mode will turn off all LEDS, prevent this
 	 */
-	if (IS_ENABLED(CONFIG_LEDS_CLASS) && priv->num_leds)
+	if (IS_REACHABLE(CONFIG_LEDS_CLASS) && priv->num_leds)
 		return 0;
 
 	return regmap_update_bits(priv->regmap, CAP11XX_REG_MAIN_CONTROL,
@@ -399,7 +399,7 @@ static void cap11xx_input_close(struct input_dev *idev)
 	cap11xx_set_sleep(priv, true);
 }
 
-#ifdef CONFIG_LEDS_CLASS
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
 static int cap11xx_led_set(struct led_classdev *cdev,
 			    enum led_brightness value)
 {

base-commit: d06ce6f1eb5eeffd4ebcfde345dc34a98131d106