linux/drivers/power/supply
Mario Limonciello 95339f40a8 power: supply: Fix logic checking if system is running from battery
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>
2023-05-16 23:02:56 +02:00
..
88pm860x_battery.c power: supply: 88pm860x_battery: Remove unnecessary int for long long 2021-04-02 14:14:58 +02:00
88pm860x_charger.c power: supply: 88pm860x: simplify using devm 2022-11-17 23:47:23 +01:00
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-05-08 15:03:50 +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-11-26 23:14:32 +01:00
ab8500_fg.c power: supply: ab8500: Fix external_power_changed race 2023-05-08 15:03:50 +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 power: supply: Add battery gauge driver for Acer Iconia Tab A500 2021-01-14 23:39:43 +01:00
act8945a_charger.c power: supply: act8945a: correct kerneldoc 2021-04-20 16:18:08 +02:00
adp5061.c power: supply: adp5061: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01: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 power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets 2023-04-01 23:01:42 +02:00
axp288_fuel_gauge.c power: supply: axp288_fuel_gauge: Fix external_power_changed race 2023-05-08 15:04:53 +02:00
bd99954-charger.c power: supply: bd99954: Use LINEAR_RANGE() 2022-11-01 01:01:50 +01:00
bd99954-charger.h
bq27xxx_battery_hdq.c power supply and reset changes for the v5.10 series 2020-10-20 10:56:34 -07:00
bq27xxx_battery_i2c.c power: supply: bq27xxx: Fix I2C IRQ race on remove 2023-05-08 15:29:11 +02:00
bq27xxx_battery.c power: supply: bq27xxx: Use mod_delayed_work() instead of cancel() + schedule() 2023-05-08 15:29:12 +02:00
bq256xx_charger.c power: supply: bq256xx: Support to disable charger 2023-03-12 23:47:54 +01:00
bq2415x_charger.c power: supply: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00
bq2515x_charger.c power: supply: bq2515x: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
bq24190_charger.c power: supply: bq24190: Call power_supply_changed() after updating input current 2023-05-08 15:29:12 +02:00
bq24257_charger.c power: supply: bq24257_charger: mark OF related data as maybe unused 2023-03-12 23:13:14 +01:00
bq24735-charger.c power: supply: bq24735: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
bq25890_charger.c power: supply: bq25890: Call power_supply_changed() after updating input current or voltage 2023-05-08 15:29:12 +02:00
bq25980_charger.c power: supply: bq25980: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
bq25980_charger.h power: supply: bq25980: Add support for the BQ259xx family 2020-10-04 01:54:35 +02:00
charger-manager.c power: supply: charger-manager: Use of_property_read_bool() for boolean properties 2023-03-12 23:33:43 +01:00
collie_battery.c power: supply: collie_battery: Convert to GPIO descriptors (part 2) 2023-02-03 13:28:59 +01:00
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-03-10 00:20:43 +01:00
cw2015_battery.c power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe() 2022-11-24 23:00:00 +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-12 23:28:04 +01: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 ARM: pxa: remove unused board files 2023-01-20 11:23:44 +01:00
ds2780_battery.c power: supply: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00
ds2781_battery.c power: supply: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00
ds2782_battery.c power: supply: ds2782: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
generic-adc-battery.c power: supply: generic-adc-battery: style fixes 2023-03-29 22:38:57 +02:00
goldfish_battery.c power: supply: Remove unnecessary print function dev_err() 2022-06-09 20:27:21 +02:00
gpio-charger.c power: supply: gpio-charger: add charge-current-limit feature 2020-08-27 21:13:23 +02:00
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
Kconfig ARM: SoC drivers for 6.3 2023-02-27 10:04:49 -08:00
lego_ev3_battery.c power: supply: lego_ev3: Simplify with dev_err_probe() 2020-08-26 17:25:45 +02:00
lp8727_charger.c power: supply: lp8727_charger: mark OF related data as maybe unused 2023-03-12 23:13:14 +01:00
lp8788-charger.c power: supply: use sysfs_emit() instead of scnprintf() for sysfs show() 2023-01-02 08:54:07 +01:00
lt3651-charger.c
ltc2941-battery-gauge.c power: supply: ltc2941: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
ltc4162-l-charger.c power: supply: ltc4162-l-charger: mark OF related data as maybe unused 2023-03-12 23:13:14 +01:00
Makefile ARM: SoC drivers for 6.3 2023-02-27 10:04:49 -08:00
max1721x_battery.c power: supply: max1721x: Use strscpy() is more robust and safer 2023-02-03 13:58:41 +01:00
max8903_charger.c power: supply: max8903: Convert to GPIO descriptors 2021-01-12 23:23:49 +01:00
max8925_power.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
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 power: supply: use sysfs_emit() instead of scnprintf() for sysfs show() 2023-01-02 08:54:07 +01:00
max14656_charger_detector.c power: supply: max14656: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
max17040_battery.c power: supply: max17040: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
max17042_battery.c power: supply: max17042_battery: Convert to i2c's .probe_new() 2022-11-20 20:12:16 +01:00
max77650-charger.c power: supply: max77650: Make max77650_charger_disable() return void 2023-02-13 21:20:39 +01:00
max77693_charger.c power: supply: use sysfs_emit() instead of scnprintf() for sysfs show() 2023-01-02 08:54:07 +01:00
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: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00
mt6360_charger.c power: supply: mt6360: add a check of devm_work_autocancel in mt6360_charger_probe 2023-05-16 00:46:53 +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: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00
pcf50633-charger.c power: supply: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00
pmu_battery.c
power_supply_core.c power: supply: Fix logic checking if system is running from battery 2023-05-16 23:02:56 +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-08 15:13:19 +02:00
power_supply_sysfs.c power: supply: Ratelimit no data debug output 2023-05-11 20:45:50 +02:00
power_supply.h driver core: make struct class.dev_uevent() take a const * 2022-11-24 17:12:15 +01:00
qcom_battmgr.c power: supply: qcom_battmgr: remove bogus do_div() 2023-03-01 10:41:18 -08: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-04-08 00:30:05 +02:00
rn5t618_power.c power: supply: rn5t618: Add voltage_now property 2021-08-13 18:38:17 +02:00
rt5033_battery.c power: supply: rt5033_battery: Convert to i2c's .probe_new() 2022-11-20 20:12:17 +01:00
rt9455_charger.c power: supply: rt9455_charger: mark OF related data as maybe unused 2023-03-12 23:13:14 +01:00
rt9467-charger.c power: supply: rt9467: Fix passing zero to 'dev_err_probe' 2023-05-15 00:51:54 +02:00
rt9471.c power: supply: rt9471: fix using wrong ce_gpio in rt9471_probe() 2023-02-13 21:28:56 +01:00
rx51_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: Fix INHIBITED bit for Status reg 2023-05-16 00:06:10 +02:00
sbs-manager.c power: supply: sbs-manager: Convert to i2c's .probe_new() 2022-11-20 20:12:17 +01:00
sc27xx_fuel_gauge.c power: supply: sc27xx: Fix external_power_changed race 2023-05-08 15:06:12 +02:00
sc2731_charger.c power: supply_core: Pass pointer to battery info 2022-01-03 18:53:10 +01:00
smb347-charger.c power: supply: smb347: Convert to i2c's .probe_new() 2022-11-20 20:12:17 +01:00
surface_battery.c platform/surface: aggregator: Enforce use of target-ID enum in device ID macros 2023-02-02 22:48:20 +01:00
surface_charger.c platform/surface: aggregator: Enforce use of target-ID enum in device ID macros 2023-02-02 22:48:20 +01:00
test_power.c power: supply: test-power: use strscpy() instead of strncpy() 2023-02-03 13:43:48 +01:00
tps65090-charger.c power: supply: Use IRQF_ONESHOT 2021-03-22 14:54:24 +01:00
tps65217_charger.c power: supply: tps65217: Fix comments typo 2022-09-11 12:09:10 +02:00
twl4030_charger.c power: supply: twl4030_charger: mark OF related data as maybe unused 2023-03-12 23:13:14 +01:00
twl4030_madc_battery.c
ucs1002_power.c power: supply: ucs1002: Convert to i2c's .probe_new() 2022-11-20 20:12:17 +01:00
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 power: supply: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:53 -07:00
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: use sysfs_emit() instead of sprintf() for sysfs show() 2023-01-02 09:13:37 +01:00