linux/drivers/power/supply
Mario Limonciello 2d9144c0ca power: supply: Fix logic checking if system is running from battery
[ Upstream commit 95339f40a8 ]

The logic used for power_supply_is_system_supplied() counts all power
supplies and assumes that the system is running from AC if there is
either a non-battery power-supply reporting to be online or if no
power-supplies exist at all.

The second rule is for desktop systems, that don't have any
battery/charger devices. These systems will incorrectly report to be
powered from battery once a device scope power-supply is registered
(e.g. a HID device), since these power-supplies increase the counter.

Apart from HID devices, recent dGPUs provide UCSI power supplies on a
desktop systems. The dGPU by default doesn't have anything plugged in so
it's 'offline'. This makes power_supply_is_system_supplied() return 0
with a count of 1 meaning all drivers that use this get a wrong judgement.

To fix this case adjust the logic to also examine the scope of the power
supply. If the power supply is deemed a device power supply, then don't
count it.

Cc: Evan Quan <Evan.Quan@amd.com>
Suggested-by: Lijo Lazar <Lijo.Lazar@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-06-21 16:00:52 +02:00
..
88pm860x_battery.c
88pm860x_charger.c
ab8500_bmdata.c power: supply: ab8500: Standardize BTI resistance 2022-02-28 11:34:31 +01:00
ab8500_btemp.c power: supply: ab8500: Fix external_power_changed race 2023-06-21 16:00:51 +02: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: ab8500: Fix external_power_changed race 2023-06-21 16:00:51 +02: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
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
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: Fix external_power_changed race 2023-05-30 14:03:18 +01:00
bd99954-charger.c
bd99954-charger.h
bq27xxx_battery_hdq.c
bq27xxx_battery_i2c.c power: supply: bq27xxx: Fix I2C IRQ race on remove 2023-05-30 14:03:21 +01:00
bq27xxx_battery.c power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() 2023-06-21 16:00:52 +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
bq24190_charger.c power: supply: bq24190: Call power_supply_changed() after updating input current 2023-05-30 14:03:22 +01:00
bq24257_charger.c i2c: Make remove callback return void 2022-08-16 12:46:26 +02:00
bq24735-charger.c
bq25890_charger.c power: supply: bq25890: Call power_supply_changed() after updating input current or voltage 2023-05-30 14:03:21 +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
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
Kconfig power supply and reset changes for the v6.1 series 2022-10-07 11:48:30 -07:00
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
Makefile power supply and reset changes for the v6.1 series 2022-10-07 11:48:30 -07:00
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
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
mt6360_charger.c power: supply: mt6360: add a check of devm_work_autocancel in mt6360_charger_probe 2023-05-30 14:03:21 +01: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_core.c power: supply: Fix logic checking if system is running from battery 2023-06-21 16:00:52 +02: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: leds: Fix blink to LED on transition 2023-05-30 14:03:21 +01:00
power_supply_sysfs.c power: supply: Ratelimit no data debug output 2023-06-21 16:00:52 +02:00
power_supply.h
qcom_smbb.c
rk817_charger.c power: supply: rk817: Fix low SOC bugs 2023-05-11 23:03:34 +09:00
rn5t618_power.c
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
sbs-charger.c power: supply: sbs-charger: Fix INHIBITED bit for Status reg 2023-05-30 14:03:22 +01:00
sbs-manager.c
sc27xx_fuel_gauge.c power: supply: sc27xx: Fix external_power_changed race 2023-06-21 16:00:51 +02:00
sc2731_charger.c
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
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