From: sashiko-bot@kernel.org
To: "Janani Sunil" <janani.sunil@analog.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support
Date: Thu, 27 Aug 2026 07:50:41 +0000 [thread overview]
Message-ID: <20260827075041.DE0721F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260827-ad5529r-driver-v10-3-38f2be07b824@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Inconsistent and incorrect endianness configuration in 16-bit regmap.
- [High] Missing bit shift for 12-bit data variant.
--
commit 30ecf6c6be9fe7d7d56ed009cc4fbd27ef838d98
Author: Janani Sunil <janani.sunil@analog.com>
iio: dac: Add AD5529R DAC driver support
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.
> diff --git a/drivers/iio/dac/ad5529r.c b/drivers/iio/dac/ad5529r.c
> new file mode 100644
> index 0000000000000..52601cbf28d5e
> --- /dev/null
> +++ b/drivers/iio/dac/ad5529r.c
[ ... ]
> +static int ad5529r_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + struct ad5529r_state *st = iio_priv(indio_dev);
> + unsigned int reg_addr, reg_val_h;
> + int ret, range_idx, span_mV;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + /*
> + * Read from DAC_INPUT_A register rather than DAC_DATA_READBACK.
> + * The DAC operates in transparent mode and directly reflects
> + * whatever value is written to the INPUT_A register.
> + */
> + reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
> + ret = regmap_read(st->regmap_16bit, reg_addr, ®_val_h);
> + if (ret)
> + return ret;
> +
> + *val = reg_val_h;
[Severity: High]
Does this read of reg_val_h need a bit shift for the 12-bit variant of the
device?
Since 12-bit and 16-bit variants typically share a 16-bit register format,
the 12-bit variant often expects its data to be left-justified. By returning
the 16-bit register value directly without right-shifting, will this read
report a value 16 times higher than the actual scale for 12-bit models?
> +
> + return IIO_VAL_INT;
[ ... ]
> +static int ad5529r_write_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int val, int val2, long mask)
> +{
> + struct ad5529r_state *st = iio_priv(indio_dev);
> + unsigned int reg_addr;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + if (val < 0 || val > GENMASK(st->model_data->resolution - 1, 0))
> + return -EINVAL;
> +
> + reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
> +
> + return regmap_write(st->regmap_16bit, reg_addr, val);
[Severity: High]
Similarly, will writing the raw 12-bit value directly to the 16-bit register
without left-justification alignment cause the 12-bit variant to output
voltages significantly lower than intended?
> + default:
> + return -EINVAL;
> + }
> +}
[ ... ]
> +static int ad5529r_probe(struct spi_device *spi)
> +{
> + struct regmap_config regmap_16bit_cfg;
> + struct regmap_config regmap_8bit_cfg;
[ ... ]
> + regmap_16bit_cfg = (struct regmap_config) {
> + .name = "ad5529r-16bit",
> + .reg_bits = 16,
> + .val_bits = 16,
> + .max_register = AD5529R_MAX_REGISTER,
> + .read_flag_mask = AD5529R_SPI_READ_FLAG,
> + .val_format_endian = REGMAP_ENDIAN_LITTLE,
[Severity: High]
Will this little-endian configuration break the standard SPI MSB-first
protocol for 16-bit register values?
Standard SPI DACs usually expect big-endian ordering. Since the register
address defaults to big-endian, using REGMAP_ENDIAN_LITTLE for the values
could cause mixed endianness in the SPI transaction, which might result in
completely incorrect 16-bit register reads and writes over the bus.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-ad5529r-driver-v10-0-38f2be07b824@analog.com?part=3
next prev parent reply other threads:[~2026-08-27 7:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 7:34 [PATCH v10 0/3] iio: dac: Add support for AD5529R DAC Janani Sunil
2026-08-27 7:34 ` [PATCH v10 1/3] spi: dt-bindings: Add spi-device-addr peripheral property Janani Sunil
2026-08-27 7:34 ` [PATCH v10 2/3] dt-bindings: iio: dac: Add AD5529R Janani Sunil
2026-08-27 7:44 ` sashiko-bot
2026-08-27 7:34 ` [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support Janani Sunil
2026-08-27 7:50 ` sashiko-bot [this message]
2026-08-27 8:23 ` Andy Shevchenko
2026-08-27 11:17 ` Janani Sunil
2026-08-27 12:47 ` Andy Shevchenko
2026-08-27 8:30 ` Joshua Crofts
2026-08-27 9:18 ` 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=20260827075041.DE0721F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=janani.sunil@analog.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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