Skip to contentSkip to conversation

iio: adc: ad7192: fix channel select

PATCH Superseded Markus Burri 2 participants 2 messages Jan 24, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iio: adc: ad7192: fix channel select

Channel configuration doesn't work as expected.
For FIELD_PREP the bit mask is needed and not the bit number.

---
 drivers/iio/adc/ad7192.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7192.c +1 -1
index 1c87db0e0460..c4effe8429c8 100644
@@ -1082,7 +1082,7 @@ static int ad7192_update_scan_mode(struct iio_dev *indio_dev, const unsigned lon
 
 	conf &= ~AD7192_CONF_CHAN_MASK;
 	for_each_set_bit(i, scan_mask, 8)
-		conf |= FIELD_PREP(AD7192_CONF_CHAN_MASK, i);
+		conf |= FIELD_PREP(AD7192_CONF_CHAN_MASK, BIT(i));
 
 	ret = ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, conf);
 	if (ret < 0)

base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04

Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Markus Burri

Channel configuration doesn't work as expected.
For FIELD_PREP the bit mask is needed and not the bit number.

---

LGTM. Just missing a fixes tag. With that:

Quoted 19 lines

 drivers/iio/adc/ad7192.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad7192.c +0 -0
index 1c87db0e0460..c4effe8429c8 100644
@@ -1082,7 +1082,7 @@ static int ad7192_update_scan_mode(struct iio_dev
 *indio_dev, const unsigned lon


  conf &= ~AD7192_CONF_CHAN_MASK;
  for_each_set_bit(i, scan_mask, 8)

drivers/iio/adc/ad7192.c +1 -1
-		conf |= FIELD_PREP(AD7192_CONF_CHAN_MASK, i);
+		conf |= FIELD_PREP(AD7192_CONF_CHAN_MASK, BIT(i));


  ret = ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, conf); if (ret < 0)

base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04