acpi: Use mutex_trylock() for ACPI_DO_NOT_WAIT.

We do not need to go through all the overhead of mutex_lock_with_timeout()
if there is in fact no timeout.

Change-Id: I7891ae9138a7d45be934ac53412b82546d52b901
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2730
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Augustin Cavalier
2020-05-17 19:34:02 +00:00
committed by waddlesplash
parent 97310aa7fc
commit a3a192c1cb
@@ -1298,9 +1298,11 @@ AcpiOsAcquireMutex(ACPI_MUTEX handle, UINT16 timeout)
ACPI_STATUS result = AE_OK;
DEBUG_FUNCTION_VF("mutex: %p; timeout: %u", handle, timeout);
if (timeout == ACPI_WAIT_FOREVER)
result = mutex_lock(handle) == B_OK ? AE_OK : AE_BAD_PARAMETER;
else {
if (timeout == ACPI_WAIT_FOREVER) {
result = (mutex_lock(handle) == B_OK) ? AE_OK : AE_BAD_PARAMETER;
} else if (timeout == ACPI_DO_NOT_WAIT) {
result = (mutex_trylock(handle) == B_OK) ? AE_OK : AE_TIME;
} else {
switch (mutex_lock_with_timeout(handle, B_RELATIVE_TIMEOUT,
(bigtime_t)timeout * 1000)) {
case B_OK: