Thread (24 messages) 24 messages, 5 authors, 2026-01-26

Re: [PATCH v1 6/8] iio: dac: ds4424: clear outputs on probe

From: Jonathan Cameron <jic23@kernel.org>
Date: 2026-01-23 09:38:13
Also in: linux-iio, lkml

On Mon, 19 Jan 2026 19:24:22 +0100
Oleksij Rempel [off-list ref] wrote:
The DS44xx devices have no reset pin or reset bit, so output registers
may retain preconfigured values across reboot or warm reset.

Also, the driver suspend/resume path restores from data->raw. When the
device is first probed, data->raw is zero-initialized and may not match
the actual hardware state. A later suspend/resume can therefore change an
output from a preconfigured non-zero value to 0 mA.
For DACs we often want to retain settings from before kernel load (or
on exit of the driver).  Can we just read them back from the device to
fill in the cached versions?  If we can I think that would be preferred
option.

Jonathan

quoted hunk ↗ jump to hunk
Initialize all channels to 0 output current during probe to ensure a
deterministic baseline and consistent suspend/resume behavior.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/iio/dac/ds4424.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
index a0c60eb89717..2d299a52cede 100644
--- a/drivers/iio/dac/ds4424.c
+++ b/drivers/iio/dac/ds4424.c
@@ -220,6 +220,20 @@ static int ds4424_verify_chip(struct iio_dev *indio_dev)
 	return ret;
 }
 
+static int ds4424_init(struct iio_dev *indio_dev)
+{
+	int i, ret;
+
+	/* Set all channels to 0 current. */
+	for (i = 0; i < indio_dev->num_channels; i++) {
+		ret = ds4424_set_value(indio_dev, 0, &indio_dev->channels[i]);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
 static int ds4424_setup_channels(struct i2c_client *client,
 				 struct ds4424_data *data,
 				 struct iio_dev *indio_dev)
@@ -397,6 +411,11 @@ static int ds4424_probe(struct i2c_client *client)
 	if (ret)
 		goto fail;
 
+	/* No reset pin/bit: clear any preconfigured output on probe. */
+	ret = ds4424_init(indio_dev);
+	if (ret)
+		goto fail;
+
 	indio_dev->modes = INDIO_DIRECT_MODE;
 	indio_dev->info = &ds4424_iio_info;
 
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help