From: sashiko-bot@kernel.org
To: "Nuno Sá via B4 Relay" <devnull+nuno.sa.analog.com@kernel.org>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v13 2/3] hwmon: ltc4283: Add support for the LTC4283 Swap Controller
Date: Sat, 02 May 2026 10:43:10 +0000 [thread overview]
Message-ID: <20260502104311.0D48EC19425@smtp.kernel.org> (raw)
In-Reply-To: <20260502-ltc4283-support-v13-2-1c206542e652@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Read-modify-write operations on hardware alarm and fault log registers will cause concurrent events to be lost.
--
commit 768d24f774b79f50e1444b93b756d7bda5873159
Author: Nuno Sá <nuno.sa@analog.com>
hwmon: ltc4283: Add support for the LTC4283 Swap Controller
This commit introduces driver support for the Analog Devices LTC4283
Negative Voltage Hot Swap Controller. It adds functionality to monitor
voltage, current, power, and various hardware faults via an I2C interface.
> diff --git a/drivers/hwmon/ltc4283.c b/drivers/hwmon/ltc4283.c
> new file mode 100644
> index 000000000000..d8931c9a4685
> --- /dev/null
> +++ b/drivers/hwmon/ltc4283.c
[ ... ]
> +static int ltc4283_read_alarm(struct ltc4283_hwmon *st, u32 reg,
> + u32 mask, long *val)
> +{
> + u32 alarm;
> + int ret;
> +
> + ret = regmap_read(st->map, reg, &alarm);
> + if (ret)
> + return ret;
> +
> + *val = !!(alarm & mask);
> +
> + /* If not status/fault logs, clear the alarm after reading it. */
> + if (reg != LTC4283_FAULT_STATUS && reg != LTC4283_FAULT_LOG)
> + return regmap_write(st->map, reg, alarm & ~mask);
Could this read-modify-write sequence cause concurrent hardware events to be
lost?
If these alarm registers use write-0-to-clear semantics, writing back
alarm & ~mask will inadvertently write a 0 to any new alarm bits that were
asserted by the hardware between the regmap_read() and regmap_write() calls.
Usually, a direct atomic write of ~mask without reading first is preferred
to avoid clearing unrelated active alarms.
[ ... ]
> +static int ltc4283_reset_power_hist(struct ltc4283_hwmon *st)
> +{
[ ... ]
> + /* Clear possible power faults. */
> + return regmap_clear_bits(st->map, LTC4283_FAULT_LOG,
> + LTC4283_PWR_FAIL_FAULT_MASK | LTC4283_PGI_FAULT_MASK);
> +}
Will using regmap_clear_bits() here and in other history reset functions
also risk losing concurrent fault logs?
Since regmap_clear_bits() performs a read-modify-write under the hood, any
new faults asserting between the read and write phases might be cleared
silently. Direct writes using regmap_write() might be safer if the register
behaves as write-0-to-clear.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260502-ltc4283-support-v13-0-1c206542e652@analog.com?part=2
next prev parent reply other threads:[~2026-05-02 10:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-02 9:56 [PATCH v13 0/3] hwmon: Add support for the LTC4283 Hot Swap Controller Nuno Sá via B4 Relay
2026-05-02 9:56 ` [PATCH v13 1/3] dt-bindings: hwmon: Document the LTC4283 " Nuno Sá via B4 Relay
2026-05-02 10:05 ` sashiko-bot
2026-05-02 9:56 ` [PATCH v13 2/3] hwmon: ltc4283: Add support for " Nuno Sá via B4 Relay
2026-05-02 10:43 ` sashiko-bot [this message]
2026-05-02 16:21 ` Guenter Roeck
2026-05-04 9:51 ` Nuno Sá
2026-05-02 9:56 ` [PATCH v13 3/3] gpio: gpio-ltc4283: " Nuno Sá via B4 Relay
2026-05-02 11:02 ` sashiko-bot
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=20260502104311.0D48EC19425@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+nuno.sa.analog.com@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko@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