[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <415c4c8f8301395aee2a85d071722fd6bcb488ec.1754559149.git.mazziesaccount@gmail.com>
Date: Thu, 7 Aug 2025 12:34:18 +0300
From: Matti Vaittinen <mazziesaccount@...il.com>
To: Matti Vaittinen <mazziesaccount@...il.com>,
Matti Vaittinen <matti.vaittinen@...rohmeurope.com>
Cc: Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
Andy Shevchenko <andy@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>,
Matti Vaittinen <mazziesaccount@...il.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH v2 03/10] iio: adc: ad7476: Use mV for internal reference
The ad7476 supports some ICs with an internal reference voltage. For
those ICs the reference voltage has been hard-coded as micro volts, but
the value which is later used in code needs to be milli volts. This
results the need to divide hard coded voltage by 1000 before using it.
Simplify code by changing the hard-coded voltage to millivolts and by
dropping the division.
Signed-off-by: Matti Vaittinen <mazziesaccount@...il.com>
---
Revision history:
v1 => :
- No changes
---
drivers/iio/adc/ad7476.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/adc/ad7476.c b/drivers/iio/adc/ad7476.c
index f117aafd8fad..7b6d36999afc 100644
--- a/drivers/iio/adc/ad7476.c
+++ b/drivers/iio/adc/ad7476.c
@@ -27,7 +27,7 @@
struct ad7476_state;
struct ad7476_chip_info {
- unsigned int int_vref_uv;
+ unsigned int int_vref_mv;
struct iio_chan_spec channel[2];
/* channels used when convst gpio is defined */
struct iio_chan_spec convst_channel[2];
@@ -172,7 +172,7 @@ static const struct ad7476_chip_info ad7091r_chip_info = {
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
.convst_channel[0] = AD7091R_CONVST_CHAN(12),
.convst_channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- .int_vref_uv = 2500000,
+ .int_vref_mv = 2500,
.has_vref = true,
.reset = ad7091_reset,
};
@@ -229,7 +229,7 @@ static const struct ad7476_chip_info ad7475_chip_info = {
static const struct ad7476_chip_info ad7495_chip_info = {
.channel[0] = AD7476_CHAN(12),
.channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1),
- .int_vref_uv = 2500000,
+ .int_vref_mv = 2500,
.has_vdrive = true,
};
@@ -295,7 +295,7 @@ static int ad7476_probe(struct spi_device *spi)
return -ENODEV;
/* Use VCC for reference voltage if vref / internal vref aren't used */
- if (!st->chip_info->int_vref_uv && !st->chip_info->has_vref) {
+ if (!st->chip_info->int_vref_mv && !st->chip_info->has_vref) {
ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vcc");
if (ret < 0)
return ret;
@@ -310,7 +310,7 @@ static int ad7476_probe(struct spi_device *spi)
ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vref");
if (ret < 0) {
/* Vref is optional if a device has an internal reference */
- if (!st->chip_info->int_vref_uv || ret != -ENODEV)
+ if (!st->chip_info->int_vref_mv || ret != -ENODEV)
return ret;
} else {
st->scale_mv = ret / 1000;
@@ -318,7 +318,7 @@ static int ad7476_probe(struct spi_device *spi)
}
if (!st->scale_mv)
- st->scale_mv = st->chip_info->int_vref_uv / 1000;
+ st->scale_mv = st->chip_info->int_vref_mv;
if (st->chip_info->has_vdrive) {
ret = devm_regulator_get_enable(&spi->dev, "vdrive");
--
2.50.1
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists