From: sashiko-bot@kernel.org
To: "Joshua Crofts" <joshua.crofts1@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 2/2] iio: dac: mcp47a1: add support for new device
Date: Mon, 03 Aug 2026 17:44:40 +0000 [thread overview]
Message-ID: <20260803174441.294171F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260803-mcp47a1-add-support-v3-2-540e71b4fd2e@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect SMBus commands send extra bytes and corrupt the DAC hardware state.
--
--- Patch [2]: [PATCH v3 2/2] iio: dac: mcp47a1: add support for new device ---
commit f73263d5ea24798a693c0c4cfa738627794988ba
Author: Joshua Crofts <joshua.crofts1@gmail.com>
iio: dac: mcp47a1: add support for new device
This commit introduces a new driver for the Microchip MCP47A1 6-bit volatile
DAC. It supports writing and reading the raw values and exposing the scale
using I2C.
> diff --git a/drivers/iio/dac/mcp47a1.c b/drivers/iio/dac/mcp47a1.c
> new file mode 100644
> index 0000000000000..0bf994aa0e4f5
> --- /dev/null
> +++ b/drivers/iio/dac/mcp47a1.c
[ ... ]
> +static int mcp47a1_write(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int val, int val2, long mask)
> +{
> + struct mcp47a1_data *data = iio_priv(indio_dev);
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + if (!in_range(val, 0, MCP47A1_MAX_STEPS))
> + return -EINVAL;
> +
> + return i2c_smbus_write_byte_data(data->client, MCP47A1_CMD_CODE,
> + val);
[Severity: Medium]
Could this corrupt the DAC hardware state by sending an extra byte?
If the MCP47A1 expects a single byte without a command code, using
i2c_smbus_write_byte_data() will send a 2-byte payload, writing 0x00 to the
DAC before the actual value. This could potentially cause an output glitch.
> + default:
> + return -EINVAL;
> + }
> +}
> +
> +static int mcp47a1_read(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + struct mcp47a1_data *data = iio_priv(indio_dev);
> + int ret;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + ret = i2c_smbus_read_byte_data(data->client, MCP47A1_CMD_CODE);
[Severity: Medium]
Does this destructively reset the DAC on every read?
If the device does not expect a command code and interprets it as a data byte,
calling i2c_smbus_read_byte_data() will perform a write of 0x00 before reading,
destructively resetting the DAC output to 0.
> + if (ret < 0)
> + return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803-mcp47a1-add-support-v3-0-540e71b4fd2e@gmail.com?part=2
next prev parent reply other threads:[~2026-08-03 17:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 17:32 [PATCH v3 0/2] iio: dac: mcp47a1: add support for new device Joshua Crofts
2026-08-03 17:32 ` [PATCH v3 1/2] dt-bindings: iio: dac: add support for mcp47a1 Joshua Crofts
2026-08-03 18:07 ` sashiko-bot
2026-08-03 19:35 ` Joshua Crofts
2026-08-03 17:32 ` [PATCH v3 2/2] iio: dac: mcp47a1: add support for new device Joshua Crofts
2026-08-03 17:44 ` sashiko-bot [this message]
2026-08-03 19:42 ` Joshua Crofts
2026-08-05 0:14 ` [PATCH v3 0/2] " Jonathan Cameron
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=20260803174441.294171F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=joshua.crofts1@gmail.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