[PATCH v9 04/11] iio: accel: adxl345: simplify interrupt mapping

Lothar Rubusch posted 11 patches 6 months, 1 week ago
There is a newer version of this series
[PATCH v9 04/11] iio: accel: adxl345: simplify interrupt mapping
Posted by Lothar Rubusch 6 months, 1 week ago
Replace mapping all sensor interrupts to the corresponding interrupt
line using regmap_assign_bits() since it takes a boolean directly.
Further prefer the units.h identifier to cover the full register when bits
are set.

This is a refactoring change and should not impact functionality.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
---
 drivers/iio/accel/adxl345_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/accel/adxl345_core.c b/drivers/iio/accel/adxl345_core.c
index cae9e37e216f..18c625d323ba 100644
--- a/drivers/iio/accel/adxl345_core.c
+++ b/drivers/iio/accel/adxl345_core.c
@@ -1216,9 +1216,8 @@ int adxl345_core_probe(struct device *dev, struct regmap *regmap,
 		 * interrupts to the INT1 pin, whereas bits set to 1 send their respective
 		 * interrupts to the INT2 pin. The intio shall convert this accordingly.
 		 */
-		regval = intio ? 0xff : 0;
-
-		ret = regmap_write(st->regmap, ADXL345_REG_INT_MAP, regval);
+		ret = regmap_assign_bits(st->regmap, ADXL345_REG_INT_MAP,
+					 U8_MAX, intio);
 		if (ret)
 			return ret;
 
-- 
2.39.5
Re: [PATCH v9 04/11] iio: accel: adxl345: simplify interrupt mapping
Posted by Andy Shevchenko 6 months ago
On Tue, Jun 10, 2025 at 09:59:26PM +0000, Lothar Rubusch wrote:
> Replace mapping all sensor interrupts to the corresponding interrupt
> line using regmap_assign_bits() since it takes a boolean directly.
> Further prefer the units.h identifier to cover the full register when bits
> are set.

...

> -		regval = intio ? 0xff : 0;
> -
> -		ret = regmap_write(st->regmap, ADXL345_REG_INT_MAP, regval);
> +		ret = regmap_assign_bits(st->regmap, ADXL345_REG_INT_MAP,
> +					 U8_MAX, intio);

I'm wondering if GENMASK() is actually better to point out to the amount and
exact bits in the bitfield? After all this is HW register we program, right?

>  		if (ret)
>  			return ret;

-- 
With Best Regards,
Andy Shevchenko