[U-Boot] [PATCH v2 13/22] GPIO/LED: make more robust, if STATUS_LED isn't selected

Benjamin Tietz uboot at dresden.micronet24.de
Mon Jun 20 20:27:06 CEST 2016


From: Benjamin Tietz <benjamin at micronet24.de>

If STATUS_LED isn't selected, neither led_id_t is selected, nor STATUS_LED_ON.
The following will set led_id_t to a reasonable default and define STATUS_LED_ON for that case.
---
 drivers/misc/gpio_led.c   |    4 ++++
 drivers/misc/status_led.c |    2 ++
 include/status_led.h      |    4 ++++
 3 files changed, 10 insertions(+)

diff --git a/drivers/misc/gpio_led.c b/drivers/misc/gpio_led.c
index 164c30d..9c0ea13 100644
--- a/drivers/misc/gpio_led.c
+++ b/drivers/misc/gpio_led.c
@@ -13,6 +13,10 @@
 #define CONFIG_GPIO_LED_INVERTED_TABLE {}
 #endif
 
+#ifndef STATUS_LED_ON
+#define STATUS_LED_ON 2
+#endif
+
 static led_id_t gpio_led_inv[] = CONFIG_GPIO_LED_INVERTED_TABLE;
 
 static int gpio_led_gpio_value(led_id_t mask, int state)
diff --git a/drivers/misc/status_led.c b/drivers/misc/status_led.c
index 31e8831..052ecf0 100644
--- a/drivers/misc/status_led.c
+++ b/drivers/misc/status_led.c
@@ -27,11 +27,13 @@ typedef struct {
 } led_dev_t;
 
 led_dev_t led_dev[] = {
+#if defined(STATUS_LED_BIT)
     {	STATUS_LED_BIT,
 	STATUS_LED_STATE,
 	STATUS_LED_PERIOD,
 	0,
     },
+#endif
 #if defined(STATUS_LED_BIT1)
     {	STATUS_LED_BIT1,
 	STATUS_LED_STATE1,
diff --git a/include/status_led.h b/include/status_led.h
index 396ea88..c3795a7 100644
--- a/include/status_led.h
+++ b/include/status_led.h
@@ -103,6 +103,10 @@ void __led_blink(led_id_t mask, int freq);
 # include <asm/status_led.h>
 #endif
 
+#else
+
+typedef unsigned long led_id_t;
+
 #endif	/* CONFIG_STATUS_LED	*/
 
 /*



More information about the U-Boot mailing list