Skip to content

Commit 4baf1cc

Browse files
Dan CarpenterTzung-Bi Shih
authored andcommitted
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: c6ed48e ("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]>
1 parent c98f17f commit 4baf1cc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

drivers/power/supply/cros_charge-control.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,13 @@ static ssize_t charge_behaviour_store(struct device *dev, struct device_attribut
204204
{
205205
struct cros_chctl_priv *priv = cros_chctl_attr_to_priv(&attr->attr,
206206
CROS_CHCTL_ATTR_CHARGE_BEHAVIOUR);
207-
enum power_supply_charge_behaviour behaviour;
208207
int ret;
209208

210-
behaviour = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
211-
if (behaviour < 0)
212-
return behaviour;
209+
ret = power_supply_charge_behaviour_parse(EC_CHARGE_CONTROL_BEHAVIOURS, buf);
210+
if (ret < 0)
211+
return ret;
213212

214-
priv->current_behaviour = behaviour;
213+
priv->current_behaviour = ret;
215214

216215
ret = cros_chctl_configure_ec(priv);
217216
if (ret < 0)

0 commit comments

Comments
 (0)