mirror-linux/drivers/power/supply
Chris Morgan 40b4ad4c17 power: supply: rk817: Fix low SOC bugs
[ Upstream commit baba1315a7 ]

When the SOC approaches zero, an integer overflows in the columb
counter causing the driver to react poorly. This makes the driver
think it's at (above) the fully charged capacity when in fact it's
zero. It would then write this full capacity to NVRAM which would be
used on boot if the device remained off for less than 5 hours and
not plugged in.

This can be fixed and guarded against by doing the following:
 - Changing the type of tmp in rk817_read_or_set_full_charge_on_boot()
   to be an int instead of a u32. That way we can account for negative
   numbers.
 - Guard against negative values for the full charge on boot by setting
   the charge to 0 if the system charge reports less than 0.
 - Catch scenarios where the battery voltage is below the design
   minimum voltage and set the system SOC to 0 at that time and update
   the columb counter with a charge level of 0.
 - Change the off time value from 5 hours to 30 minutes before we
   recalculate the current capacity based on the OCV tables.

These changes allow the driver to operate better at low voltage/low
capacity conditions.

Fixes: 3268a4d9b0 ("power: supply: rk817: Fix unsigned comparison with less than zero")
Fixes: 11cb8da018 ("power: supply: Add charger driver for Rockchip RK817")
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-11 23:03:34 +09:00
..
88pm860x_battery.c
88pm860x_charger.c
Kconfig power supply and reset changes for the v6.1 series 2022-10-07 11:48:30 -07:00
Makefile power supply and reset changes for the v6.1 series 2022-10-07 11:48:30 -07:00
ab8500-bm.h power: supply: ab8500: Standardize BTI resistance 2022-02-28 11:34:31 +01:00
ab8500-chargalg.h power: supply: ab8500: Drop external charger leftovers 2022-07-17 00:51:35 +02:00
ab8500_bmdata.c power: supply: ab8500: Standardize BTI resistance 2022-02-28 11:34:31 +01:00
ab8500_btemp.c power: supply: ab8500: Defer thermal zone probe 2022-11-01 01:00:32 +01:00
ab8500_chargalg.c power: supply: ab8500: remove unused static local variable 2022-10-05 23:47:04 +02:00
ab8500_charger.c power: supply: ab8500: Fix error handling in ab8500_charger_init() 2022-12-31 13:32:45 +01:00
ab8500_fg.c power supply and reset changes for the v6.0 series 2022-08-12 09:37:33 -07:00
acer_a500_battery.c
act8945a_charger.c
adp5061.c power: supply: adp5061: show unknown capacity_level as text 2022-09-11 12:19:28 +02:00
apm_power.c
axp20x_ac_power.c power: supply: axp20x_ac_power: fix platform_get_irq.cocci warning 2022-03-04 22:20:32 +01:00
axp20x_battery.c power: supply: axp20x_battery: properly report current when discharging 2022-02-01 11:18:47 +01:00
axp20x_usb_power.c power: supply: axp20x_usb_power: fix platform_get_irq.cocci warnings 2022-03-04 22:20:32 +01:00
axp288_charger.c extcon: Fix extcon_get_extcon_dev() error handling 2022-05-13 17:03:40 +09:00
axp288_fuel_gauge.c power: supply: axp288_fuel_gauge: Added check for negative values 2023-04-20 12:35:10 +02:00
bd99954-charger.c power: supply_core: Pass pointer to battery info 2022-01-03 18:53:10 +01:00
bd99954-charger.h
bq27xxx_battery.c power: supply: bq27xxx: fix NULL vs 0 warnings 2022-09-11 15:04:59 +02:00
bq27xxx_battery_hdq.c
bq27xxx_battery_i2c.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
bq256xx_charger.c power: supply: bq256xx: Handle OOM correctly 2022-02-11 21:19:51 +01:00
bq2415x_charger.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
bq2515x_charger.c power: supply_core: Pass pointer to battery info 2022-01-03 18:53:10 +01:00
bq24190_charger.c power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition 2023-03-30 12:49:01 +02:00
bq24257_charger.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
bq24735-charger.c power: supply: bq24735: reorganize ChargeOption command macros 2021-08-13 18:38:17 +02:00
bq25890_charger.c power: supply: bq25890: Ensure pump_express_work is cancelled on remove 2022-12-31 13:32:45 +01:00
bq25980_charger.c power: supply: bq25980: Implements POWER_SUPPLY_CHARGE_TYPE_BYPASS 2022-02-24 12:09:20 +01:00
bq25980_charger.h
charger-manager.c extcon: Fix extcon_get_extcon_dev() error handling 2022-05-13 17:03:40 +09:00
collie_battery.c
cpcap-battery.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_320.RULE 2022-06-10 14:51:36 +02:00
cpcap-charger.c power: supply: cpcap-charger: fix repeated words in comments 2022-09-11 10:52:05 +02:00
cros_peripheral_charger.c power: supply: cros_peripheral: Use struct_size() helper in kzalloc() 2022-06-09 22:03:27 +02:00
cros_usbpd-charger.c power: supply: cros_usbpd: reclassify "default case!" as debug 2023-04-20 12:35:10 +02:00
cw2015_battery.c power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe() 2022-12-31 13:32:44 +01:00
da9030_battery.c
da9052-battery.c
da9150-charger.c power: supply: da9150: Fix use after free bug in da9150_charger_remove due to race condition 2023-03-30 12:49:01 +02:00
da9150-fg.c power: supply: da9150-fg: Remove unnecessary print function dev_err() 2022-03-04 22:20:33 +01:00
ds2760_battery.c
ds2780_battery.c
ds2781_battery.c
ds2782_battery.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
generic-adc-battery.c power: supply: generic-adc-battery: fix unit scaling 2023-05-11 23:03:33 +09:00
goldfish_battery.c power: supply: Remove unnecessary print function dev_err() 2022-06-09 20:27:21 +02:00
gpio-charger.c
ingenic-battery.c power: supply_core: Pass pointer to battery info 2022-01-03 18:53:10 +01:00
ip5xxx_power.c power: supply: ip5xxx: Fix integer overflow in current_now calculation 2022-11-01 00:02:36 +01:00
ipaq_micro_battery.c
isp1704_charger.c
lego_ev3_battery.c
lp8727_charger.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
lp8788-charger.c power: supply: lp8788: fix typo in comment 2022-06-09 20:02:56 +02:00
lt3651-charger.c
ltc2941-battery-gauge.c power: supply: ltc2941: clean up error messages 2022-02-13 22:21:42 +01:00
ltc4162-l-charger.c
max1721x_battery.c power: supply: max1721x: Fix spelling mistake "Gauage" -> "Gauge" 2022-10-01 21:10:07 +02:00
max8903_charger.c
max8925_power.c
max8997_charger.c extcon: Fix extcon_get_extcon_dev() error handling 2022-05-13 17:03:40 +09:00
max8998_charger.c
max14577_charger.c
max14656_charger_detector.c power: supply: max14656: Use devm_work_autocancel() 2022-02-24 12:19:20 +01:00
max17040_battery.c power: supply: max17040: fix null-ptr-deref in max17040_probe() 2021-10-12 17:18:46 +02:00
max17042_battery.c power: supply: max17042_battery: Use devm_work_autocancel() 2022-02-24 12:00:14 +01:00
max77650-charger.c
max77693_charger.c
max77976_charger.c power: supply: max77976: update Luca Ceresoli's e-mail address 2022-06-09 19:27:14 +02:00
mp2629_charger.c power: supply: mp2629_charger: use platform_get_irq() 2022-02-01 10:32:35 +01:00
mt6360_charger.c power: supply: mt6360_charger: add MT6360 charger support 2021-08-13 18:37:49 +02:00
mt6370-charger.c power: supply: mt6370: Fix return value check in mt6370_chg_probe() 2022-10-01 22:17:45 +02:00
olpc_battery.c power: supply: olpc_battery: Hold the reference returned by of_find_compatible_node 2022-07-17 01:05:54 +02:00
pcf50633-charger.c
pda_power.c
pmu_battery.c
power_supply.h
power_supply_core.c power: supply: remove faulty cooling logic 2023-03-10 09:33:36 +01:00
power_supply_hwmon.c power: supply: core: Simplify hwmon memory allocation 2022-02-11 19:45:52 +01:00
power_supply_leds.c
power_supply_sysfs.c power: supply: Fix repeated word in comments 2022-09-11 14:11:53 +02:00
qcom_smbb.c power: supply: qcom_smbb: support pm8226 2021-11-30 11:34:27 +01:00
rk817_charger.c power: supply: rk817: Fix low SOC bugs 2023-05-11 23:03:34 +09:00
rn5t618_power.c power: supply: rn5t618: Add voltage_now property 2021-08-13 18:38:17 +02:00
rt5033_battery.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
rt9455_charger.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
rx51_battery.c
s3c_adc_battery.c
samsung-sdi-battery.c power: supply: samsung-sdi-battery: Add missing charge restart voltages 2022-04-13 12:05:22 +02:00
samsung-sdi-battery.h power: supply: Static data for Samsung batteries 2022-03-04 22:20:18 +01:00
sbs-battery.c power: supply: sbs-battery: add support for time_to_empty_now attribute 2021-08-06 23:48:51 +02:00
sbs-charger.c power: supply: sbs-charger: Don't cancel work that is not initialized 2022-02-24 12:16:21 +01:00
sbs-manager.c
sc27xx_fuel_gauge.c power: supply_core: Pass pointer to battery info 2022-01-03 18:53:10 +01:00
sc2731_charger.c power: supply_core: Pass pointer to battery info 2022-01-03 18:53:10 +01:00
smb347-charger.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
surface_battery.c power/supply: surface_battery: Use client device wrappers for notifier registration 2022-06-13 17:25:08 +02:00
surface_charger.c power/supply: surface_charger: Use client device wrappers for notifier registration 2022-06-13 17:25:08 +02:00
test_power.c
tosa_battery.c ARM/pxa/mfd/power/sound: Switch Tosa to GPIO descriptors 2022-05-07 22:55:33 +02:00
tps65090-charger.c
tps65217_charger.c power: supply: tps65217: Fix comments typo 2022-09-11 12:09:10 +02:00
twl4030_charger.c
twl4030_madc_battery.c
ucs1002_power.c
ug3105_battery.c power: supply: ug3105_battery: Add driver for uPI uG3105 battery monitor 2022-02-11 19:08:35 +01:00
wilco-charger.c
wm97xx_battery.c
wm831x_backup.c
wm831x_power.c power: supply: wm831x_power: fix spelling mistake on function name 2021-10-02 17:31:15 +02:00
wm8350_power.c power: supply: wm8350-power: Add missing free in free_charger_irq 2022-03-04 22:20:32 +01:00
z2_battery.c power: supply: z2_battery: Fix possible memleak in z2_batt_probe() 2022-12-31 13:32:44 +01:00