diff options
author | Aseda Aboagye <aaboagye@google.com> | 2018-09-23 16:53:27 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-11-13 03:32:52 -0800 |
commit | a2742989efcbcd92cc4d56e5a833c687a189725b (patch) | |
tree | fa9d59436d6551045f84c48d6a13be84d69b3959 | |
parent | 2e5d1744a9b4bef51f5d5333a7bd5b77b68f1925 (diff) | |
download | chrome-ec-a2742989efcbcd92cc4d56e5a833c687a189725b.tar.gz |
led_pwm: Turn off inactive charge port LEDs.
When a board is configured to only show the charging led on the active
charge port, we should ensure that the other ports' charging LED is
turned off. This commit fixes a bug where both ports LEDs could remain
lit even though there's only one active charge port at a time.
BUG=b:116020780
BRANCH=firmware-nocturne-10984.B
TEST=Plug in a low power charger on one port, plug in a higher powered
charger on a different port, verify that the charging LED switches to
the higher powered port and the other LED is off.
Change-Id: I48992e36f49346c920170c5bf90761776824af48
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1239547
Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
(cherry picked from commit 8d3e6bdaaca89ffda59ddb1fa01a6df921716bc7)
Reviewed-on: https://chromium-review.googlesource.com/1333147
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r-- | common/led_pwm.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/common/led_pwm.c b/common/led_pwm.c index 90c22c5202..879b9f7bfc 100644 --- a/common/led_pwm.c +++ b/common/led_pwm.c @@ -33,23 +33,23 @@ static uint8_t led_is_pulsing; -static int ignore_set_led_color(enum pwm_led_id id, int color) +static int get_led_id_color(enum pwm_led_id id, int color) { #ifdef CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY int active_chg_port = charge_manager_get_active_charge_port(); - /* We should always be able to turn off a LED.*/ + /* We should always be able to turn off a LED. */ if (color == -1) - return 0; + return -1; if (led_is_pulsing) - return 0; + return color; + /* The inactive charge port LEDs should be off. */ if ((int)id != active_chg_port) - return 1; + return -1; #endif /* CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY */ - - return 0; + return color; } void set_pwm_led_color(enum pwm_led_id id, int color) @@ -82,13 +82,11 @@ static void set_led_color(int color) */ if ((led_auto_control_is_enabled(EC_LED_ID_POWER_LED)) || (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED))) - if (!ignore_set_led_color(PWM_LED0, color)) - set_pwm_led_color(PWM_LED0, color); + set_pwm_led_color(PWM_LED0, get_led_id_color(PWM_LED0, color)); #if CONFIG_LED_PWM_COUNT >= 2 if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) - if (!ignore_set_led_color(PWM_LED1, color)) - set_pwm_led_color(PWM_LED1, color); + set_pwm_led_color(PWM_LED1, get_led_id_color(PWM_LED1, color)); #endif /* CONFIG_LED_PWM_COUNT >= 2 */ } |