Skip to contentSkip to conversation

iio: adc: ad7124: Fix enabling of internal reference

PATCH In review Mircea Caprioru 2 participants 2 messages Nov 18, 2019 – Nov 23, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 iio: adc: ad7124: Fix enabling of internal reference

When the internal reference was selected by a channel it was not enabled. This patch fixes that and enables it.

Fixes b3af341bbd96 ("iio: adc: Add ad7124 support")

---

Changelog v3:
- mark this as a fix in the patch title

 drivers/iio/adc/ad7124.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7124.c +6 -1
index edc6f1cc90b2..3f03abf100b5 100644
@@ -39,6 +39,8 @@
 #define AD7124_STATUS_POR_FLAG_MSK	BIT(4)
 
 /* AD7124_ADC_CONTROL */
+#define AD7124_ADC_CTRL_REF_EN_MSK	BIT(8)
+#define AD7124_ADC_CTRL_REF_EN(x)	FIELD_PREP(AD7124_ADC_CTRL_REF_EN_MSK, x)
 #define AD7124_ADC_CTRL_PWR_MSK	GENMASK(7, 6)
 #define AD7124_ADC_CTRL_PWR(x)		FIELD_PREP(AD7124_ADC_CTRL_PWR_MSK, x)
 #define AD7124_ADC_CTRL_MODE_MSK	GENMASK(5, 2)
@@ -424,7 +426,10 @@ static int ad7124_init_channel_vref(struct ad7124_state *st,
 		break;
 	case AD7124_INT_REF:
 		st->channel_config[channel_number].vref_mv = 2500;
-		break;
+		st->adc_control &= ~AD7124_ADC_CTRL_REF_EN_MSK;
+		st->adc_control |= AD7124_ADC_CTRL_REF_EN(1);
+		return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL,
+				      2, st->adc_control);
 	default:
 		dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel);
 		return -EINVAL;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 2 lines · On Mon, 18 Nov 2019 13:19:48 +0200 Mircea Caprioru…

When the internal reference was selected by a channel it was not enabled. This patch fixes that and enables it.

Ah well. I took v2 and it's marked for stable so doubt it matters that there is no Fix in the title.

Issues like this happen to us all from time to time, please send a quick reply to the earlier version if you are sending a new one.

I'm a bit random in how I apply patches (particularly when I only have a few minutes around family stuff) so assume that a series with no replies is fine to apply if I'm happy with it!

Thanks,

Jonathan

Quoted 36 lines
Fixes b3af341bbd96 ("iio: adc: Add ad7124 support")

---

Changelog v3:
- mark this as a fix in the patch title

 drivers/iio/adc/ad7124.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/iio/adc/ad7124.c +6 -1
index edc6f1cc90b2..3f03abf100b5 100644
@@ -39,6 +39,8 @@
 #define AD7124_STATUS_POR_FLAG_MSK	BIT(4)
 
 /* AD7124_ADC_CONTROL */
+#define AD7124_ADC_CTRL_REF_EN_MSK	BIT(8)
+#define AD7124_ADC_CTRL_REF_EN(x)	FIELD_PREP(AD7124_ADC_CTRL_REF_EN_MSK, x)
 #define AD7124_ADC_CTRL_PWR_MSK	GENMASK(7, 6)
 #define AD7124_ADC_CTRL_PWR(x)		FIELD_PREP(AD7124_ADC_CTRL_PWR_MSK, x)
 #define AD7124_ADC_CTRL_MODE_MSK	GENMASK(5, 2)
@@ -424,7 +426,10 @@ static int ad7124_init_channel_vref(struct ad7124_state *st,
 		break;
 	case AD7124_INT_REF:
 		st->channel_config[channel_number].vref_mv = 2500;
-		break;
+		st->adc_control &= ~AD7124_ADC_CTRL_REF_EN_MSK;
+		st->adc_control |= AD7124_ADC_CTRL_REF_EN(1);
+		return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL,
+				      2, st->adc_control);
 	default:
 		dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel);
 		return -EINVAL;