From: sashiko-bot@kernel.org
To: "Stefan Popa" <stefan.popa@analog.com>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v1 2/2] iio: adc: add MAX40080 current-sense amplifier driver
Date: Fri, 03 Jul 2026 10:42:49 +0000 [thread overview]
Message-ID: <20260703104250.2B3B31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703102941.1141341-3-stefan.popa@analog.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver enables I2C PEC without verifying adapter support and sets the I2C_CLIENT_PEC flag before configuring the device to expect it.
- [Medium] The driver modifies volatile hardware state during initialization but lacks PM suspend/resume hooks to restore this state, causing device failure after a suspend cycle.
--
commit 7c1a04214c6c99c028e92e65daff698c598ebaff
Author: Stefan Popa <stefan.popa@analog.com>
iio: adc: add MAX40080 current-sense amplifier driver
The MAX40080 is a bidirectional current-sense amplifier with an
integrated 12-bit ADC and an I2C/SMBus interface. It measures the
voltage across an external shunt resistor and the input bus voltage,
storing the results in an internal FIFO.
> diff --git a/drivers/iio/adc/max40080.c b/drivers/iio/adc/max40080.c
> new file mode 100644
> index 0000000000000..441e1ce3dcffd
> --- /dev/null
> +++ b/drivers/iio/adc/max40080.c
> @@ -0,0 +1,587 @@
[ ... ]
> +static int max40080_probe(struct i2c_client *client)
> +{
> + struct device *dev = &client->dev;
> + struct iio_dev *indio_dev;
> + struct max40080_state *st;
> + int ret;
> +
> + if (!i2c_check_functionality(client->adapter,
> + I2C_FUNC_SMBUS_WORD_DATA |
> + I2C_FUNC_SMBUS_I2C_BLOCK |
> + I2C_FUNC_SMBUS_QUICK))
> + return -EOPNOTSUPP;
[Severity: High]
Should this check also verify I2C_FUNC_SMBUS_PEC support?
If the adapter lacks PEC support, it will not send PEC bytes. However, since the
driver writes MAX40080_PEC_EN_MSK to the device during initialization, the device
will expect a PEC byte on all subsequent transactions and discard any writes that
lack it.
Won't this render the device unresponsive on adapters without PEC?
> +
> + client->flags |= I2C_CLIENT_PEC;
[Severity: High]
Is it safe to unconditionally set the I2C_CLIENT_PEC flag before the hardware is
configured to accept PEC bytes?
Since the device powers up with PEC disabled, it expects a standard 2-byte SMBus
word write. If the host appends a 3rd PEC byte during the initial configuration
in max40080_init(), won't the device NACK it, causing the initial configuration
to fail and probe to abort?
[ ... ]
> +static struct i2c_driver max40080_driver = {
> + .driver = {
> + .name = "max40080",
> + .of_match_table = max40080_of_match,
> + },
> + .probe = max40080_probe,
> + .id_table = max40080_i2c_ids,
> +};
[Severity: Medium]
Does this driver need PM suspend/resume hooks to restore hardware state?
max40080_init() programs the device into MAX40080_SINGLE_MODE, enables PEC, and
configures the FIFO. If the system enters a sleep state where power to the
sensor is cut, the device resets to its power-on defaults (STANDBY_MODE, PEC
disabled).
Upon resume, any subsequent read would trigger an I2C Quick Command (which the
device ignores in STANDBY_MODE) and poll indefinitely for the data valid bit,
resulting in a timeout.
Additionally, the software would send PEC bytes which the reset device would
reject.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260703102941.1141341-1-stefan.popa@analog.com?part=2
next prev parent reply other threads:[~2026-07-03 10:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:29 [PATCH v1 0/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-03 10:29 ` [PATCH v1 1/2] dt-bindings: iio: adc: add maxim,max40080 Stefan Popa
2026-07-03 16:21 ` Conor Dooley
2026-07-03 20:42 ` David Lechner
2026-07-03 10:29 ` [PATCH v1 2/2] iio: adc: add MAX40080 current-sense amplifier driver Stefan Popa
2026-07-03 10:42 ` sashiko-bot [this message]
2026-07-03 12:08 ` Andy Shevchenko
2026-07-03 23:36 ` Jonathan Cameron
2026-07-03 19:42 ` Siratul Islam
2026-07-03 20:29 ` David Lechner
2026-07-04 12:05 ` Andy Shevchenko
2026-07-04 16:32 ` Siratul Islam
2026-07-04 17:05 ` Andy Shevchenko
2026-07-04 17:30 ` Siratul Islam
2026-07-04 18:52 ` Andy Shevchenko
2026-07-03 21:04 ` David Lechner
2026-07-03 23:53 ` Jonathan Cameron
2026-07-03 11:34 ` [PATCH v1 0/2] " 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=20260703104250.2B3B31F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=stefan.popa@analog.com \
/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