karo: tx6ul: make show_activity() bail out on GPIO error
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 18 Feb 2016 16:58:57 +0000 (17:58 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Thu, 18 Feb 2016 16:58:57 +0000 (17:58 +0100)
board/karo/tx6/tx6ul.c

index da40e53..ce9450f 100644 (file)
@@ -675,6 +675,7 @@ enum {
        LED_STATE_INIT = -1,
        LED_STATE_OFF,
        LED_STATE_ON,
+       LED_STATE_ERR,
 };
 
 static inline int calc_blink_rate(void)
@@ -692,13 +693,24 @@ void show_activity(int arg)
        static int led_state = LED_STATE_INIT;
        static int blink_rate;
        static ulong last;
+       int ret;
+
+       switch (led_state) {
+       case LED_STATE_ERR:
+               return;
 
-       if (led_state == LED_STATE_INIT) {
+       case LED_STATE_INIT:
                last = get_timer(0);
-               gpio_set_value(TX6UL_LED_GPIO, 1);
-               led_state = LED_STATE_ON;
+               ret = gpio_set_value(TX6UL_LED_GPIO, 1);
+               if (ret)
+                       led_state = LED_STATE_ERR;
+               else
+                       led_state = LED_STATE_ON;
                blink_rate = calc_blink_rate();
-       } else {
+               break;
+
+       case LED_STATE_ON:
+       case LED_STATE_OFF:
                if (get_timer(last) > blink_rate) {
                        blink_rate = calc_blink_rate();
                        last = get_timer_masked();
@@ -709,6 +721,7 @@ void show_activity(int arg)
                        }
                        led_state = 1 - led_state;
                }
+               break;
        }
 }