summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-01-17 17:12:43 +1100
committerCommit Bot <commit-bot@chromium.org>2022-01-18 04:45:51 +0000
commit8670201004ff5f6c704373f0b062879e2c72b6e1 (patch)
treeb2130db69689d9b55e0de8887a8238bfef600ff9 /common
parent369ebd9394715b78189148f9a40cdd52a6ff97c6 (diff)
downloadchrome-ec-8670201004ff5f6c704373f0b062879e2c72b6e1.tar.gz
usbc: Exit the charging task if the port does not exist.
Exit the charging task if the port does not exist. Some boards were using task_disable_task to disable the task, but with Zephyr this function is not implemented, so check in the task itself. BUG=b:214880218 TEST=make buildall BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I22ef7eea58560d17a7ead4b984e7f33801e0ebb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3392104 Reviewed-by: Peter Marheine <pmarheine@chromium.org> Commit-Queue: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_charger.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/common/usb_charger.c b/common/usb_charger.c
index b8e8038811..bba88f4f11 100644
--- a/common/usb_charger.c
+++ b/common/usb_charger.c
@@ -131,6 +131,13 @@ void usb_charger_task(void *u)
{
int port = TASK_ID_TO_USB_CHG_PORT(task_get_current());
+ /*
+ * The actual number of ports may be less than the maximum
+ * configured, so only run the task if the port exists.
+ */
+ if (port >= board_get_usb_pd_port_count())
+ return;
+
ASSERT(bc12_ports[port].drv->usb_charger_task);
bc12_ports[port].drv->usb_charger_task(port);
}