Thread (26 messages) read the whole thread 26 messages, 5 authors, 2026-02-03

Re: [PATCH v2 6/8] iio: dac: ds4424: fix -128 rejection and refactor raw access

From: Oleksij Rempel <o.rempel@pengutronix.de>
Date: 2026-01-27 10:49:14
Also in: linux-iio, lkml, stable

On Tue, Jan 27, 2026 at 12:42:24PM +0200, Andy Shevchenko wrote:
On Tue, Jan 27, 2026 at 07:09:37AM +0100, Oleksij Rempel wrote:
quoted
The DS442x DAC uses sign-magnitude encoding, so -128 cannot be represented.
Previously, passing -128 resulted in a truncated value that programmed 0mA.

Fix this by validating the input against the 7-bit magnitude limit.
Additionally, refactor the raw access logic to use symmetrical bitwise
operations, replacing the union structure.
quoted
Fixes: d632a2bd8ffc ("iio: dac: ds4422/ds4424 dac driver")
+		/*
+		 * Currents exiting the IC (Source) are positive.
+		 * Canonicalize 0 to sink; datasheet treats sign as don't-care.
+		 */
+		if (val > 0)
+			abs_val |= DS4424_DAC_SOURCE;
Hmm... Maybe 0 should be excluded as invalid?
0 is valid value for no current flow (power off). The direction bit
DS4424_DAC_SOURCE  will just make no difference if value is 0.

-- 
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