Thread (32 messages) 32 messages, 3 authors, 2026-02-09

Re: [PATCH v4 01/13] iio: dac: ds4424: reject -128 RAW value

From: Oleksij Rempel <o.rempel@pengutronix.de>
Date: 2026-02-03 10:28:51
Also in: linux-iio, lkml, stable

On Tue, Feb 03, 2026 at 11:54:35AM +0200, Andy Shevchenko wrote:
On Tue, Feb 03, 2026 at 10:34:21AM +0100, Oleksij Rempel wrote:
quoted
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.
...
quoted
 	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 '='.
The use of S8_MIN here is intentional to satisfy the requirement for a minimal
stable backport, as requested by Jonathan:
https://lore.kernel.org/all/20260201144226.218a43cb@jic23-huawei/ (local)

This patch: Strict "Fix only" for stable. Uses minimal logic changes (<=
S8_MIN) to avoid introducing new bugs during backporting.

N++ patch: Full refactoring.

Can we accept this temporary state to facilitate the stable process?

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help