summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@chromium.org>2019-12-09 09:19:59 -0700
committerCommit Bot <commit-bot@chromium.org>2019-12-10 19:18:15 +0000
commitc2e089ac90c46c14d4827b40e3eb9b78f46ae518 (patch)
treeb3a7b992aa276eeb5443f259126f41fc80753314
parent7199e402ed041c9f856fa1100b7a904af345a763 (diff)
downloadchrome-ec-c2e089ac90c46c14d4827b40e3eb9b78f46ae518.tar.gz
pi3usb9201: use i2c field update common function
BUG=none BRANCH=none TEST=make buildall -j Change-Id: I26eeba971cea3f470c7e54fa325e361a2a26b313 Signed-off-by: Denis Brockus <dbrockus@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1958413 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--driver/bc12/pi3usb9201.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index 7f11e1da8a..0dee6a01d5 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -67,26 +67,12 @@ static inline int raw_read8(int port, int offset, int *value)
offset, value);
}
-static inline int raw_write8(int port, int offset, int value)
-{
- return i2c_write8(pi3usb9201_bc12_chips[port].i2c_port,
- pi3usb9201_bc12_chips[port].i2c_addr_flags,
- offset, value);
-}
-
static int pi3usb9201_raw(int port, int reg, int mask, int val)
{
- int rv;
- int reg_val;
-
- rv = raw_read8(port, reg, &reg_val);
- if (rv)
- return rv;
-
- reg_val &= ~mask;
- reg_val |= val;
-
- return raw_write8(port, reg, reg_val);
+ /* Clear mask and then set val in i2c reg value */
+ return i2c_field_update8(pi3usb9201_bc12_chips[port].i2c_port,
+ pi3usb9201_bc12_chips[port].i2c_addr_flags,
+ reg, mask, val);
}
static int pi3usb9201_interrupt_mask(int port, int enable)