From: Arka Mondal <arka@arkamondal.net>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Michael Hennerich" <Michael.Hennerich@analog.com>
Cc: David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
arkamondalofficial@gmail.com, Arka Mondal <arka@arkamondal.net>
Subject: [PATCH 5/5] iio: dac: ad5758: Fix the 4 mA to 20 mA current range
Date: Fri, 18 Sep 2026 21:20:32 +0900 [thread overview]
Message-ID: <20260918122032.134947-6-arka@arkamondal.net> (raw)
In-Reply-To: <20260918122032.134947-1-arka@arkamondal.net>
Range code 1010 selects 4 mA to 20 mA (data sheet Rev. B, Table 32),
but the driver describes it as 4 uA to 24 mA. With the reported scale
and offset, userspace converts raw code 0 to about 0 mA instead of
4 mA, and full scale to about 23 mA instead of 20 mA.
Describe the range as 4000 to 20000 uA and rename the enum entry to
match. Map the deprecated <4 24000> device tree value to the corrected
range, so existing device trees keep working.
Fixes: 28d1a7ac2a0d ("iio: dac: Add AD5758 support")
Signed-off-by: Arka Mondal <arka@arkamondal.net>
---
Notes:
Compile tested only; no relevant hardware available.
drivers/iio/dac/ad5758.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c
index 1e21ad2a050d..b152001f38d4 100644
--- a/drivers/iio/dac/ad5758.c
+++ b/drivers/iio/dac/ad5758.c
@@ -141,7 +141,7 @@ enum ad5758_output_range {
AD5758_RANGE_PLUSMINUS_10V,
AD5758_RANGE_0mA_20mA = 8,
AD5758_RANGE_0mA_24mA,
- AD5758_RANGE_4mA_24mA,
+ AD5758_RANGE_4mA_20mA,
AD5758_RANGE_PLUSMINUS_20mA,
AD5758_RANGE_PLUSMINUS_24mA,
AD5758_RANGE_MINUS_1mA_PLUS_22mA,
@@ -164,7 +164,7 @@ static const struct ad5758_range ad5758_voltage_range[] = {
static const struct ad5758_range ad5758_current_range[] = {
{ AD5758_RANGE_0mA_20mA, 0, 20000},
{ AD5758_RANGE_0mA_24mA, 0, 24000 },
- { AD5758_RANGE_4mA_24mA, 4, 24000 },
+ { AD5758_RANGE_4mA_20mA, 4000, 20000 },
{ AD5758_RANGE_PLUSMINUS_20mA, -20000, 20000 },
{ AD5758_RANGE_PLUSMINUS_24mA, -24000, 24000 },
{ AD5758_RANGE_MINUS_1mA_PLUS_22mA, -1000, 22000 },
@@ -747,6 +747,12 @@ static int ad5758_parse_dt(struct ad5758_state *st)
"Missing \"range-microamp\" property\n");
return ret;
}
+
+ if (tmparray[0] == 4 && tmparray[1] == 24000) {
+ tmparray[0] = 4000;
+ tmparray[1] = 20000;
+ }
+
range = ad5758_current_range;
size = ARRAY_SIZE(ad5758_current_range);
}
--
2.55.0
next prev parent reply other threads:[~2026-09-18 12:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 12:20 [PATCH 0/5] iio: dac: ad5758: fix DMA alignment, raw range, offset and 4-20 mA Arka Mondal
2026-09-18 12:20 ` [PATCH 1/5] iio: dac: ad5758: Fix alignment for DMA safety Arka Mondal
2026-09-18 12:20 ` [PATCH 2/5] iio: dac: ad5758: Reject out-of-range raw values Arka Mondal
2026-09-18 12:20 ` [PATCH 3/5] iio: dac: ad5758: Fix the offset calculation Arka Mondal
2026-09-18 12:20 ` [PATCH 4/5] dt-bindings: iio: dac: adi,ad5758: Fix the 4 mA to 20 mA current range Arka Mondal
2026-09-20 18:39 ` Jonathan Cameron
2026-09-28 19:34 ` Rob Herring
2026-10-04 16:27 ` Jonathan Cameron
2026-09-18 12:20 ` Arka Mondal [this message]
2026-09-18 15:22 ` [PATCH 0/5] iio: dac: ad5758: fix DMA alignment, raw range, offset and 4-20 mA Nuno Sá
2026-09-20 18:41 ` Jonathan Cameron
2026-09-27 20:52 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260918122032.134947-6-arka@arkamondal.net \
--to=arka@arkamondal.net \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=arkamondalofficial@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@analog.com \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox