summaryrefslogtreecommitdiff
path: root/chip/stm32
diff options
context:
space:
mode:
authorZhuohao Lee <zhuohao@chromium.org>2018-08-06 14:18:55 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-08-07 01:50:39 -0700
commit7c47fcc96889866ee143e01b56f78b3732657a7f (patch)
tree7e2455270ced9d72e447aabfa6806df1e0b14565 /chip/stm32
parentb3ff32c510e8842d9ee043d9c9b09a1efb60f9db (diff)
downloadchrome-ec-7c47fcc96889866ee143e01b56f78b3732657a7f.tar.gz
i2c: add i2c_lock before and after calling i2c_xfer
According to the include/i2c.h, we need to call i2c_lock before and after calling i2c_xfer. This patch adds the lock to protect the i2c data transmission. BUG=none BRANCH=master TEST=make buildall -j Change-Id: If125333902105c35ca332c154bbb8012c363d1bf Signed-off-by: Zhuohao Lee <zhuohao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1163543 Reviewed-by: Nick Sanders <nsanders@chromium.org>
Diffstat (limited to 'chip/stm32')
-rw-r--r--chip/stm32/usb_power.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/chip/stm32/usb_power.c b/chip/stm32/usb_power.c
index bf9e824f84..cc4f723322 100644
--- a/chip/stm32/usb_power.c
+++ b/chip/stm32/usb_power.c
@@ -411,8 +411,11 @@ uint16_t ina2xx_readagain(uint8_t port, uint8_t addr)
int res;
uint16_t val;
+ i2c_lock(port, 1);
res = i2c_xfer(port, addr, NULL, 0, (uint8_t *)&val, sizeof(uint16_t),
I2C_XFER_SINGLE);
+ i2c_lock(port, 0);
+
if (res) {
CPRINTS("INA2XX I2C readagain failed p:%d a:%02x",
(int)port, (int)addr);