]> Git Repo - J-linux.git/commitdiff
power: supply: cros_charge-control: Fix signedness bug in charge_behaviour_store()
authorDan Carpenter <[email protected]>
Thu, 4 Jul 2024 15:20:03 +0000 (10:20 -0500)
committerTzung-Bi Shih <[email protected]>
Fri, 5 Jul 2024 01:51:33 +0000 (01:51 +0000)
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 <[email protected]>
Acked-by: Thomas Weißschuh <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Tzung-Bi Shih <[email protected]>
drivers/power/supply/cros_charge-control.c

index 2dd8ddbd56bc09d380490b3bf2352dcfe92936ce..17c53591ce197d08d97c94d3d4359a282026dd7d 100644 (file)
@@ -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)
This page took 0.04588 seconds and 4 git commands to generate.