diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c index c546a767e6a7..933bde657f76 100644 --- a/sys/dev/acpica/acpi.c +++ b/sys/dev/acpica/acpi.c @@ -1339,7 +1339,7 @@ acpi_DeviceIsPresent(device_t dev) ret = TRUE; /* Return true for 'present' and 'functioning' */ - if ((devinfo->CurrentStatus & 0x9) == 0x9) + if (ACPI_DEVICE_PRESENT(devinfo->CurrentStatus)) ret = TRUE; AcpiOsFree(buf.Pointer); @@ -1372,8 +1372,8 @@ acpi_BatteryIsPresent(device_t dev) if ((devinfo->Valid & ACPI_VALID_STA) == 0) ret = TRUE; - /* Return true for 'present' and 'functioning' */ - if ((devinfo->CurrentStatus & 0x19) == 0x19) + /* Return true for 'present', 'battery present', and 'functioning' */ + if (ACPI_BATTERY_PRESENT(devinfo->CurrentStatus)) ret = TRUE; AcpiOsFree(buf.Pointer); diff --git a/sys/dev/acpica/acpivar.h b/sys/dev/acpica/acpivar.h index 251a09d0e7d9..21292177d774 100644 --- a/sys/dev/acpica/acpivar.h +++ b/sys/dev/acpica/acpivar.h @@ -222,7 +222,21 @@ void acpi_EnterDebugger(void); device_printf(dev, x); \ } while (0) -#define ACPI_DEVINFO_PRESENT(x) (((x) & 0x9) == 9) +/* Values for the device _STA (status) method. */ +#define ACPI_STA_PRESENT (1 << 0) +#define ACPI_STA_ENABLED (1 << 1) +#define ACPI_STA_SHOW_IN_UI (1 << 2) +#define ACPI_STA_FUNCTIONAL (1 << 3) +#define ACPI_STA_BATT_PRESENT (1 << 4) + +#define ACPI_DEVINFO_PRESENT(x, flags) \ + (((x) & (flags)) == (flags)) +#define ACPI_DEVICE_PRESENT(x) \ + ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL) +#define ACPI_BATTERY_PRESENT(x) \ + ACPI_DEVINFO_PRESENT(x, ACPI_STA_PRESENT | ACPI_STA_FUNCTIONAL | \ + ACPI_STA_BATT_PRESENT) + BOOLEAN acpi_DeviceIsPresent(device_t dev); BOOLEAN acpi_BatteryIsPresent(device_t dev); ACPI_STATUS acpi_GetHandleInScope(ACPI_HANDLE parent, char *path,