diff options
-rw-r--r-- | sys/dev/acpica/acpi_ec.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sys/dev/acpica/acpi_ec.c b/sys/dev/acpica/acpi_ec.c index 350fc86..2ba7958 100644 --- a/sys/dev/acpica/acpi_ec.c +++ b/sys/dev/acpica/acpi_ec.c @@ -312,37 +312,34 @@ EcLock(struct acpi_ec_softc *sc, int serialize) { ACPI_STATUS status; + /* If _GLK is non-zero, acquire the global lock. */ + status = AE_OK; + if (sc->ec_glk) { + status = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT, &sc->ec_glkhandle); + if (ACPI_FAILURE(status)) + return (status); + } + /* * If caller is executing a series of commands, acquire the exclusive lock * to serialize with other users. * To sync with bottom-half interrupt handler, always acquire the mutex. */ - status = AE_OK; if (serialize) ACPI_SERIAL_BEGIN(ec); mtx_lock(&sc->ec_mtx); - /* If _GLK is non-zero, also acquire the global lock. */ - if (sc->ec_glk) { - status = AcpiAcquireGlobalLock(EC_LOCK_TIMEOUT, &sc->ec_glkhandle); - if (ACPI_FAILURE(status)) { - mtx_unlock(&sc->ec_mtx); - if (serialize) - ACPI_SERIAL_END(ec); - } - } - return (status); } static __inline void EcUnlock(struct acpi_ec_softc *sc) { - if (sc->ec_glk) - AcpiReleaseGlobalLock(sc->ec_glkhandle); mtx_unlock(&sc->ec_mtx); if (sx_xlocked(&ec_sxlock)) ACPI_SERIAL_END(ec); + if (sc->ec_glk) + AcpiReleaseGlobalLock(sc->ec_glkhandle); } static uint32_t EcGpeHandler(void *Context); |