[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aXiV35CoH6f8FPUT@smile.fi.intel.com>
Date: Tue, 27 Jan 2026 12:39:27 +0200
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Jonathan Cameron <jic23@...nel.org>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, kernel@...gutronix.de,
linux-kernel@...r.kernel.org, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, Andy Shevchenko <andy@...nel.org>,
David Lechner <dlechner@...libre.com>,
Nuno Sá <nuno.sa@...log.com>,
David Jander <david@...tonic.nl>
Subject: Re: [PATCH v2 5/8] iio: dac: ds4424: convert to regmap
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
Powered by blists - more mailing lists