All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] leds: fix redundant trigger API #ifdef
@ 2015-04-09 15:25 Valentin Rothberg
  2015-04-09 15:37 ` [PATCH v2] " Valentin Rothberg
  0 siblings, 1 reply; 3+ messages in thread
From: Valentin Rothberg @ 2015-04-09 15:25 UTC (permalink / raw)
  To: j.anaszewski, cooloney, rpurdie, linux-leds, linux-kernel,
	pebolle, rupran, stefan.hengelein
  Cc: Valentin Rothberg

Commit 5a15d172057c ("leds: unify the location of led-trigger API")
moved the leds trigger API to led.h.  Moving the function definitions
caused a logical problem regarding the visibility of #idef blocks.  As
listed in the code snippet below, the inner #else block will never see a
compiler since CONFIG_LEDS_TRIGGERS is always true for the second #ifdef.

This patch removes the second, redundant #ifdef and moves the code of
the #else branch to its proper place.

Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
---
I found this issue with undertaker-checkpatch from the Undertaker
toolsuite.  See undertaker.cs.fau.de for more information.
---
 include/linux/leds.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/linux/leds.h b/include/linux/leds.h
index 057970818961..96a669f93f69 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -223,7 +223,6 @@ struct led_trigger {
 	struct list_head  next_trig;
 };
 
-#ifdef CONFIG_LEDS_TRIGGERS
 void led_trigger_set_default(struct led_classdev *led_cdev);
 void led_trigger_set(struct led_classdev *led_cdev,
 			struct led_trigger *trigger);
@@ -234,13 +233,6 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
 	return led_cdev->trigger_data;
 }
 
-#else
-#define led_trigger_set_default(x) do {} while (0)
-#define led_trigger_set(x, y) do {} while (0)
-#define led_trigger_remove(x) do {} while (0)
-#define led_get_trigger_data(x) (NULL)
-#endif
-
 ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
 			const char *buf, size_t count);
 ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
@@ -282,6 +274,11 @@ extern void led_trigger_rename_static(const char *name,
 
 #else
 
+#define led_trigger_set_default(x) do {} while (0)
+#define led_trigger_set(x, y) do {} while (0)
+#define led_trigger_remove(x) do {} while (0)
+#define led_get_trigger_data(x) (NULL)
+
 /* Trigger has no members */
 struct led_trigger {};
 
-- 
2.1.0

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

* [PATCH v2] leds: fix redundant trigger API #ifdef
  2015-04-09 15:25 [PATCH] leds: fix redundant trigger API #ifdef Valentin Rothberg
@ 2015-04-09 15:37 ` Valentin Rothberg
  2015-04-09 17:34   ` Bryan Wu
  0 siblings, 1 reply; 3+ messages in thread
From: Valentin Rothberg @ 2015-04-09 15:37 UTC (permalink / raw)
  To: j.anaszewski, cooloney, rpurdie, linux-leds, linux-kernel,
	pebolle, rupran, stefan.hengelein
  Cc: Valentin Rothberg

Commit 5a15d172057c ("leds: unify the location of led-trigger API")
moved the leds trigger API to led.h.  Moving the function definitions
caused a logical problem regarding the visibility of #idef blocks.  As
listed in the code snippet below, the inner #else block will never see a
compiler since CONFIG_LEDS_TRIGGERS is always true for the second #ifdef.

 #ifdef CONFIG_LEDS_TRIGGERS
 [...]
 #ifdef CONFIG_LEDS_TRIGGERS
 [...]
 #else
 #define led_trigger_set_default(x) do {} while (0)
 #define led_trigger_set(x, y) do {} while (0)
 #define led_trigger_remove(x) do {} while (0)
 #define led_get_trigger_data(x) (NULL)
 #endif
 #else
 [...]
 #endif

This patch removes the second, redundant #ifdef and moves the code of
the #else branch to its proper place.

Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
---
I found this issue with undertaker-checkpatch from the Undertaker
toolsuite.  See undertaker.cs.fau.de for more information.

v2:  Add the code snippet example.  It has been removed by Git before.
---
 include/linux/leds.h | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/linux/leds.h b/include/linux/leds.h
index 057970818961..96a669f93f69 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -223,7 +223,6 @@ struct led_trigger {
 	struct list_head  next_trig;
 };
 
-#ifdef CONFIG_LEDS_TRIGGERS
 void led_trigger_set_default(struct led_classdev *led_cdev);
 void led_trigger_set(struct led_classdev *led_cdev,
 			struct led_trigger *trigger);
@@ -234,13 +233,6 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
 	return led_cdev->trigger_data;
 }
 
-#else
-#define led_trigger_set_default(x) do {} while (0)
-#define led_trigger_set(x, y) do {} while (0)
-#define led_trigger_remove(x) do {} while (0)
-#define led_get_trigger_data(x) (NULL)
-#endif
-
 ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
 			const char *buf, size_t count);
 ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
@@ -282,6 +274,11 @@ extern void led_trigger_rename_static(const char *name,
 
 #else
 
+#define led_trigger_set_default(x) do {} while (0)
+#define led_trigger_set(x, y) do {} while (0)
+#define led_trigger_remove(x) do {} while (0)
+#define led_get_trigger_data(x) (NULL)
+
 /* Trigger has no members */
 struct led_trigger {};
 
-- 
2.1.0

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

* Re: [PATCH v2] leds: fix redundant trigger API #ifdef
  2015-04-09 15:37 ` [PATCH v2] " Valentin Rothberg
@ 2015-04-09 17:34   ` Bryan Wu
  0 siblings, 0 replies; 3+ messages in thread
From: Bryan Wu @ 2015-04-09 17:34 UTC (permalink / raw)
  To: Valentin Rothberg
  Cc: Jacek Anaszewski, rpurdie, Linux LED Subsystem, lkml, pebolle,
	rupran, stefan.hengelein

On Thu, Apr 9, 2015 at 8:37 AM, Valentin Rothberg
<valentinrothberg@gmail.com> wrote:
> Commit 5a15d172057c ("leds: unify the location of led-trigger API")
> moved the leds trigger API to led.h.  Moving the function definitions
> caused a logical problem regarding the visibility of #idef blocks.  As
> listed in the code snippet below, the inner #else block will never see a
> compiler since CONFIG_LEDS_TRIGGERS is always true for the second #ifdef.
>
>  #ifdef CONFIG_LEDS_TRIGGERS
>  [...]
>  #ifdef CONFIG_LEDS_TRIGGERS
>  [...]
>  #else
>  #define led_trigger_set_default(x) do {} while (0)
>  #define led_trigger_set(x, y) do {} while (0)
>  #define led_trigger_remove(x) do {} while (0)
>  #define led_get_trigger_data(x) (NULL)
>  #endif
>  #else
>  [...]
>  #endif
>
> This patch removes the second, redundant #ifdef and moves the code of
> the #else branch to its proper place.
>

Thanks for patching this. Jacek got a fix then.
-Bryan

> Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
> ---
> I found this issue with undertaker-checkpatch from the Undertaker
> toolsuite.  See undertaker.cs.fau.de for more information.
>
> v2:  Add the code snippet example.  It has been removed by Git before.
> ---
>  include/linux/leds.h | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/leds.h b/include/linux/leds.h
> index 057970818961..96a669f93f69 100644
> --- a/include/linux/leds.h
> +++ b/include/linux/leds.h
> @@ -223,7 +223,6 @@ struct led_trigger {
>         struct list_head  next_trig;
>  };
>
> -#ifdef CONFIG_LEDS_TRIGGERS
>  void led_trigger_set_default(struct led_classdev *led_cdev);
>  void led_trigger_set(struct led_classdev *led_cdev,
>                         struct led_trigger *trigger);
> @@ -234,13 +233,6 @@ static inline void *led_get_trigger_data(struct led_classdev *led_cdev)
>         return led_cdev->trigger_data;
>  }
>
> -#else
> -#define led_trigger_set_default(x) do {} while (0)
> -#define led_trigger_set(x, y) do {} while (0)
> -#define led_trigger_remove(x) do {} while (0)
> -#define led_get_trigger_data(x) (NULL)
> -#endif
> -
>  ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
>                         const char *buf, size_t count);
>  ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
> @@ -282,6 +274,11 @@ extern void led_trigger_rename_static(const char *name,
>
>  #else
>
> +#define led_trigger_set_default(x) do {} while (0)
> +#define led_trigger_set(x, y) do {} while (0)
> +#define led_trigger_remove(x) do {} while (0)
> +#define led_get_trigger_data(x) (NULL)
> +
>  /* Trigger has no members */
>  struct led_trigger {};
>
> --
> 2.1.0
>

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

end of thread, other threads:[~2015-04-09 17:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-09 15:25 [PATCH] leds: fix redundant trigger API #ifdef Valentin Rothberg
2015-04-09 15:37 ` [PATCH v2] " Valentin Rothberg
2015-04-09 17:34   ` Bryan Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.