From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: "Thomas Weißschuh" <thomas@weissschuh.net>,
"Benson Leung" <bleung@chromium.org>,
"Guenter Roeck" <groeck@chromium.org>,
"Sebastian Reichel" <sre@kernel.org>,
"Tzung-Bi Shih" <tzungbi@kernel.org>,
chrome-platform@lists.linux.dev, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] power: supply: cros_charge-control: Fix signedness bug in charge_behaviour_store()
Date: Thu, 4 Jul 2024 10:20:03 -0500 [thread overview]
Message-ID: <ZoWKEs4mCqeLyTOB@stanley.mountain> (raw)
The C standard is vague about the signedness of enums, but in this case
here, they are treated as unsigned so the error handling does not work.
Use an int type to fix this.
Fixes: c6ed48ef5259 ("power: supply: add ChromeOS EC based charge control driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/power/supply/cros_charge-control.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/power/supply/cros_charge-control.c b/drivers/power/supply/cros_charge-control.c
index 73d7f2dc0fa3..3183a13eefd0 100644
--- a/drivers/power/supply/cros_charge-control.c
+++ b/drivers/power/supply/cros_charge-control.c
@@ -204,14 +204,13 @@ static ssize_t charge_behaviour_store(struct device *dev, struct device_attribut
{
struct cros_chctl_priv *priv = cros_chctl_attr_to_priv(&attr->attr,
CROS_CHCTL_ATTR_CHARGE_BEHAVIOUR);
- enum power_supply_charge_behaviour behaviour;
int ret;
- behaviour = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
- if (behaviour < 0)
- return behaviour;
+ ret = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
+ if (ret < 0)
+ return ret;
- priv->current_behaviour = behaviour;
+ priv->current_behaviour = ret;
ret = cros_chctl_configure_ec(priv);
if (ret < 0)
--
2.43.0
next reply other threads:[~2024-07-04 15:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 15:20 Dan Carpenter [this message]
2024-07-04 18:16 ` [PATCH] power: supply: cros_charge-control: Fix signedness bug in charge_behaviour_store() Thomas Weißschuh
2024-07-05 1:55 ` Tzung-Bi Shih
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=ZoWKEs4mCqeLyTOB@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=sre@kernel.org \
--cc=thomas@weissschuh.net \
--cc=tzungbi@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).