[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aYHF29ZR9mdi6Pqx@smile.fi.intel.com>
Date: Tue, 3 Feb 2026 11:54:35 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Jonathan Cameron <jic23@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, stable@...r.kernel.org,
kernel@...gutronix.de, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
Andy Shevchenko <andy@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
David Jander <david@...tonic.nl>
Subject: Re: [PATCH v4 01/13] iio: dac: ds4424: reject -128 RAW value
On Tue, Feb 03, 2026 at 10:34:21AM +0100, Oleksij Rempel wrote:
> 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.
...
> case IIO_CHAN_INFO_RAW:
> - if (val < S8_MIN || val > S8_MAX)
> + if (val <= S8_MIN || val > S8_MAX)
> return -EINVAL;
I still consider using -127, 127 is better than type _MIN/_MAX.
This is all due to '='.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists