* [PATCH 0/2] mfd: gateworks-gsc: Propagate I2C write and store errors
@ 2026-11-08 7:18 shao.mingyin
2026-11-08 7:18 ` [PATCH 1/2] mfd: gateworks-gsc: Propagate I2C write errors shao.mingyin
2026-11-08 7:18 ` [PATCH 2/2] mfd: gateworks-gsc: Propagate errors from gsc_store() shao.mingyin
0 siblings, 2 replies; 3+ messages in thread
From: shao.mingyin @ 2026-11-08 7:18 UTC (permalink / raw)
To: lee, mfd; +Cc: tharvey, linux-kernel
The GSC regmap bus wraps register accesses in an I2C retry loop to work
around a chip errata, but gsc_write() throws away the result of the last
transfer. Every write through regmap therefore looks successful, and
gsc_powerdown()'s existing error checks can never fire. The powerdown
sysfs attribute has the same problem on a smaller scale: it ignores both
the argument parse error and the value returned by gsc_powerdown().
1/2 returns the last transfer result from gsc_write(), so regmap_write()
and gsc_powerdown()'s checks start to work. 2/2 returns the kstrtol()
and gsc_powerdown() errors from gsc_store() instead of reporting a
successful store; its gsc_powerdown() error path is only reachable with
1/2 applied.
The patches apply independently and can be applied in either order,
although 2/2's gsc_powerdown() error path only becomes reachable once
1/2 is in place. The read counterpart in gsc_read() is handled by a
separate patch and is not a dependency here.
Shao Mingyin (2):
mfd: gateworks-gsc: Propagate I2C write errors
mfd: gateworks-gsc: Propagate errors from gsc_store()
drivers/mfd/gateworks-gsc.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
---
base-commit: 7649ba73f9e7e1e04d0b46213e39c79ae09dd55c
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] mfd: gateworks-gsc: Propagate I2C write errors
2026-11-08 7:18 [PATCH 0/2] mfd: gateworks-gsc: Propagate I2C write and store errors shao.mingyin
@ 2026-11-08 7:18 ` shao.mingyin
2026-11-08 7:18 ` [PATCH 2/2] mfd: gateworks-gsc: Propagate errors from gsc_store() shao.mingyin
1 sibling, 0 replies; 3+ messages in thread
From: shao.mingyin @ 2026-11-08 7:18 UTC (permalink / raw)
To: lee, mfd; +Cc: tharvey, linux-kernel
From: Shao Mingyin <shao.mingyin@zte.com.cn>
gsc_write() retries the I2C transfer but then returns 0 unconditionally,
so regmap_write() and regmap_bulk_write() never report an error even when
all attempts failed. Callers such as gsc_powerdown() check the return
value, but those checks can never trigger.
Return the result of the last transfer.
Fixes: d85234994b2f ("mfd: Add Gateworks System Controller core driver")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
diff --git a/drivers/mfd/gateworks-gsc.c b/drivers/mfd/gateworks-gsc.c
index a3301502ce6a..aa2252402095 100644
--- a/drivers/mfd/gateworks-gsc.c
+++ b/drivers/mfd/gateworks-gsc.c
@@ -44,7 +44,7 @@ int gsc_write(void *context, unsigned int reg, unsigned int val)
break;
}
- return 0;
+ return ret;
}
EXPORT_SYMBOL_GPL(gsc_write);
--
2.47.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] mfd: gateworks-gsc: Propagate errors from gsc_store()
2026-11-08 7:18 [PATCH 0/2] mfd: gateworks-gsc: Propagate I2C write and store errors shao.mingyin
2026-11-08 7:18 ` [PATCH 1/2] mfd: gateworks-gsc: Propagate I2C write errors shao.mingyin
@ 2026-11-08 7:18 ` shao.mingyin
1 sibling, 0 replies; 3+ messages in thread
From: shao.mingyin @ 2026-11-08 7:18 UTC (permalink / raw)
To: lee, mfd; +Cc: tharvey, linux-kernel
From: Shao Mingyin <shao.mingyin@zte.com.cn>
gsc_store() ignores both the kstrtol() result and the value returned by
gsc_powerdown(), so an invalid argument or a failed I2C write is reported
to userspace as a successful sysfs store.
Return both errors to the caller. The gsc_powerdown() error only became
reachable with the preceding patch, which makes gsc_write() report I2C
failures.
Fixes: d85234994b2f ("mfd: Add Gateworks System Controller core driver")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
diff --git a/drivers/mfd/gateworks-gsc.c b/drivers/mfd/gateworks-gsc.c
index aa2252402095..999cf84405ba 100644
--- a/drivers/mfd/gateworks-gsc.c
+++ b/drivers/mfd/gateworks-gsc.c
@@ -125,10 +125,16 @@ static ssize_t gsc_store(struct device *dev, struct device_attribute *attr,
struct gsc_dev *gsc = dev_get_drvdata(dev);
const char *name = attr->attr.name;
long value;
+ int ret;
if (strcasecmp(name, "powerdown") == 0) {
- if (kstrtol(buf, 0, &value) == 0)
- gsc_powerdown(gsc, value);
+ ret = kstrtol(buf, 0, &value);
+ if (ret)
+ return ret;
+
+ ret = gsc_powerdown(gsc, value);
+ if (ret)
+ return ret;
} else {
dev_err(dev, "invalid command: '%s\n", name);
}
--
2.47.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-08 7:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 7:18 [PATCH 0/2] mfd: gateworks-gsc: Propagate I2C write and store errors shao.mingyin
2026-11-08 7:18 ` [PATCH 1/2] mfd: gateworks-gsc: Propagate I2C write errors shao.mingyin
2026-11-08 7:18 ` [PATCH 2/2] mfd: gateworks-gsc: Propagate errors from gsc_store() shao.mingyin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®