From: <shao.mingyin@zte.com.cn>
To: <lee@kernel.org>, <mfd@lists.linux.dev>
Cc: <tharvey@gateworks.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/2] mfd: gateworks-gsc: Propagate errors from gsc_store()
Date: Sun, 8 Nov 2026 15:18:49 +0800 (CST) [thread overview]
Message-ID: <20261108151849390eWkZBJaNgwJDsb5MuOMLo@zte.com.cn> (raw)
In-Reply-To: <20261108151842879F_ON2AUBnuh5imOx8oZ1w@zte.com.cn>
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
prev parent reply other threads:[~2026-11-08 7:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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=20261108151849390eWkZBJaNgwJDsb5MuOMLo@zte.com.cn \
--to=shao.mingyin@zte.com.cn \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=tharvey@gateworks.com \
/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
all inboxes | Powered by JetHome®