svn commit: r358534 - stable/12/sys/dev/acpica
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Mar 2 09:09:18 UTC 2020
Author: hselasky
Date: Mon Mar 2 09:09:16 2020
New Revision: 358534
URL: https://svnweb.freebsd.org/changeset/base/358534
Log:
MFC r358219 and r358270:
Make sure the ACPI lid state is updated during boot and after resume.
While at it update the sysctl(9) description for the lid state.
Always check return value from acpi_GetInteger().
If a failure happens reading the lid state, assume the lid is opened.
Differential Revision: https://reviews.freebsd.org/D23724
PR: 240881
Submitted by: Yuri Pankov <yuripv at yuripv.me>
Sponsored by: Mellanox Technologies
Modified:
stable/12/sys/dev/acpica/acpi_lid.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/dev/acpica/acpi_lid.c
==============================================================================
--- stable/12/sys/dev/acpica/acpi_lid.c Mon Mar 2 08:44:58 2020 (r358533)
+++ stable/12/sys/dev/acpica/acpi_lid.c Mon Mar 2 09:09:16 2020 (r358534)
@@ -84,6 +84,27 @@ static devclass_t acpi_lid_devclass;
DRIVER_MODULE(acpi_lid, acpi, acpi_lid_driver, acpi_lid_devclass, 0, 0);
MODULE_DEPEND(acpi_lid, acpi, 1, 1, 1);
+static void
+acpi_lid_status_update(struct acpi_lid_softc *sc)
+{
+ ACPI_STATUS status;
+ int lid_status;
+
+ ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
+
+ /*
+ * Evaluate _LID and check the return value, update lid status.
+ * Zero: The lid is closed
+ * Non-zero: The lid is open
+ */
+ status = acpi_GetInteger(sc->lid_handle, "_LID", &lid_status);
+ if (ACPI_FAILURE(status))
+ lid_status = 1; /* assume lid is opened */
+
+ /* range check value */
+ sc->lid_status = lid_status ? 1 : 0;
+}
+
static int
acpi_lid_probe(device_t dev)
{
@@ -122,13 +143,16 @@ acpi_lid_attach(device_t dev)
if (acpi_parse_prw(sc->lid_handle, &prw) == 0)
AcpiEnableGpe(prw.gpe_handle, prw.gpe_bit);
+ /* Get the initial lid status */
+ acpi_lid_status_update(sc);
+
/*
* Export the lid status
*/
SYSCTL_ADD_INT(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO,
"state", CTLFLAG_RD, &sc->lid_status, 0,
- "Device set to wake the system");
+ "Device state (0 = closed, 1 = open)");
return (0);
}
@@ -142,6 +166,13 @@ acpi_lid_suspend(device_t dev)
static int
acpi_lid_resume(device_t dev)
{
+ struct acpi_lid_softc *sc;
+
+ sc = device_get_softc(dev);
+
+ /* Update lid status, if any */
+ acpi_lid_status_update(sc);
+
return (0);
}
@@ -150,21 +181,14 @@ acpi_lid_notify_status_changed(void *arg)
{
struct acpi_lid_softc *sc;
struct acpi_softc *acpi_sc;
- ACPI_STATUS status;
ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
sc = (struct acpi_lid_softc *)arg;
ACPI_SERIAL_BEGIN(lid);
- /*
- * Evaluate _LID and check the return value, update lid status.
- * Zero: The lid is closed
- * Non-zero: The lid is open
- */
- status = acpi_GetInteger(sc->lid_handle, "_LID", &sc->lid_status);
- if (ACPI_FAILURE(status))
- goto out;
+ /* Update lid status, if any */
+ acpi_lid_status_update(sc);
acpi_sc = acpi_device_get_parent_softc(sc->lid_dev);
if (acpi_sc == NULL)
More information about the svn-src-all
mailing list