[PATCH v8 1/7] iio: accel: adxl345: add function to switch measuring mode

Lothar Rubusch
2024-12-25T18:13:47Z

Replace the powerup / powerdown functions by a generic function to put
the sensor in STANDBY, or MEASURE mode. When configuring the FIFO for
several features of the accelerometer, it is recommended to put
measuring in STANDBY mode.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
Please squash with a3fb9f5202c3de0ca84848a475f59a0e0584d9fc

Just introduces a cosmetic simplification to the already applied
commit, under the same title.

drivers/iio/accel/adxl345_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index b48bc838c..27d70a1f0 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -153,9 +153,8 @@ static int adxl345_write_raw_get_fmt(struct iio_dev *indio_dev,
*/
static int adxl345_set_measure_en(struct adxl345_state *st, bool en)
{
- unsigned int val = 0;
+ unsigned int val = en ? ADXL345_POWER_CTL_MEASURE : ADXL345_POWER_CTL_STANDBY;

- val = (en) ? ADXL345_POWER_CTL_MEASURE : ADXL345_POWER_CTL_STANDBY;
return regmap_write(st->regmap, ADXL345_REG_POWER_CTL, val);
}

--
2.39.5