[haiku-commits] Change in haiku[master]: acpi: Use mutex_trylock() for ACPI_DO_NOT_WAIT.

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 17 May 2020 19:33:28 +0000

From waddlesplash <waddlesplash@xxxxxxxxx>:

waddlesplash has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2730 ;)


Change subject: acpi: Use mutex_trylock() for ACPI_DO_NOT_WAIT.
......................................................................

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.
---
M src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp
1 file changed, 5 insertions(+), 3 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/30/2730/1

diff --git a/src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp 
b/src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp
index 3aad4e0..dda946e 100644
--- a/src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp
+++ b/src/add-ons/kernel/bus_managers/acpi/ACPICAHaiku.cpp
@@ -1298,9 +1298,11 @@
        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:

--
To view, visit https://review.haiku-os.org/c/haiku/+/2730
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I7891ae9138a7d45be934ac53412b82546d52b901
Gerrit-Change-Number: 2730
Gerrit-PatchSet: 1
Gerrit-Owner: waddlesplash <waddlesplash@xxxxxxxxx>
Gerrit-MessageType: newchange

Other related posts:

  • » [haiku-commits] Change in haiku[master]: acpi: Use mutex_trylock() for ACPI_DO_NOT_WAIT. - Gerrit