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

leds: Replace {devm_}led_classdev_register() macros with inlines

Replace preprocessor macro aliases for legacy LED registration helpers
with inline functions. It will allow to avoid misleading compiler error
messages about missing symbol that actually wasn't explicitly used
in the code. It used to occur when CONFIG_LEDS_CLASS was undefined
and legacy (non-ext) function had been used in the code.

Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Acked-by: Pavel Machek <pavel@ucw.cz>

+25 -4
+25 -4
include/linux/leds.h
··· 157 157 * @led_cdev: the led_classdev structure for this device 158 158 * @init_data: the LED class device initialization data 159 159 * 160 + * Register a new object of LED class, with name derived from init_data. 161 + * 160 162 * Returns: 0 on success or negative error value on failure 161 163 */ 162 164 extern int led_classdev_register_ext(struct device *parent, 163 165 struct led_classdev *led_cdev, 164 166 struct led_init_data *init_data); 165 - #define led_classdev_register(parent, led_cdev) \ 166 - led_classdev_register_ext(parent, led_cdev, NULL) 167 + 168 + /** 169 + * led_classdev_register - register a new object of LED class 170 + * @parent: LED controller device this LED is driven by 171 + * @led_cdev: the led_classdev structure for this device 172 + * 173 + * Register a new object of LED class, with name derived from the name property 174 + * of passed led_cdev argument. 175 + * 176 + * Returns: 0 on success or negative error value on failure 177 + */ 178 + static inline int led_classdev_register(struct device *parent, 179 + struct led_classdev *led_cdev) 180 + { 181 + return led_classdev_register_ext(parent, led_cdev, NULL); 182 + } 183 + 167 184 extern int devm_led_classdev_register_ext(struct device *parent, 168 185 struct led_classdev *led_cdev, 169 186 struct led_init_data *init_data); 170 - #define devm_led_classdev_register(parent, led_cdev) \ 171 - devm_led_classdev_register_ext(parent, led_cdev, NULL) 187 + 188 + static inline int devm_led_classdev_register(struct device *parent, 189 + struct led_classdev *led_cdev) 190 + { 191 + return devm_led_classdev_register_ext(parent, led_cdev, NULL); 192 + } 172 193 extern void led_classdev_unregister(struct led_classdev *led_cdev); 173 194 extern void devm_led_classdev_unregister(struct device *parent, 174 195 struct led_classdev *led_cdev);