From 41bf123847ca110e334f92dc827ffd2e94d87d5d Mon Sep 17 00:00:00 2001 From: Namyoon Woo Date: Tue, 4 Jun 2019 19:05:25 -0700 Subject: cr50: optimize set_ec_on() by prioritizing the case EC is on This patch prioritize the case that EC is in ON over other cases like INIT, INIT_DEBOUNCING or DEBOUNCING in set_ec_on(). set_ec_on() is called every second to monitor EC status when EC_UART signal is detected. set_ec_on() shall finish quickly in most of time when EC is ON. BUG=None BRANCH=None TEST=ran flash_ec and uart_stress_tester.sh on Bob. Signed-off-by: Namyoon Woo Change-Id: I6a53ca86ccb4f65c7450bfbfda78cb5cf5b6409d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1644598 Tested-by: Namyoon Woo Reviewed-by: Vadim Bendebury Commit-Queue: Namyoon Woo --- board/cr50/ec_state.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'board') diff --git a/board/cr50/ec_state.c b/board/cr50/ec_state.c index c9ed7eeb31..c42518f709 100644 --- a/board/cr50/ec_state.c +++ b/board/cr50/ec_state.c @@ -61,6 +61,16 @@ static void set_state(enum device_state new_state) */ static void set_ec_on(void) { + /* If we're already on, done */ + if (state == DEVICE_STATE_ON) + return; + + /* If we were debouncing ON->OFF, cancel it because we're still on */ + if (state == DEVICE_STATE_DEBOUNCING) { + set_state(DEVICE_STATE_ON); + return; + } + if (state == DEVICE_STATE_INIT || state == DEVICE_STATE_INIT_DEBOUNCING) { /* @@ -75,14 +85,6 @@ static void set_ec_on(void) return; } - /* If we were debouncing ON->OFF, cancel it because we're still on */ - if (state == DEVICE_STATE_DEBOUNCING) - set_state(DEVICE_STATE_ON); - - /* If we're already on, done */ - if (state == DEVICE_STATE_ON) - return; - /* We were previously off */ CPRINTS("EC on"); set_state(DEVICE_STATE_ON); -- cgit v1.2.1