summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2023-03-06 10:21:40 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-17 04:56:12 +0000
commit44016532fe3db3ce3445d75a0c3dcbbccc785a18 (patch)
tree0a619415a91f1ee95c3a6d8b20d237166a99b4ed /driver
parent901e3e769e6208a5fea2643720bbae88662eea29 (diff)
downloadchrome-ec-44016532fe3db3ce3445d75a0c3dcbbccc785a18.tar.gz
bma4xx: emulator and driver tests
This implements an emulator and tests for the accel_bma4xx driver using that emulator in the drivers.default test binary. One change to the driver itself is made to fix an overread during interrupt processing (which is not harmful but is slightly inefficient) and a function is marked __maybe_unused so the driver builds successfully when not using interrupts. BUG=b:256047664 TEST=twister -ciC -s drivers/drivers.default -- --test="bma4xx::*" BRANCH=none LOW_COVERAGE_REASON=Some aspects of emulator functionality are not currently exercised. Change-Id: I2765f768c1f5f3651893dfedd1c04cd15cb7fa86 Signed-off-by: Peter Marheine <pmarheine@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4310762 Reviewed-by: Eric Yilun Lin <yllin@google.com>
Diffstat (limited to 'driver')
-rw-r--r--driver/accel_bma4xx.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/driver/accel_bma4xx.c b/driver/accel_bma4xx.c
index 345916dd36..a842b42d3a 100644
--- a/driver/accel_bma4xx.c
+++ b/driver/accel_bma4xx.c
@@ -51,8 +51,8 @@ static inline int bma4_read8(const struct motion_sensor_t *s, const int reg,
return i2c_read8(s->port, s->i2c_spi_addr_flags, reg, data_ptr);
}
-static inline int bma4_read16(const struct motion_sensor_t *s, const int reg,
- int *data_ptr)
+__maybe_unused static inline int bma4_read16(const struct motion_sensor_t *s,
+ const int reg, int *data_ptr)
{
return i2c_read16(s->port, s->i2c_spi_addr_flags, reg, data_ptr);
}
@@ -639,7 +639,7 @@ static int irq_handler(struct motion_sensor_t *s, uint32_t *event)
int interrupt_status_reg, fifo_depth;
/* Read interrupt status, also clears pending IRQs */
- RETURN_ERROR(bma4_read16(s, BMA4_INT_STATUS_1, &interrupt_status_reg));
+ RETURN_ERROR(bma4_read8(s, BMA4_INT_STATUS_1, &interrupt_status_reg));
if ((interrupt_status_reg &
(BMA4_FFULL_INT | BMA4_FWM_INT | BMA4_ACC_DRDY_INT)) == 0) {
return EC_ERROR_NOT_HANDLED;