From: Jonathan Cameron <jic23@kernel.org>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
kernel@pengutronix.de, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
"Andy Shevchenko" <andy@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"David Jander" <david@protonic.nl>
Subject: Re: [PATCH v3 7/8] iio: dac: ds4424: convert to regmap
Date: Thu, 29 Jan 2026 18:04:04 +0000 [thread overview]
Message-ID: <20260129180404.68bcdf20@jic23-huawei> (raw)
In-Reply-To: <20260128153824.3679187-8-o.rempel@pengutronix.de>
On Wed, 28 Jan 2026 16:38:23 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> Refactor the driver to use the regmap API.
>
> Replace the driver-specific mutex and manual shadow buffers with the
> standard regmap infrastructure for locking and caching.
>
> This ensures the cache is populated from hardware at probe, preventing
> state desynchronization (e.g. across suspend/resume).
>
> Define access tables to validate the different register maps of DS44x2
> and DS44x4.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Hi Oleksij
A few comments that might not overlap with what Andy already provided.
> diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
> index f340d491fcc1..9bef1c60b2eb 100644
> --- a/drivers/iio/dac/ds4424.c
> +++ b/drivers/iio/dac/ds4424.c
> +static int ds4424_init_regmap(struct i2c_client *client,
> + struct iio_dev *indio_dev)
> {
> struct ds4424_data *data = iio_priv(indio_dev);
> + const struct regmap_config *regmap_config;
> + u8 vals[DS4424_MAX_DAC_CHANNELS];
> int ret;
>
> - mutex_lock(&data->lock);
> - ret = i2c_smbus_write_byte_data(data->client,
> - DS4424_DAC_ADDR(chan->channel), val);
> - if (ret < 0)
> - goto fail;
> -
> - data->raw[chan->channel] = val;
> -
> -fail:
> - mutex_unlock(&data->lock);
> - return ret;
> + if (indio_dev->num_channels == DS4424_MAX_DAC_CHANNELS)
> + regmap_config = &ds44x4_regmap_config;
> + else
> + regmap_config = &ds44x2_regmap_config;
> +
> + data->regmap = devm_regmap_init_i2c(client, regmap_config);
> + if (IS_ERR(data->regmap))
> + return dev_err_probe(&client->dev, PTR_ERR(data->regmap),
> + "Failed to init regmap.\n");
> +
> + /*
> + * Prime the cache with the bootloader's configuration.
> + * regmap_bulk_read will automatically populate the cache with
regmap_bulk_read()
style preferred for functions mentioned in comments.
> + * the values read from the hardware.
> + */
> + ret = regmap_bulk_read(data->regmap, DS4424_DAC_ADDR(0), vals,
> @@ -233,10 +253,7 @@ static int ds4424_probe(struct i2c_client *client)
> return ret;
> }
>
> - usleep_range(1000, 1200);
> - ret = ds4424_verify_chip(indio_dev);
> - if (ret < 0)
> - goto fail;
> + fsleep(1000);
This change to fsleep() is unrelated to regmap stuff. So separate patch.
Thanks,
Jonathan
next prev parent reply other threads:[~2026-01-29 18:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 15:38 [PATCH v3 0/8] iio: dac: ds4424: add DS4402/DS4404 support and scale Oleksij Rempel
2026-01-28 15:38 ` [PATCH v3 1/8] iio: dac: ds4424: fix -128 rejection and refactor raw access Oleksij Rempel
2026-01-29 17:58 ` Jonathan Cameron
2026-02-01 12:40 ` Oleksij Rempel
2026-02-01 14:42 ` Jonathan Cameron
2026-01-28 15:38 ` [PATCH v3 2/8] iio: dac: ds4424: ratelimit read errors and use device context Oleksij Rempel
2026-01-28 15:38 ` [PATCH v3 3/8] iio: dac: ds4424: sort headers alphabetically Oleksij Rempel
2026-01-28 15:38 ` [PATCH v3 4/8] dt-bindings: iio: dac: maxim,ds4424: add ds4402/ds4404 Oleksij Rempel
2026-01-28 15:38 ` [PATCH v3 5/8] dt-bindings: iio: dac: maxim,ds4424: add maxim,rfs-ohms property Oleksij Rempel
2026-01-28 17:34 ` Conor Dooley
2026-01-28 15:38 ` [PATCH v3 6/8] iio: dac: ds4424: add DS4402/DS4404 device IDs Oleksij Rempel
2026-01-31 21:31 ` David Lechner
2026-01-28 15:38 ` [PATCH v3 7/8] iio: dac: ds4424: convert to regmap Oleksij Rempel
2026-01-28 22:17 ` Andy Shevchenko
2026-01-29 18:04 ` Jonathan Cameron [this message]
2026-02-01 19:35 ` Sander Vanheule
2026-01-28 15:38 ` [PATCH v3 8/8] iio: dac: ds4424: add Rfs-based scale and per-variant limits Oleksij Rempel
2026-01-29 18:19 ` Jonathan Cameron
2026-01-28 22:19 ` [PATCH v3 0/8] iio: dac: ds4424: add DS4402/DS4404 support and scale Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260129180404.68bcdf20@jic23-huawei \
--to=jic23@kernel.org \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david@protonic.nl \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=kernel@pengutronix.de \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=o.rempel@pengutronix.de \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox