Skip to content

Commit 8345775

Browse files
JordanYatesnashif
authored andcommitted
fuel_gauge: sbs_gauge: fix negative currents
Fix negative currents being read as extremely high currents due to unsigned variable use. Signed-off-by: Jordan Yates <[email protected]>
1 parent 9c3482b commit 8345775

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/fuel_gauge/sbs_gauge/sbs_gauge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static int sbs_gauge_get_prop(const struct device *dev, fuel_gauge_prop_t prop,
8383
break;
8484
case FUEL_GAUGE_CURRENT:
8585
rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_CURRENT, &tmp_val);
86-
val->current = tmp_val * 1000;
86+
val->current = (int16_t)tmp_val * 1000;
8787
break;
8888
case FUEL_GAUGE_FULL_CHARGE_CAPACITY:
8989
rc = sbs_cmd_reg_read(dev, SBS_GAUGE_CMD_FULL_CAPACITY, &tmp_val);

0 commit comments

Comments
 (0)