Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: accel: adxl345: simplify measure enable

Simplify the function to enable or disable measurement. Replace the
separate decision logic and call to regmap_update_bits() by a single
call to regmap_assign_bits() taking a boolean argument directly.

This is a refactoring change and should not impact functionality.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Link: https://patch.msgid.link/20250610215933.84795-4-l.rubusch@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Lothar Rubusch and committed by
Jonathan Cameron
f7f905f7 5decafde

+2 -4
-1
drivers/iio/accel/adxl345.h
··· 73 73 #define ADXL345_BW_LOW_POWER BIT(4) 74 74 #define ADXL345_BASE_RATE_NANO_HZ 97656250LL 75 75 76 - #define ADXL345_POWER_CTL_STANDBY 0x00 77 76 #define ADXL345_POWER_CTL_WAKEUP GENMASK(1, 0) 78 77 #define ADXL345_POWER_CTL_SLEEP BIT(2) 79 78 #define ADXL345_POWER_CTL_MEASURE BIT(3)
+2 -3
drivers/iio/accel/adxl345_core.c
··· 233 233 */ 234 234 static int adxl345_set_measure_en(struct adxl345_state *st, bool en) 235 235 { 236 - unsigned int val = en ? ADXL345_POWER_CTL_MEASURE : ADXL345_POWER_CTL_STANDBY; 237 - 238 - return regmap_write(st->regmap, ADXL345_REG_POWER_CTL, val); 236 + return regmap_assign_bits(st->regmap, ADXL345_REG_POWER_CTL, 237 + ADXL345_POWER_CTL_MEASURE, en); 239 238 } 240 239 241 240 /* tap */