linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: Replace {devm_}led_classdev_register() macros with inlines
@ 2019-08-26 21:02 Jacek Anaszewski
  2019-08-27 11:31 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Jacek Anaszewski @ 2019-08-26 21:02 UTC (permalink / raw)
  To: linux-leds; +Cc: linux-kernel, Jacek Anaszewski, Pavel Machek, Dan Murphy

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>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: Dan Murphy <dmurphy@ti.com>
---
 include/linux/leds.h | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/include/linux/leds.h b/include/linux/leds.h
index d101fd13e18e..b8df71193329 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -157,18 +157,39 @@ struct led_classdev {
  * @led_cdev: the led_classdev structure for this device
  * @init_data: the LED class device initialization data
  *
+ * Register a new object of LED class, with name derived from init_data.
+ *
  * Returns: 0 on success or negative error value on failure
  */
 extern int led_classdev_register_ext(struct device *parent,
 				     struct led_classdev *led_cdev,
 				     struct led_init_data *init_data);
-#define led_classdev_register(parent, led_cdev)			\
-	led_classdev_register_ext(parent, led_cdev, NULL)
+
+/**
+ * led_classdev_register - register a new object of LED class
+ * @parent: LED controller device this LED is driven by
+ * @led_cdev: the led_classdev structure for this device
+ *
+ * Register a new object of LED class, with name derived from the name property
+ * of passed led_cdev argument.
+ *
+ * Returns: 0 on success or negative error value on failure
+ */
+static inline int led_classdev_register(struct device *parent,
+					struct led_classdev *led_cdev)
+{
+	return led_classdev_register_ext(parent, led_cdev, NULL);
+}
+
 extern int devm_led_classdev_register_ext(struct device *parent,
 					  struct led_classdev *led_cdev,
 					  struct led_init_data *init_data);
-#define devm_led_classdev_register(parent, led_cdev)		\
-	devm_led_classdev_register_ext(parent, led_cdev, NULL)
+
+static inline int devm_led_classdev_register(struct device *parent,
+					     struct led_classdev *led_cdev)
+{
+	return devm_led_classdev_register_ext(parent, led_cdev, NULL);
+}
 extern void led_classdev_unregister(struct led_classdev *led_cdev);
 extern void devm_led_classdev_unregister(struct device *parent,
 					 struct led_classdev *led_cdev);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] leds: Replace {devm_}led_classdev_register() macros with inlines
  2019-08-26 21:02 [PATCH] leds: Replace {devm_}led_classdev_register() macros with inlines Jacek Anaszewski
@ 2019-08-27 11:31 ` Pavel Machek
  2019-08-27 21:34   ` Jacek Anaszewski
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2019-08-27 11:31 UTC (permalink / raw)
  To: Jacek Anaszewski; +Cc: linux-leds, linux-kernel, Dan Murphy

[-- Attachment #1: Type: text/plain, Size: 2826 bytes --]

On Mon 2019-08-26 23:02:19, Jacek Anaszewski wrote:
> 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>

> Cc: Dan Murphy <dmurphy@ti.com>
> ---
>  include/linux/leds.h | 29 +++++++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index d101fd13e18e..b8df71193329 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -157,18 +157,39 @@ struct led_classdev {
>   * @led_cdev: the led_classdev structure for this device
>   * @init_data: the LED class device initialization data
>   *
> + * Register a new object of LED class, with name derived from init_data.
> + *
>   * Returns: 0 on success or negative error value on failure
>   */
>  extern int led_classdev_register_ext(struct device *parent,
>  				     struct led_classdev *led_cdev,
>  				     struct led_init_data *init_data);
> -#define led_classdev_register(parent, led_cdev)			\
> -	led_classdev_register_ext(parent, led_cdev, NULL)
> +
> +/**
> + * led_classdev_register - register a new object of LED class
> + * @parent: LED controller device this LED is driven by
> + * @led_cdev: the led_classdev structure for this device
> + *
> + * Register a new object of LED class, with name derived from the name property
> + * of passed led_cdev argument.
> + *
> + * Returns: 0 on success or negative error value on failure
> + */
> +static inline int led_classdev_register(struct device *parent,
> +					struct led_classdev *led_cdev)
> +{
> +	return led_classdev_register_ext(parent, led_cdev, NULL);
> +}
> +
>  extern int devm_led_classdev_register_ext(struct device *parent,
>  					  struct led_classdev *led_cdev,
>  					  struct led_init_data *init_data);
> -#define devm_led_classdev_register(parent, led_cdev)		\
> -	devm_led_classdev_register_ext(parent, led_cdev, NULL)
> +
> +static inline int devm_led_classdev_register(struct device *parent,
> +					     struct led_classdev *led_cdev)
> +{
> +	return devm_led_classdev_register_ext(parent, led_cdev, NULL);
> +}
>  extern void led_classdev_unregister(struct led_classdev *led_cdev);
>  extern void devm_led_classdev_unregister(struct device *parent,
>  					 struct led_classdev *led_cdev);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] leds: Replace {devm_}led_classdev_register() macros with inlines
  2019-08-27 11:31 ` Pavel Machek
@ 2019-08-27 21:34   ` Jacek Anaszewski
  0 siblings, 0 replies; 3+ messages in thread
From: Jacek Anaszewski @ 2019-08-27 21:34 UTC (permalink / raw)
  To: Pavel Machek; +Cc: linux-leds, linux-kernel, Dan Murphy

On 8/27/19 1:31 PM, Pavel Machek wrote:
> On Mon 2019-08-26 23:02:19, Jacek Anaszewski wrote:
>> 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>

Thanks, applied.

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-08-27 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-26 21:02 [PATCH] leds: Replace {devm_}led_classdev_register() macros with inlines Jacek Anaszewski
2019-08-27 11:31 ` Pavel Machek
2019-08-27 21:34   ` Jacek Anaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).