[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260129180404.68bcdf20@jic23-huawei>
Date: Thu, 29 Jan 2026 18:04:04 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: 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 v3 7/8] iio: dac: ds4424: convert to regmap
On Wed, 28 Jan 2026 16:38:23 +0100
Oleksij Rempel <o.rempel@...gutronix.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@...gutronix.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
Powered by blists - more mailing lists