diff options
author | Jonathan Brandmeyer <jbrandmeyer@chromium.org> | 2018-08-07 16:04:23 -0600 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-09 22:04:40 -0700 |
commit | 740427a24398b3fd66904e913b742f751371d09c (patch) | |
tree | 1efe5fd4db314fbbb44bdd3a5bc726c4ee818ad0 /driver/stm_mems_common.c | |
parent | aba9f5e09f7fb1f18a297fb5552404706a642351 (diff) | |
download | chrome-ec-740427a24398b3fd66904e913b742f751371d09c.tar.gz |
drivers: Refactor to use high-level i2c APIs
Using the high-level APIs for block transfers eliminates some code
duplication and error-prone manual locking sequences.
- common/cbi: Block transfers
- driver/accel_bma2x2: Block transfers
- driver/accel_kionix: Block transfers
- driver/accelgyro_bmi160: Block transfers
- driver/accelgyro_lsm6ds0: Block transfers
- driver/baro_bmp280: Block and byte transfers
- driver/charger/rt946x: Block transfers
- driver/gyro_l3gd20h: Block transfers
- driver/stm_mems_common: Block transfers
- driver/tcpm: Block transfers
TEST=buildall; motionsense and PD testing on Grunt convertible which
exercises the bma160, kionix and tcpcm drivers.
BRANCH=none
BUG=chromium:871851
Change-Id: I1732253a244c3343459265ce1e1e54488cee65b8
Signed-off-by: Jonathan Brandmeyer <jbrandmeyer@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1167958
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'driver/stm_mems_common.c')
-rw-r--r-- | driver/stm_mems_common.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/driver/stm_mems_common.c b/driver/stm_mems_common.c index b3fe4d94fb..c22f0d42e5 100644 --- a/driver/stm_mems_common.c +++ b/driver/stm_mems_common.c @@ -14,15 +14,8 @@ int st_raw_read_n(const int port, const int addr, const uint8_t reg, uint8_t *data_ptr, const int len) { - int rv = -EC_ERROR_PARAM1; - uint8_t reg_a = reg | 0x80; - /* TODO: Implement SPI interface support */ - i2c_lock(port, 1); - rv = i2c_xfer(port, addr, ®_a, 1, data_ptr, len, I2C_XFER_SINGLE); - i2c_lock(port, 0); - - return rv; + return i2c_read_block(port, addr, reg | 0x80, data_ptr, len); } /** @@ -31,14 +24,8 @@ int st_raw_read_n(const int port, const int addr, const uint8_t reg, int st_raw_read_n_noinc(const int port, const int addr, const uint8_t reg, uint8_t *data_ptr, const int len) { - int rv = -EC_ERROR_PARAM1; - /* TODO: Implement SPI interface support */ - i2c_lock(port, 1); - rv = i2c_xfer(port, addr, ®, 1, data_ptr, len, I2C_XFER_SINGLE); - i2c_lock(port, 0); - - return rv; + return i2c_read_block(port, addr, reg, data_ptr, len); } /** |