summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2022-04-14 14:36:16 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-04-14 18:25:31 +0000
commit265691a2fe290e0fa54ecccba151a5c63dd73e47 (patch)
treedac5c92eef7e97fd1a5632389b60733036793707
parent9f530cd97ef5a64e4712128051a17d5de8b43e53 (diff)
downloadchrome-ec-265691a2fe290e0fa54ecccba151a5c63dd73e47.tar.gz
usbc: fix initializing pd timers
In the pd_timer_init function, initialize timers related to the port passed as an argument, not timers for all ports. The bug could impact already started timers of other ports than the one being initialized. BUG=b:208435177 TEST=zmake testall & make buildall & run faft_pd and make sure there is no regression BRANCH=none Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: Ide07cf2ac392b9ce679a70e8cbe9ce038d294073 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3586427 Reviewed-by: Boris Mittelberg <bmbm@google.com> Tested-by: Boris Mittelberg <bmbm@google.com> Reviewed-by: caveh jalali <caveh@chromium.org> Commit-Queue: caveh jalali <caveh@chromium.org>
-rw-r--r--common/usbc/usb_pd_timer.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/common/usbc/usb_pd_timer.c b/common/usbc/usb_pd_timer.c
index d215590371..a1859ac9e9 100644
--- a/common/usbc/usb_pd_timer.c
+++ b/common/usbc/usb_pd_timer.c
@@ -131,12 +131,11 @@ void pd_timer_init(int port)
count[port] = 0;
/*
- * timer_active and timer_disabled are atomic_t global arrays.
- * Set them to the initial state.
+ * Set timers to init state for "port".
*/
- for (int i = 0; i < ARRAY_SIZE(timer_active); i++) {
- *(timer_active + i) = 0;
- *(timer_disabled + i) = ~0;
+ for (int bit = 0; bit < PD_TIMER_COUNT; bit++) {
+ PD_CLR_ACTIVE(port, bit);
+ PD_SET_DISABLED(port, bit);
}
}