alistair23-linux/drivers/acpi
Hans de Goede 19fffc8450 ACPI / battery: Add handling for devices which wrongly report discharging state
On quite a few devices the battery code in the ACPI tables is buggy and
first checks the charging status bits of the charger-IC, and if those
report not charging it will report discharging, without looking at the
presence of AC power or at the battery dis(charge) current from the
fuel-gauge.

This causes the wrong status to be reported for the battery in the
following quite common scenario:

1) Plug in charger while battery is say half full, battery starts
charging, charging state bits indicate: pre-charge or fast-charge,
ACPI reported battery status is ok

2) When fully charged charging state bits indicate: end-of-charge,
ACPI reported battery status is ok

3) unplug the charger, wait 1 minute, replug. Now the battery voltage is
still above the start-charging threshold, so the charger will not start
charging to avoid wrecking the battery by repeatedly recharging the last 1%
capacity. The charger IC charging state bits now are all 0 (not-charging)
and the broken ACPI code wrongly translate this to "discharging" and ends
up setting the ACPI_BATTERY_STATE_DISCHARGING bit in its state field.

Reporting this "not charging" state as discharging is confusing for users,
making the user think his adapter/power-brick is broken or not properly
plugged in.

This commit adds a helper for handling the ACPI_BATTERY_STATE_DISCHARGING
state. This helper checks if we're an AC and the current going out of the
battery is 0 and in that case reports a status of "not charging" to
userspace rather then "discharging".

This replaces commit c68f0676ef ("ACPI / battery: Add quirk for Asus
GL502VSK and UX305LA"), a previous fix for this which was reverted.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Daniel Drake <drake@endlessm.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2018-05-02 13:06:59 +02:00
..
acpica ACPICA: Cleanup/simplify module-level code support 2018-03-18 19:29:46 +01:00
apei Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2018-01-30 14:18:52 -08:00
arm64 IOMMU Updates for Linux v4.17 2018-04-11 18:50:41 -07:00
dptf License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfit libnvdimm for 4.17 2018-04-10 10:25:57 -07:00
pmic ACPI / PMIC: Replace license boilerplate with SPDX license identifier 2018-02-22 23:14:58 +01:00
x86 ACPI / x86: Extend KIOX000A quirk to cover all affected BIOS versions 2017-10-21 13:24:53 +02:00
ac.c ACPI / AC: Remove initializer for unused ident dmi_system_id 2018-05-02 13:06:59 +02:00
acpi_amba.c
acpi_apd.c ACPI / APD: Add clock frequency for ThunderX2 I2C controller 2017-10-17 23:52:54 +02:00
acpi_cmos_rtc.c
acpi_configfs.c ACPI: configfs: make config_item_type const 2017-10-19 16:15:29 +02:00
acpi_dbg.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
acpi_extlog.c
acpi_ipmi.c
acpi_lpat.c ACPI / lpat: Fix typos in comments and kerneldoc style 2017-07-24 22:52:00 +02:00
acpi_lpit.c ACPI / LPIT: Export lpit_read_residency_count_address() 2018-02-04 15:55:52 +02:00
acpi_lpss.c ACPI / LPSS: Do not instiate platform_dev for devs without MMIO resources 2018-01-15 17:45:25 +01:00
acpi_memhotplug.c
acpi_pad.c ACPI: acpi_pad: Fix memory leak in power saving threads 2018-03-30 12:04:58 +02:00
acpi_platform.c
acpi_pnp.c
acpi_processor.c ACPI: Mark expected switch fall-throughs 2017-11-09 00:55:16 +01:00
acpi_tad.c ACPI: Add Time and Alarm Device (TAD) driver 2018-03-20 10:36:04 +01:00
acpi_video.c ACPI / video: Only default only_lcd to true on Win8-ready _desktops_ 2018-04-24 22:42:35 +02:00
acpi_watchdog.c ACPI / watchdog: Prefer iTCO_wdt on Lenovo Z50-70 2018-04-24 11:12:59 +02:00
battery.c ACPI / battery: Add handling for devices which wrongly report discharging state 2018-05-02 13:06:59 +02:00
bgrt.c ACPI: BGRT: constify attribute_group structures 2017-07-04 22:15:20 +02:00
blacklist.c dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
bus.c ACPICA: Rename a global for clarity, no functional change 2018-03-18 18:52:00 +01:00
button.c ACPI / button: make module loadable when booted in non-ACPI mode 2018-04-24 12:47:34 +02:00
cm_sbs.c
container.c
cppc_acpi.c ACPI / CPPC: Update all pr_(debug/err) messages to log the susbspace id 2018-02-22 22:54:00 +01:00
custom_method.c treewide: Align function definition open/close braces 2018-03-26 11:13:09 +02:00
debugfs.c
device_pm.c ACPI / PM: Allow deeper wakeup power states with no _SxD nor _SxW 2018-03-20 10:27:09 +01:00
device_sysfs.c treewide: Use DEVICE_ATTR_RO 2018-01-09 16:34:34 +01:00
dock.c ACPI: Mark expected switch fall-throughs 2017-11-09 00:55:16 +01:00
ec.c ACPI / EC: Restore polling during noirq suspend/resume phases 2018-02-12 10:29:31 +01:00
ec_sys.c ACPI: EC: Fix debugfs_create_*() usage 2018-01-04 13:54:51 +01:00
event.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
evged.c ACPI: GED: unregister interrupts during shutdown 2017-12-16 03:05:37 +01:00
fan.c treewide: Align function definition open/close braces 2018-03-26 11:13:09 +02:00
glue.c
hed.c
internal.h ACPI: EC: Fix debugfs_create_*() usage 2018-01-04 13:54:51 +01:00
ioapic.c
irq.c ACPI / irq: Fix return code of acpi_gsi_to_irq() 2017-07-12 13:11:49 +02:00
Kconfig Merge branches 'acpi-osi', 'acpi-scan', 'acpi-tad', 'acpi-video' and 'acpi-misc' 2018-04-02 10:59:01 +02:00
Makefile ACPI: Add Time and Alarm Device (TAD) driver 2018-03-20 10:36:04 +01:00
numa.c acpi, numa: fix pxm to online numa node associations 2018-03-15 19:49:14 -07:00
nvs.c
osi.c ACPI / OSI: Add OEM _OSI strings to disable NVidia RTD3 2018-03-18 23:42:33 +01:00
osl.c acpi: Introduce acpi_arch_get_root_pointer() for getting rsdp address 2018-02-26 08:43:20 +01:00
pci_irq.c
pci_link.c ACPI / PCI: pci_link: Allow the absence of _PRS and change log level 2018-02-27 17:15:39 +01:00
pci_mcfg.c
pci_root.c Merge branch 'pci/portdrv' 2018-04-04 13:27:58 -05:00
pci_slot.c dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
power.c ACPI / power: constify attribute_group structures 2017-07-04 22:15:14 +02:00
proc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
processor_core.c
processor_driver.c ACPI: processor: use dev_dbg() instead of dev_warn() when CPPC probe failed 2017-07-27 01:51:06 +02:00
processor_idle.c More ACPI updates for v4.16-rc1 2018-02-09 09:44:25 -08:00
processor_pdc.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
processor_perflib.c xen/acpi: upload _PSD info for non Dom0 CPUs too 2018-03-21 08:29:13 -04:00
processor_thermal.c
processor_throttling.c
property.c device property: Constify device_get_match_data() 2018-02-12 10:41:11 +01:00
reboot.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
resource.c ACPI: Mark expected switch fall-throughs 2017-11-09 00:55:16 +01:00
sbs.c battery: Add the battery hooking API 2018-02-21 23:27:13 +01:00
sbshc.c ACPI: sbshc: remove raw pointer from printk() message 2018-02-08 09:50:08 +01:00
sbshc.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
scan.c ACPI / scan: Initialize watchdog before PNP 2018-04-23 08:56:38 +02:00
sleep.c ACPI / PM: Blacklist Low Power S0 Idle _DSM for ThinkPad X1 Tablet(2016) 2018-04-23 08:53:17 +02:00
sleep.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
spcr.c ACPI: SPCR: Mark expected switch fall-through in acpi_parse_spcr 2018-02-12 10:31:26 +01:00
sysfs.c ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs 2017-12-13 01:11:33 +01:00
tables.c ACPI: add NFIT and HMAT to the initrd override list 2018-02-22 22:46:35 +01:00
thermal.c dmi: Mark all struct dmi_system_id instances const 2017-09-14 11:59:30 +02:00
utils.c ACPI: utils: Introduce acpi_dev_get_first_match_name() 2018-01-10 00:41:43 +01:00
video_detect.c ACPI / video: Add quirk to force acpi-video backlight on Samsung 670Z5E 2018-03-20 10:38:17 +01:00
wakeup.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00