]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: dac: ds4424: reject -128 RAW value
authorOleksij Rempel <o.rempel@pengutronix.de>
Wed, 4 Feb 2026 14:00:33 +0000 (15:00 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 08:24:37 +0000 (08:24 +0000)
The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented
in hardware (7-bit magnitude).

Previously, passing -128 resulted in a truncated value that programmed
0mA (magnitude 0) instead of the expected maximum negative current,
effectively failing silently.

Reject -128 to avoid producing the wrong current.

Fixes: d632a2bd8ffc ("iio: dac: ds4422/ds4424 dac driver")
Cc: stable@vger.kernel.org
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ds4424.c

index 6dda8918975a669121e18c42a01227617230015c..c61868f2de316c4623feddec0dba304a784dbef4 100644 (file)
@@ -140,7 +140,7 @@ static int ds4424_write_raw(struct iio_dev *indio_dev,
 
        switch (mask) {
        case IIO_CHAN_INFO_RAW:
-               if (val < S8_MIN || val > S8_MAX)
+               if (val <= S8_MIN || val > S8_MAX)
                        return -EINVAL;
 
                if (val > 0) {