[PATCH v2 5/5] iio: dac: ad5758: Fix the 4 mA to 20 mA current range
From: Arka Mondal
Date: Tue Oct 06 2026 - 11:42:09 EST
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. A device tree that still has <4 24000> no longer matches any
entry in the table, so probe fails with "range invalid".
Fixes: 28d1a7ac2a0d ("iio: dac: Add AD5758 support")
Signed-off-by: Arka Mondal <arka@xxxxxxxxxxxxxx>
Reviewed-by: Nuno Sá <nuno.sa@xxxxxxxxxx>
---
Notes:
Compile tested only; no relevant hardware available.
drivers/iio/dac/ad5758.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c
index 1e21ad2a050d..4c15447ccb6b 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 },
--
2.55.0