Verified Commit 3e747399 authored by Sebastian Krzyszkowiak's avatar Sebastian Krzyszkowiak
Browse files

power: supply: max17042_battery: Prevent int underflow in set_soc_threshold

Fixes: e5f3872d

 ("max17042: Add support for signalling change in SOC")
Signed-off-by: Sebastian Krzyszkowiak's avatarSebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>
parent 0b8b7587
Pipeline #71090 passed with stage
in 67 minutes and 42 seconds
...@@ -886,7 +886,8 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off) ...@@ -886,7 +886,8 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off)
regmap_read(map, MAX17042_RepSOC, &soc); regmap_read(map, MAX17042_RepSOC, &soc);
soc >>= 8; soc >>= 8;
soc_tr = (soc + off) << 8; soc_tr = (soc + off) << 8;
soc_tr |= (soc - off); if (off < soc)
soc_tr |= soc - off;
regmap_write(map, MAX17042_SALRT_Th, soc_tr); regmap_write(map, MAX17042_SALRT_Th, soc_tr);
} }
......
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