From: sashiko-bot@kernel.org
To: "Joshua Crofts" <joshua.crofts1@gmail.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 2/2] iio: dac: mcp47a1: add support for new device
Date: Mon, 27 Jul 2026 18:42:26 +0000 [thread overview]
Message-ID: <20260727184226.DFC1E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260727-mcp47a1-add-support-v2-2-d4591a2ce69e@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Potential off-by-one in DAC scale calculation denominator.
--
--- Patch [2]: [PATCH v2 2/2] iio: dac: mcp47a1: add support for new device ---
commit 38bec2fbb020c3f749c52a26e5cc3e78e72eeaf5
Author: Joshua Crofts <joshua.crofts1@gmail.com>
iio: dac: mcp47a1: add support for new device
The Microchip MCP47A1 is a 6-bit volatile Digital-to-Analog converter
which communicates via I2C.
> diff --git a/drivers/iio/dac/mcp47a1.c b/drivers/iio/dac/mcp47a1.c
> new file mode 100644
> index 0000000000000..140e93ff2ba01
> --- /dev/null
> +++ b/drivers/iio/dac/mcp47a1.c
[ ... ]
> +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_SCALE:
> + *val = data->vref_mV;
> + *val2 = MCP47A1_MAX_STEP;
[Severity: Medium]
Does this code use the correct denominator for the scale calculation?
Since this is a 6-bit DAC, shouldn't the scale denominator be 64 (2^6)
instead of the maximum step value of 63? Using MCP47A1_MAX_STEP (63) here
introduces an off-by-one error that could cause userspace to calculate
output voltages with a ~1.5% LSB scaling error when reading the sysfs
attribute.
> +
> + return IIO_VAL_FRACTIONAL;
> + default:
> + return -EINVAL;
> + }
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260727-mcp47a1-add-support-v2-0-d4591a2ce69e@gmail.com?part=2
next prev parent reply other threads:[~2026-07-27 18:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 18:31 [PATCH v2 0/2] iio: dac: mcp47a1: add support for new device Joshua Crofts
2026-07-27 18:31 ` [PATCH v2 1/2] dt-bindings: iio: dac: add support for mcp47a1 Joshua Crofts
2026-07-27 18:31 ` [PATCH v2 2/2] iio: dac: mcp47a1: add support for new device Joshua Crofts
2026-07-27 18:42 ` sashiko-bot [this message]
2026-07-28 13:15 ` Joshua Crofts
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=20260727184226.DFC1E1F000E9@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 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.