From: sashiko-bot@kernel.org
To: "Siqi Chen" <chensiqi@uniontech.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH] hwmon: (pcf8591) Propagate channel access errors
Date: Tue, 17 Nov 2026 11:48:01 +0000 [thread overview]
Message-ID: <sashiko-outbox-218728@kernel.org> (raw)
In-Reply-To: <20261117113819.3336050-1-chensiqi@uniontech.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] hwmon: (pcf8591) negative ADC readings treated as errors in
show_in_channel()
--
commit d99106187d0cf00e871df0cbaf44bbf27b3630ed
Author: Siqi Chen <chensiqi@uniontech.com>
hwmon: (pcf8591) Propagate channel access errors
This commit checks SMBus operations in pcf8591_read_channel() for errors,
invalidates the cached channel until selection and the dummy read succeed,
and propagates negative error codes through the sysfs show callbacks.
> diff --git a/drivers/hwmon/pcf8591.c b/drivers/hwmon/pcf8591.c
> index ec98e6b66c49b..602d0caeaced6 100644
> --- a/drivers/hwmon/pcf8591.c
> +++ b/drivers/hwmon/pcf8591.c
[ ... ]
> @@ -81,7 +82,11 @@ static ssize_t show_in##channel##_input(struct device *dev, \
> struct device_attribute *attr, \
> char *buf) \
> { \
> - return sprintf(buf, "%d\n", pcf8591_read_channel(dev, channel));\
> + int value = pcf8591_read_channel(dev, channel); \
> + \
> + if (value < 0) \
> + return value; \
> + return sysfs_emit(buf, "%d\n", value); \
> } \
> static DEVICE_ATTR(in##channel##_input, S_IRUGO, \
> show_in##channel##_input, NULL);
[Severity: High]
Does checking value < 0 here reject valid negative differential ADC
readings as errors?
In differential modes (input_mode 1, 2, or 3), pcf8591_read_channel()
converts two's-complement readings via 10 * REG_TO_SIGNED(value), which
legitimately returns values in [-1280, -10] when bit 7 of the ADC byte is
set. Treating any negative return value as an error causes sysfs reads of
in0_input, in1_input, or in2_input to fail with the millivolt reading as
the errno whenever the differential input voltage is negative. Returning
the channel reading through an int * output parameter while returning 0 or
a negative errno from pcf8591_read_channel() would keep the two separate.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117113819.3336050-1-chensiqi@uniontech.com?part=1
next prev parent reply other threads:[~2026-11-17 11:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 11:38 [PATCH] hwmon: (pcf8591) Propagate channel access errors Siqi Chen
2026-11-17 11:48 ` sashiko-bot [this message]
2026-11-17 16:07 ` Guenter Roeck
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=sashiko-outbox-218728@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chensiqi@uniontech.com \
--cc=linux-hwmon@vger.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