Re: [PATCH 2/3] hwmon: spd5118: Retry temperature reads after temporary I2C errors

From: Guenter Roeck

Date: Mon Jan 12 2026 - 11:35:34 EST


On 1/10/26 09:19, Tinsae Tadesse wrote:
After suspend/resume, the SPD5118 hub or the underlying I2C adapter
may not be immediately available, causing register reads to fail.

Attempt a single regcache re-synchronization and retry the read to
allow recovery.

Signed-off-by: Tinsae Tadesse <tinsaetadesse2015@xxxxxxxxx>
---
drivers/hwmon/spd5118.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c
index ec9f14f6e0df..63f798991363 100644
--- a/drivers/hwmon/spd5118.c
+++ b/drivers/hwmon/spd5118.c
@@ -101,6 +101,7 @@ static int spd5118_read_temp(struct regmap *regmap, u32 attr, long *val)
int reg, err;
u8 regval[2];
u16 temp;
+ bool retried = false;
switch (attr) {
case hwmon_temp_input:
@@ -122,9 +123,17 @@ static int spd5118_read_temp(struct regmap *regmap, u32 attr, long *val)
return -EOPNOTSUPP;
}
+retry:
err = regmap_bulk_read(regmap, reg, regval, 2);
- if (err)
+ if (err) {
+ if (!retried && (err == -ENXIO || err == -EIO)) {
+ retried = true;
+ regcache_mark_dirty(regmap);
+ if (!regcache_sync(regmap))
+ goto retry;
+ }
return err;
+ }
temp = (regval[1] << 8) | regval[0];


Wrong solution. This affects all accesses, not just the first access after
resume. regmap_bulk_read() can fail for any reason, not just because the
system just returned from resume. The above code just assumes that the failure
is due to a bad resume based on the returned error code. That may be the case
for the i801 controller driver, but even that would be just by chance.

Guenter