From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Janani Sunil <janani.sunil@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Philipp Zabel" <p.zabel@pengutronix.de>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Mark Brown" <broonie@kernel.org>,
"Marius Cristea" <marius.cristea@microchip.com>,
"Marcus Folkesson" <marcus.folkesson@gmail.com>,
"Kent Gustavsson" <kent@minoris.se>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
"Janani Sunil" <jan.sun97@gmail.com>,
linux-spi@vger.kernel.org, "Kent Gustavsson" <nedo80@gmail.com>
Subject: Re: [PATCH v6 5/5] iio: dac: Add AD5529R DAC driver support
Date: Sun, 19 Jul 2026 03:19:52 +0100 [thread overview]
Message-ID: <20260719031952.732e193d@jic23-huawei> (raw)
In-Reply-To: <20260715-ad5529r-driver-v6-5-cfdf8b9f5ee3@analog.com>
On Wed, 15 Jul 2026 13:41:08 +0200
Janani Sunil <janani.sunil@analog.com> wrote:
> Add support for AD5529R 16-channel, 12/16 bit Digital to Analog Converter
> from Analog Devices.
>
> The device communicates over SPI and supports per-channel output range
> configuration. An optional external 4.096V reference can be used in
> place of the internal reference.
>
> Signed-off-by: Janani Sunil <janani.sunil@analog.com>
Hi Janini
Fairly quick review as it is end of day here now.
A few things inline.
Thanks,
Jonathan
> diff --git a/drivers/iio/dac/ad5529r.c b/drivers/iio/dac/ad5529r.c
> new file mode 100644
> index 000000000000..c279dc530d68
> --- /dev/null
> +++ b/drivers/iio/dac/ad5529r.c
> +static int ad5529r_reset(struct ad5529r_state *st)
> +{
> + struct reset_control *rst;
> + int ret;
> +
> + rst = devm_reset_control_get_optional_exclusive(&st->spi->dev, NULL);
> + if (IS_ERR(rst))
> + return PTR_ERR(rst);
> +
> + if (rst) {
> + ret = reset_control_assert(rst);
> + if (ret)
> + return ret;
> +
Nothing on the datasheet to say how long it needs to be asserted?
If it is very small maybe add a comment to say that here.
> + ret = reset_control_deassert(rst);
> + if (ret)
> + return ret;
> +
> +static int ad5529r_probe(struct spi_device *spi)
> +{
> + struct device *dev = &spi->dev;
> + struct iio_dev *indio_dev;
> + struct ad5529r_state *st;
> + struct regmap_config regmap_8bit_cfg = ad5529r_regmap_8bit_config;
> + struct regmap_config regmap_16bit_cfg = ad5529r_regmap_16bit_config;
I would fill both of these in using a designated initializer and do
it once we know the remaining fields.
regmap_8bit_cfg = (struct regmap_config) {
.name = "ad5529r-8bit",
.reg_bits = 16,
.val_bits = 8,
.max_register = AD5529R_8BIT_REG_MAX,
.read_flag_mask = AD5529R_SPI_READ_FLAG,
.rd_table = &ad5529r_8bit_readable_table,
.wr_table = &ad5529r_8bit_writeable_table,
.reg_base = ...
};
That keeps everything in once place and removes the indirection of a template
that we then override parts of.
> + bool external_vref;
> + u32 dev_addr = 0;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + st = iio_priv(indio_dev);
> +
> + st->spi = spi;
> +
> + st->model_data = spi_get_device_match_data(spi);
> + if (!st->model_data)
> + return dev_err_probe(dev, -EINVAL,
> + "Failed to identify device variant\n");
> +
> + device_property_read_u32(dev, "spi-device-addr", &dev_addr);
> + if (dev_addr > 3)
> + return dev_err_probe(dev, -EINVAL,
> + "spi-device-addr %u out of range [0, 3]\n",
> + dev_addr);
> + regmap_8bit_cfg.reg_base = dev_addr << AD5529R_ADDR_SHIFT;
> + regmap_16bit_cfg.reg_base = dev_addr << AD5529R_ADDR_SHIFT;
> +
> + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(ad5529r_supply_names),
> + ad5529r_supply_names);
> + if (ret)
> + return dev_err_probe(dev, ret,
> + "Failed to get and enable regulators\n");
> +
> + ret = devm_regulator_get_enable_optional(dev, "hvss");
> + if (ret && ret != -ENODEV)
> + return dev_err_probe(dev, ret,
> + "Failed to get and enable hvss regulator\n");
> +
> + ret = devm_regulator_get_enable_optional(dev, "vref");
> + if (ret == -ENODEV)
> + external_vref = false;
> + else if (!ret)
> + external_vref = true;
> + else
> + return dev_err_probe(dev, ret,
> + "Failed to get and enable vref regulator\n");
Slightly prefer these last two flipped so get the error of the way
a bit earlier.
> +
next prev parent reply other threads:[~2026-07-19 2:19 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 11:41 [PATCH v6 0/5] iio: dac: Add support for AD5529R DAC Janani Sunil
2026-07-15 11:41 ` [PATCH v6 1/5] spi: dt-bindings: Add spi-device-addr peripheral property Janani Sunil
2026-07-15 11:48 ` sashiko-bot
2026-07-15 13:09 ` Mark Brown
2026-07-15 13:29 ` Nuno Sá
2026-07-15 13:37 ` Mark Brown
2026-07-16 9:22 ` Nuno Sá
2026-07-16 12:28 ` Mark Brown
2026-07-16 17:06 ` Conor Dooley
2026-07-17 11:51 ` Mark Brown
2026-07-17 13:52 ` Nuno Sá
2026-07-19 2:10 ` Jonathan Cameron
2026-07-15 11:41 ` [PATCH v6 2/5] dt-bindings: iio: adc: microchip,mcp3564: Add spi-device-addr Janani Sunil
2026-07-15 11:50 ` sashiko-bot
2026-07-19 2:07 ` Jonathan Cameron
2026-07-15 11:41 ` [PATCH v6 3/5] dt-bindings: iio: adc: microchip,mcp3911: " Janani Sunil
2026-07-15 11:52 ` sashiko-bot
2026-07-19 2:08 ` Jonathan Cameron
2026-07-15 11:41 ` [PATCH v6 4/5] dt-bindings: iio: dac: Add AD5529R Janani Sunil
2026-07-15 11:52 ` sashiko-bot
2026-07-15 11:41 ` [PATCH v6 5/5] iio: dac: Add AD5529R DAC driver support Janani Sunil
2026-07-15 11:52 ` sashiko-bot
2026-07-15 22:22 ` Uwe Kleine-König
2026-07-19 2:19 ` Jonathan Cameron [this message]
2026-09-30 9:17 ` Andy Shevchenko
2026-09-30 13:51 ` Janani Sunil
2026-09-30 14:04 ` 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=20260719031952.732e193d@jic23-huawei \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jan.sun97@gmail.com \
--cc=janani.sunil@analog.com \
--cc=kent@minoris.se \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=marcus.folkesson@gmail.com \
--cc=marius.cristea@microchip.com \
--cc=nedo80@gmail.com \
--cc=nuno.sa@analog.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=skhan@linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.