From cd89b400a22702ab327b6fd261cd7d5c53b421e3 Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Tue, 15 May 2018 10:50:53 +0200 Subject: [PATCH] charge_manager: handle gracefully dedicated port charge_manager_fill_power_info can be called to fill the power info of the dedicated port. This function might call charge_manager_get_source_current with the dedicated port, we don't want to use assert in that case, but just fail gracefully by returning 0. BRANCH=None BUG=chromium:841944 TEST=Check that the function returns 0 for dedicated and not 0 for USB. Change-Id: I357c056647e01bdb0e77a08a6c6b492aa3dbb503 Signed-off-by: Fabien Parent Reviewed-on: https://chromium-review.googlesource.com/1059248 Reviewed-by: Daisuke Nojiri --- common/charge_manager.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/charge_manager.c b/common/charge_manager.c index 2c30ca7bc8..c1fa917665 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -217,7 +217,8 @@ static int charge_manager_is_seeded(void) */ static int charge_manager_get_source_current(int port) { - ASSERT(is_pd_port(port)); + if (!is_pd_port(port)) + return 0; switch (source_port_last_rp[port]) { case TYPEC_RP_3A0: