ACPI / bus: Do not call _STA on battery devices with unmet dependencies

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/54ddce7062242036402242242c07c60c0b505f84
Commit:     54ddce7062242036402242242c07c60c0b505f84
Parent:     b0fd6772cfe10cd1edd65a376522e430e5f1bc58
Refname:    refs/heads/master
Author:     Hans de Goede <[email protected]>
AuthorDate: Fri Jan 26 16:02:58 2018 +0100
Committer:  Rafael J. Wysocki <[email protected]>
CommitDate: Sun Feb 4 09:11:56 2018 +0100

    ACPI / bus: Do not call _STA on battery devices with unmet dependencies
    
    The battery code uses acpi_device->dep_unmet to check for unmet deps and
    if there are unmet deps it does not bind to the device to avoid errors
    about missing OpRegions when calling ACPI methods on the device.
    
    The missing OpRegions when there are unmet deps problem also applies to
    the _STA method of some battery devices and calling it too early results
    in errors like these:
    
    [    0.123579] ACPI Error: No handler for Region [ECRM] (00000000ba9edc4c)
                   [GenericSerialBus] (20170831/evregion-166)
    [    0.123601] ACPI Error: Region GenericSerialBus (ID=9) has no handler
                   (20170831/exfldio-299)
    [    0.123618] ACPI Error: Method parse/execution failed
                   \_SB.I2C1.BAT1._STA, AE_NOT_EXIST (20170831/psparse-550)
    
    This commit fixes these errors happening when acpi_get_bus_status gets
    called by checking dep_unmet for battery devices and reporting a status
    of 0 until all dependencies are met.
    
    Signed-off-by: Hans de Goede <[email protected]>
    Signed-off-by: Rafael J. Wysocki <[email protected]>
---
 drivers/acpi/bus.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index d44d2c287b91..433bb5a3f327 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -120,6 +120,12 @@ int acpi_bus_get_status(struct acpi_device *device)
 		return 0;
 	}
 
+	/* Battery devices must have their deps met before calling _STA */
+	if (acpi_device_is_battery(device) && device->dep_unmet) {
+		acpi_set_device_status(device, 0);
+		return 0;
+	}
+
 	status = acpi_bus_get_status_handle(device->handle, &sta);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.