Commit 4baf1cc5 authored by Dan Carpenter's avatar Dan Carpenter Committed by Tzung-Bi Shih

power: supply: cros_charge-control: Fix signedness bug in charge_behaviour_store()

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: c6ed48ef ("power: supply: add ChromeOS EC based charge control driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Acked-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Link: https://lore.kernel.org/r/ZoWKEs4mCqeLyTOB@stanley.mountainSigned-off-by: default avatarTzung-Bi Shih <tzungbi@kernel.org>
parent c98f17fe
...@@ -204,14 +204,13 @@ static ssize_t charge_behaviour_store(struct device *dev, struct device_attribut ...@@ -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, struct cros_chctl_priv *priv = cros_chctl_attr_to_priv(&attr->attr,
CROS_CHCTL_ATTR_CHARGE_BEHAVIOUR); CROS_CHCTL_ATTR_CHARGE_BEHAVIOUR);
enum power_supply_charge_behaviour behaviour;
int ret; int ret;
behaviour = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf); ret = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
if (behaviour < 0) if (ret < 0)
return behaviour; return ret;
priv->current_behaviour = behaviour; priv->current_behaviour = ret;
ret = cros_chctl_configure_ec(priv); ret = cros_chctl_configure_ec(priv);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment