Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

leds: Remove led_init_default_state_get() and devm_led_classdev_register_ext() stubs

These two functions have stub implementations that are called when
NEW_LEDS and/or LEDS_CLASS are disabled, theorerically allowing drivers
to optionally use the LED subsystem.

However, this has never really worked because a built-in driver is
unable to link against these functions if the LED class is in a loadable
module. Heiner ran into this problem with a driver that newly gained
a LEDS_CLASS dependency and suggested using an IS_REACHABLE() check.

This is the reverse approach, removing the stub entirely to acknowledge
that it is pointless in its current form, and that not having it avoids
misleading developers into thinking that they can rely on it.

This survived around 1000 randconfig builds to validate that any callers
of the interface already have the correct Kconfig dependency already,
with the exception of the one that Heiner just added.

Cc: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/linux-leds/0f6f432b-c650-4bb8-a1b5-fe3372804d52@gmail.com/T/#u
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240109090715.982332-1-arnd@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Arnd Bergmann and committed by
Lee Jones
211f8ec9 d0532248

-19
-19
include/linux/leds.h
··· 82 82 bool devname_mandatory; 83 83 }; 84 84 85 - #if IS_ENABLED(CONFIG_NEW_LEDS) 86 85 enum led_default_state led_init_default_state_get(struct fwnode_handle *fwnode); 87 - #else 88 - static inline enum led_default_state 89 - led_init_default_state_get(struct fwnode_handle *fwnode) 90 - { 91 - return LEDS_DEFSTATE_OFF; 92 - } 93 - #endif 94 86 95 87 struct led_hw_trigger_type { 96 88 int dummy; ··· 271 279 return led_classdev_register_ext(parent, led_cdev, NULL); 272 280 } 273 281 274 - #if IS_ENABLED(CONFIG_LEDS_CLASS) 275 282 int devm_led_classdev_register_ext(struct device *parent, 276 283 struct led_classdev *led_cdev, 277 284 struct led_init_data *init_data); 278 - #else 279 - static inline int 280 - devm_led_classdev_register_ext(struct device *parent, 281 - struct led_classdev *led_cdev, 282 - struct led_init_data *init_data) 283 - { 284 - return 0; 285 - } 286 - #endif 287 - 288 285 static inline int devm_led_classdev_register(struct device *parent, 289 286 struct led_classdev *led_cdev) 290 287 {