From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"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 v2 5/8] iio: dac: ds4424: convert to regmap
Date: Tue, 27 Jan 2026 12:39:27 +0200 [thread overview]
Message-ID: <aXiV35CoH6f8FPUT@smile.fi.intel.com> (raw)
In-Reply-To: <20260127060939.3914006-6-o.rempel@pengutronix.de>
On Tue, Jan 27, 2026 at 07:09:36AM +0100, Oleksij Rempel 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.
...
> +static const struct regmap_access_table ds44x4_table = {
> + .yes_ranges = ds44x4_ranges,
> + .n_yes_ranges = ARRAY_SIZE(ds44x4_ranges),
+ array_size.h
> +};
...
> + ret = regmap_read(data->regmap, DS4424_DAC_ADDR(chan->channel),
> + ®val);
> if (ret < 0) {
> - pr_err("%s : ds4424_get_value returned %d\n",
> - __func__, ret);
> + pr_err("%s : regmap_read returned %d\n",
> + __func__, ret);
This should be dev_err() to begin with. Perhaps you want a new patch for that.
> return ret;
> }
...
> + /* Bulk read all channels starting at 0xf8.
> + * This populates the regmap cache with current HW values.
> + */
/*
* Use proper style for multi-line
* comments.
*/
...
> + if (ret)
> + return dev_err_probe(&indio_dev->dev, ret, "Failed to seed cache\n");
Why not physical device? I assume during probe we use physical device, when we
do IIO callbacks, we use IIO device.
...
> static int ds4424_suspend(struct device *dev)
> {
> + struct iio_dev *indio_dev = dev_get_drvdata(dev);
> struct ds4424_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + /* Disable all outputs, bypass cache so the '0' isn't saved */
> + regcache_cache_bypass(data->regmap, true);
> + for (unsigned int i = 0; i < indio_dev->num_channels; i++) {
> + ret = regmap_write(data->regmap, DS4424_DAC_ADDR(i), 0);
> + if (ret) {
> + dev_err(dev, "Failed to zero channel %d: %d\n", i, ret);
%u for 'i'.
> + regcache_cache_bypass(data->regmap, false);
> return ret;
> + }
> }
> + regcache_cache_bypass(data->regmap, false);
> +
> + regcache_cache_only(data->regmap, true);
> + regcache_mark_dirty(data->regmap);
> +
> + return 0;
> }
...
> usleep_range(1000, 1200);
Side note: Perhaps fsleep() in the future...
> + ret = ds4424_init_regmap(client, indio_dev);
> + if (ret < 0)
Do we need ' < 0' part?
> + goto fail;
> +
> + ret = ds4424_verify_chip(indio_dev);
> + if (ret < 0)
Ditto.
> + goto fail;
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-01-27 10:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-27 6:09 [PATCH v2 0/8] iio: dac: ds4424: add DS4402/DS4404 support and scale Oleksij Rempel
2026-01-27 6:09 ` [PATCH v2 1/8] dt-bindings: iio: dac: maxim,ds4424: add ds4402/ds4404 Oleksij Rempel
2026-01-27 6:09 ` [PATCH v2 2/8] dt-bindings: iio: dac: maxim,ds4424: add maxim,rfs-ohms property Oleksij Rempel
2026-01-27 19:49 ` Conor Dooley
2026-01-27 19:55 ` Conor Dooley
2026-01-28 8:01 ` David Jander
2026-01-28 17:00 ` Conor Dooley
2026-01-27 6:09 ` [PATCH v2 3/8] iio: dac: ds4424: add DS4402/DS4404 device IDs Oleksij Rempel
2026-01-27 10:27 ` Andy Shevchenko
2026-01-27 6:09 ` [PATCH v2 4/8] iio: dac: ds4424: sort headers alphabetically Oleksij Rempel
2026-01-27 10:30 ` Andy Shevchenko
2026-01-27 6:09 ` [PATCH v2 5/8] iio: dac: ds4424: convert to regmap Oleksij Rempel
2026-01-27 10:39 ` Andy Shevchenko [this message]
2026-02-01 14:42 ` Sander Vanheule
2026-02-01 16:16 ` Oleksij Rempel
2026-02-01 17:24 ` Sander Vanheule
2026-02-03 10:10 ` Andy Shevchenko
2026-02-03 10:13 ` Andy Shevchenko
2026-01-27 6:09 ` [PATCH v2 6/8] iio: dac: ds4424: fix -128 rejection and refactor raw access Oleksij Rempel
2026-01-27 10:42 ` Andy Shevchenko
2026-01-27 10:49 ` Oleksij Rempel
2026-01-27 10:51 ` Andy Shevchenko
2026-01-27 6:09 ` [PATCH v2 7/8] iio: dac: ds4424: add Rfs-based scale and per-variant limits Oleksij Rempel
2026-01-27 10:46 ` Andy Shevchenko
2026-01-27 6:09 ` [PATCH v2 8/8] iio: dac: ds4424: ratelimit read errors and use device context Oleksij Rempel
2026-01-27 10:47 ` 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=aXiV35CoH6f8FPUT@smile.fi.intel.com \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david@protonic.nl \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--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