From 0e024b2bae085f12ec4df33000799339aef38809 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Tue, 20 Aug 2013 14:16:53 +0800 Subject: [PATCH] Fix a bug that I2C error may cause incorrect LED color If there is an I2C transaction error while setting LED color, the three LED color channels might be in an inconsistent state. In this case, we should explicitly set the LED state to INVALID so as to force the next LED color update. BUG=None TEST=Build success BRANCH=Spring Change-Id: I1353044ef782481872d692f15748413ef539cb27 Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/66314 Reviewed-by: Vincent Palatin --- common/led_lp5562.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/led_lp5562.c b/common/led_lp5562.c index a35332be9b..3d6e316426 100644 --- a/common/led_lp5562.c +++ b/common/led_lp5562.c @@ -35,6 +35,9 @@ enum led_state_t { /* Not an actual state */ LED_STATE_OFF, + + /* Used to force next LED color update */ + LED_STATE_INVALID, }; static enum led_state_t last_state = LED_STATE_OFF; @@ -57,12 +60,14 @@ static int set_led_color(enum led_state_t state) case LED_STATE_SOLID_YELLOW: rv = lp5562_set_color(LED_COLOR_YELLOW); break; - case LED_STATE_OFF: + default: break; } if (rv == EC_SUCCESS) last_state = state; + else + last_state = LED_STATE_INVALID; return rv; }