Skip to contentSkip to conversation

leds: Change devm_led_classdev_register_ext stub logic to use IS_REACHABLE

PATCH In review Heiner Kallweit 3 participants 3 messages Dec 28, 2023 – Jan 9, 2024 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: Change devm_led_classdev_register_ext stub logic to use IS_REACHABLE

If CONFIG_LEDS_CLASS = m and the caller of devm_led_classdev_register is built-in, we get a compile/link error.
To avoid this we could add conditional compiling to the caller, but exactly this overhead we wanted to avoid with adding the stubs. Easiest solution is to use the existing stub also in case IS_ENABLED is true, but IS_REACHABLE is false.

Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")
---
 include/linux/leds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/leds.h +1 -1
index 4754b02d3..1eecee316 100644
@@ -279,7 +279,7 @@ static inline int led_classdev_register(struct device *parent,
 	return led_classdev_register_ext(parent, led_cdev, NULL);
 }
 
-#if IS_ENABLED(CONFIG_LEDS_CLASS)
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
 int devm_led_classdev_register_ext(struct device *parent,
 					  struct led_classdev *led_cdev,
 					  struct led_init_data *init_data);
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 7 lines · Heiner Kallweit

If CONFIG_LEDS_CLASS = m and the caller of devm_led_classdev_register is built-in, we get a compile/link error.
To avoid this we could add conditional compiling to the caller, but exactly this overhead we wanted to avoid with adding the stubs. Easiest solution is to use the existing stub also in case IS_ENABLED is true, but IS_REACHABLE is false.

Quoted 7 lines
Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")
---
 include/linux/leds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Arnd pretty much NACKed this, right?

https://lore.kernel.org/r/[email protected]

Quoted 16 lines
include/linux/leds.h +1 -1
index 4754b02d3..1eecee316 100644
@@ -279,7 +279,7 @@ static inline int led_classdev_register(struct device *parent,
 	return led_classdev_register_ext(parent, led_cdev, NULL);
 }
 
-#if IS_ENABLED(CONFIG_LEDS_CLASS)
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
 int devm_led_classdev_register_ext(struct device *parent,
 					  struct led_classdev *led_cdev,
 					  struct led_init_data *init_data);
Signature · 1 line
2.43.0
Signature · 1 line
Lee Jones [李琼斯]
#2 lore raw
Quoted 17 lines · Lee Jones
Quoted 7 lines · Heiner Kallweit

If CONFIG_LEDS_CLASS = m and the caller of devm_led_classdev_register is built-in, we get a compile/link error.
To avoid this we could add conditional compiling to the caller, but exactly this overhead we wanted to avoid with adding the stubs. Easiest solution is to use the existing stub also in case IS_ENABLED is true, but IS_REACHABLE is false.

Quoted 7 lines
Fixes 18764b883e15 ("r8169: add support for LED's on RTL8168/RTL8101")
---
 include/linux/leds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 3 lines

Arnd pretty much NACKed this, right?

https://lore.kernel.org/r/[email protected]

Yes, I actually wrote a replacement that does the opposite, I just need to send that out.

Arnd