poppy: Return early from base_detect_change if status is unchanged

If current status is the same as requested state, then return early
from base_detect_change without taking any action.

BUG=b:64460667
BRANCH=None
TEST=make -j buildall

Change-Id: I3c403739a2e5c43f31fe77b5633927cf49b974eb
Signed-off-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/625243
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
This commit is contained in:
Furquan Shaikh
2017-08-21 17:29:41 -07:00
committed by chrome-bot
parent af6024cc08
commit 1fb39a4247

View File

@@ -198,6 +198,9 @@ static void base_detect_change(enum base_status status)
{
int connected = (status == BASE_CONNECTED);
if (current_base_status == status)
return;
CPRINTS("Base %sconnected", connected ? "" : "not ");
gpio_set_level(GPIO_PP3300_DX_BASE, connected);
host_set_single_event(EC_HOST_EVENT_MODE_CHANGE);
@@ -260,8 +263,7 @@ static void base_detect_deferred(void)
* other ADC values that do not clearly indicate base
* presence or absence.
*/
if (current_base_status != BASE_DISCONNECTED)
base_detect_change(BASE_DISCONNECTED);
base_detect_change(BASE_DISCONNECTED);
}
}