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 <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/66314
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vic Yang
2013-08-20 14:16:53 +08:00
committed by ChromeBot
parent 5d1eeefdbc
commit 0e024b2bae

View File

@@ -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;
}