diff options
author | Diana Z <dzigterman@chromium.org> | 2021-04-16 15:47:19 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-04-22 22:30:42 +0000 |
commit | 0f3b5955efc635ff6f387485733f66e7e1971918 (patch) | |
tree | 113da9c190051dbafe44b73a8063385dd92e3d4b | |
parent | 6ada099de9c62d6cc290be071fee4529ed86566c (diff) | |
download | chrome-ec-0f3b5955efc635ff6f387485733f66e7e1971918.tar.gz |
LED On/Off: Allow compiling without CONFIG_CHARGER
The header for charge_get_percent() will only define this function if
CONFIG_CHARGER is present. Make a declaration for complilation to use,
and then allow most of the led_get_state() function to be optimized out
with IS_ENABLED().
BRANCH=None
BUG=b:185508707
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I3d94f290ac5b9ec82b46b9c0a6fc668b2e8dd91c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2832693
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/led_onoff_states.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/common/led_onoff_states.c b/common/led_onoff_states.c index 1731953d8c..eea527373d 100644 --- a/common/led_onoff_states.c +++ b/common/led_onoff_states.c @@ -29,11 +29,19 @@ __overridable void led_set_color_battery(enum ec_led_colors color) { } +#ifndef CONFIG_CHARGER +/* Include for the sake of compilation */ +int charge_get_percent(void); +#endif + static enum led_states led_get_state(void) { int charge_lvl; enum led_states new_state = LED_NUM_STATES; + if (!IS_ENABLED(CONFIG_CHARGER)) + return new_state; + switch (charge_get_state()) { case PWR_STATE_CHARGE: /* Get percent charge */ |