From: John den Heijer <jdenheijer74@gmail.com>
To: linux-hwmon@vger.kernel.org
Cc: eugene.shalygin@gmail.com, linux@roeck-us.net
Subject: [RFC PATCH v2 1/3] hwmon: (asus-ec-sensors) propagate EC read and selector errors
Date: Sat, 28 Nov 2026 20:12:23 +0100 [thread overview]
Message-ID: <20261128191225.2990-2-jdenheijer74@gmail.com> (raw)
In-Reply-To: <20261128191225.2990-1-jdenheijer74@gmail.com>
On an EC or selector failure, asus_ec_block_read() can continue with a
partial buffer. A successful final bank restore then reports success,
so update_ec_sensors() publishes stale bytes.
Propagate the first error. Attempt selector restoration in its bank,
then restore the original bank. A failed restore also rejects the
update. This changes the failure path for all supported boards.
Signed-off-by: John den Heijer <jdenheijer74@gmail.com>
---
drivers/hwmon/asus-ec-sensors.c | 39 ++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 13 deletions(-)
diff --git a/drivers/hwmon/asus-ec-sensors.c b/drivers/hwmon/asus-ec-sensors.c
index d0c01b825..6e06256a5 100644
--- a/drivers/hwmon/asus-ec-sensors.c
+++ b/drivers/hwmon/asus-ec-sensors.c
@@ -1309,7 +1309,7 @@ static int asus_ec_bank_switch(u8 bank, u8 *old)
static int asus_ec_block_read(const struct device *dev,
struct ec_sensors_data *ec)
{
- int ireg, ibank, status;
+ int ireg, ibank, status, restore_status;
u8 bank, reg_bank, prev_bank, select, prev_select;
bool select_saved;
@@ -1330,7 +1330,8 @@ static int asus_ec_block_read(const struct device *dev,
for (ibank = 0; ibank < ec->nr_banks; ibank++) {
if (bank != ec->banks[ibank]) {
bank = ec->banks[ibank];
- if (asus_ec_bank_switch(bank, NULL)) {
+ status = asus_ec_bank_switch(bank, NULL);
+ if (status) {
dev_warn(dev, "EC bank switch to %d failed",
bank);
break;
@@ -1345,24 +1346,36 @@ static int asus_ec_block_read(const struct device *dev,
select = register_select(ec->registers[ireg]);
if (select) {
if (!select_saved) {
- if (ec_read(ASUS_EC_SELECT_REGISTER,
- &prev_select))
- continue;
+ status = ec_read(ASUS_EC_SELECT_REGISTER,
+ &prev_select);
+ if (status)
+ goto restore_select;
select_saved = true;
}
- if (ec_write(ASUS_EC_SELECT_REGISTER, select))
- continue;
+ status = ec_write(ASUS_EC_SELECT_REGISTER, select);
+ if (status)
+ goto restore_select;
}
- ec_read(register_index(ec->registers[ireg]),
- ec->read_buffer + ireg);
+ status = ec_read(register_index(ec->registers[ireg]),
+ ec->read_buffer + ireg);
+ if (status)
+ goto restore_select;
}
+restore_select:
/* restore the selector while still in its bank */
- if (select_saved &&
- ec_write(ASUS_EC_SELECT_REGISTER, prev_select))
- dev_warn(dev, "EC selector restore failed");
+ if (select_saved) {
+ restore_status = ec_write(ASUS_EC_SELECT_REGISTER,
+ prev_select);
+ if (!status)
+ status = restore_status;
+ }
+ if (status)
+ break;
}
- status = asus_ec_bank_switch(prev_bank, NULL);
+ restore_status = asus_ec_bank_switch(prev_bank, NULL);
+ if (!status)
+ status = restore_status;
return status;
}
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-11-28 19:12 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 19:12 [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card John den Heijer
2026-11-28 19:12 ` John den Heijer [this message]
2026-11-28 19:17 ` [RFC PATCH v2 1/3] hwmon: (asus-ec-sensors) propagate EC read and selector errors sashiko-bot
2026-11-28 19:12 ` [RFC PATCH v2 2/3] hwmon: (asus-ec-sensors) add opt-in MAXIMUS XI HERO EXT fan RPM John den Heijer
2026-11-28 19:19 ` sashiko-bot
2026-11-28 19:12 ` [RFC PATCH v2 3/3] hwmon: (asus-ec-sensors) add MAXIMUS XI HERO EXT thermistors John den Heijer
2026-11-28 19:19 ` [RFC PATCH v2 0/3] hwmon: asus-ec-sensors: MAXIMUS XI HERO Fan Extension Card 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=20261128191225.2990-2-jdenheijer74@gmail.com \
--to=jdenheijer74@gmail.com \
--cc=eugene.shalygin@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/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