WSL2-Linux-Kernel/drivers/power/supply
Mario Limonciello 9df872ec4a 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 15:59:13 +02:00
..
88pm860x_battery.c
88pm860x_charger.c
Kconfig
Makefile
ab8500-bm.h
ab8500-chargalg.h
ab8500_bmdata.c
ab8500_btemp.c power: supply: ab8500: Fix external_power_changed race 2023-06-21 15:59:12 +02:00
ab8500_chargalg.c
ab8500_charger.c power: supply: ab8500: Fix error handling in ab8500_charger_init() 2022-12-31 13:14:32 +01:00
ab8500_fg.c power: supply: ab8500: Fix external_power_changed race 2023-06-21 15:59:12 +02:00
acer_a500_battery.c
act8945a_charger.c
adp5061.c
apm_power.c
axp20x_ac_power.c
axp20x_battery.c
axp20x_usb_power.c
axp288_charger.c
axp288_fuel_gauge.c
bd99954-charger.c
bd99954-charger.h
bq27xxx_battery.c power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() 2023-06-21 15:59:12 +02:00
bq27xxx_battery_hdq.c
bq27xxx_battery_i2c.c power: supply: bq27xxx: Fix I2C IRQ race on remove 2023-05-30 13:55:32 +01:00
bq256xx_charger.c
bq2415x_charger.c
bq2515x_charger.c
bq24190_charger.c power: supply: bq24190: Call power_supply_changed() after updating input current 2023-06-05 09:21:13 +02:00
bq24257_charger.c
bq24735-charger.c
bq25890_charger.c
bq25980_charger.c
bq25980_charger.h
charger-manager.c
collie_battery.c
cpcap-battery.c
cpcap-charger.c
cros_peripheral_charger.c
cros_usbpd-charger.c power: supply: cros_usbpd: reclassify "default case!" as debug 2023-04-20 12:13:54 +02:00
cw2015_battery.c
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:47:43 +02:00
da9150-fg.c
ds2760_battery.c
ds2780_battery.c
ds2781_battery.c
ds2782_battery.c
generic-adc-battery.c power: supply: generic-adc-battery: fix unit scaling 2023-05-11 23:00:36 +09:00
goldfish_battery.c
gpio-charger.c
ingenic-battery.c
ipaq_micro_battery.c
isp1704_charger.c
lego_ev3_battery.c
lp8727_charger.c
lp8788-charger.c
lt3651-charger.c
ltc2941-battery-gauge.c
ltc4162-l-charger.c
max1721x_battery.c
max8903_charger.c
max8925_power.c
max8997_charger.c
max8998_charger.c
max14577_charger.c
max14656_charger_detector.c
max17040_battery.c
max17042_battery.c
max77650-charger.c
max77693_charger.c
mp2629_charger.c
mt6360_charger.c power: supply: mt6360: add a check of devm_work_autocancel in mt6360_charger_probe 2023-05-30 13:55:32 +01:00
olpc_battery.c
pcf50633-charger.c
pda_power.c
pm2301_charger.h
pmu_battery.c
power_supply.h
power_supply_core.c power: supply: Fix logic checking if system is running from battery 2023-06-21 15:59:13 +02:00
power_supply_hwmon.c
power_supply_leds.c power: supply: leds: Fix blink to LED on transition 2023-05-30 13:55:32 +01:00
power_supply_sysfs.c power: supply: Ratelimit no data debug output 2023-06-21 15:59:12 +02:00
qcom_smbb.c
rn5t618_power.c
rt5033_battery.c
rt9455_charger.c
rx51_battery.c
s3c_adc_battery.c
sbs-battery.c
sbs-charger.c power: supply: sbs-charger: Fix INHIBITED bit for Status reg 2023-05-30 13:55:32 +01:00
sbs-manager.c
sc27xx_fuel_gauge.c power: supply: sc27xx: Fix external_power_changed race 2023-06-21 15:59:12 +02:00
sc2731_charger.c
smb347-charger.c
surface_battery.c
surface_charger.c
test_power.c
tosa_battery.c
tps65090-charger.c
tps65217_charger.c
twl4030_charger.c
twl4030_madc_battery.c
ucs1002_power.c
wilco-charger.c
wm97xx_battery.c
wm831x_backup.c
wm831x_power.c
wm8350_power.c
z2_battery.c