-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make mutex acquires return uacpi_status and get rid of related macros
This allows us to get rid of constructs like: if (uacpi_unlikely(!uacpi_kernel_mutex_acquire(mtx, 0xFFFF)) return UACPI_STATUS_INTERNAL_ERROR; ...by letting the host indicate internal errors on its own. This also feels cleaner as all other fallible API returns uacpi_status. Signed-off-by: Daniil Tatianin <99danilt@gmail.com>
- Loading branch information
1 parent
8d7af98
commit 8700432
Showing
8 changed files
with
149 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,51 @@ | ||
#pragma once | ||
|
||
#include <uacpi/types.h> | ||
#include <uacpi/kernel_api.h> | ||
|
||
uacpi_bool uacpi_this_thread_owns_aml_mutex(uacpi_mutex*); | ||
|
||
uacpi_bool uacpi_acquire_aml_mutex(uacpi_mutex*, uacpi_u16 timeout); | ||
void uacpi_release_aml_mutex(uacpi_mutex*); | ||
uacpi_status uacpi_acquire_aml_mutex(uacpi_mutex*, uacpi_u16 timeout); | ||
uacpi_status uacpi_release_aml_mutex(uacpi_mutex*); | ||
|
||
static inline uacpi_status uacpi_acquire_native_mutex(uacpi_handle mtx) | ||
{ | ||
if (uacpi_unlikely(mtx == UACPI_NULL)) | ||
return UACPI_STATUS_INVALID_ARGUMENT; | ||
|
||
return uacpi_kernel_acquire_mutex(mtx, 0xFFFF); | ||
} | ||
|
||
uacpi_status uacpi_acquire_native_mutex_with_timeout( | ||
uacpi_handle mtx, uacpi_u16 timeout | ||
); | ||
|
||
static inline uacpi_status uacpi_release_native_mutex(uacpi_handle mtx) | ||
{ | ||
if (uacpi_unlikely(mtx == UACPI_NULL)) | ||
return UACPI_STATUS_INVALID_ARGUMENT; | ||
|
||
uacpi_kernel_release_mutex(mtx); | ||
return UACPI_STATUS_OK; | ||
} | ||
|
||
static inline uacpi_status uacpi_acquire_native_mutex_may_be_null( | ||
uacpi_handle mtx | ||
) | ||
{ | ||
if (mtx == UACPI_NULL) | ||
return UACPI_STATUS_OK; | ||
|
||
return uacpi_kernel_acquire_mutex(mtx, 0xFFFF); | ||
} | ||
|
||
static inline uacpi_status uacpi_release_native_mutex_may_be_null( | ||
uacpi_handle mtx | ||
) | ||
{ | ||
if (mtx == UACPI_NULL) | ||
return UACPI_STATUS_OK; | ||
|
||
uacpi_kernel_release_mutex(mtx); | ||
return UACPI_STATUS_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.