Lines Matching +full:lock +full:- +full:status
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
4 * Module Name: utlock - Reader/Writer lock interfaces
6 * Copyright (C) 2000 - 2023, Intel Corp.
21 * PARAMETERS: lock - Pointer to a valid RW lock
23 * RETURN: Status
25 * DESCRIPTION: Reader/writer lock creation and deletion interfaces.
28 acpi_status acpi_ut_create_rw_lock(struct acpi_rw_lock *lock) in acpi_ut_create_rw_lock() argument
30 acpi_status status; in acpi_ut_create_rw_lock() local
32 lock->num_readers = 0; in acpi_ut_create_rw_lock()
33 status = acpi_os_create_mutex(&lock->reader_mutex); in acpi_ut_create_rw_lock()
34 if (ACPI_FAILURE(status)) { in acpi_ut_create_rw_lock()
35 return (status); in acpi_ut_create_rw_lock()
38 status = acpi_os_create_mutex(&lock->writer_mutex); in acpi_ut_create_rw_lock()
39 return (status); in acpi_ut_create_rw_lock()
42 void acpi_ut_delete_rw_lock(struct acpi_rw_lock *lock) in acpi_ut_delete_rw_lock() argument
45 acpi_os_delete_mutex(lock->reader_mutex); in acpi_ut_delete_rw_lock()
46 acpi_os_delete_mutex(lock->writer_mutex); in acpi_ut_delete_rw_lock()
48 lock->num_readers = 0; in acpi_ut_delete_rw_lock()
49 lock->reader_mutex = NULL; in acpi_ut_delete_rw_lock()
50 lock->writer_mutex = NULL; in acpi_ut_delete_rw_lock()
58 * PARAMETERS: lock - Pointer to a valid RW lock
60 * RETURN: Status
71 acpi_status acpi_ut_acquire_read_lock(struct acpi_rw_lock *lock) in acpi_ut_acquire_read_lock() argument
73 acpi_status status; in acpi_ut_acquire_read_lock() local
75 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); in acpi_ut_acquire_read_lock()
76 if (ACPI_FAILURE(status)) { in acpi_ut_acquire_read_lock()
77 return (status); in acpi_ut_acquire_read_lock()
80 /* Acquire the write lock only for the first reader */ in acpi_ut_acquire_read_lock()
82 lock->num_readers++; in acpi_ut_acquire_read_lock()
83 if (lock->num_readers == 1) { in acpi_ut_acquire_read_lock()
84 status = in acpi_ut_acquire_read_lock()
85 acpi_os_acquire_mutex(lock->writer_mutex, in acpi_ut_acquire_read_lock()
89 acpi_os_release_mutex(lock->reader_mutex); in acpi_ut_acquire_read_lock()
90 return (status); in acpi_ut_acquire_read_lock()
93 acpi_status acpi_ut_release_read_lock(struct acpi_rw_lock *lock) in acpi_ut_release_read_lock() argument
95 acpi_status status; in acpi_ut_release_read_lock() local
97 status = acpi_os_acquire_mutex(lock->reader_mutex, ACPI_WAIT_FOREVER); in acpi_ut_release_read_lock()
98 if (ACPI_FAILURE(status)) { in acpi_ut_release_read_lock()
99 return (status); in acpi_ut_release_read_lock()
102 /* Release the write lock only for the very last reader */ in acpi_ut_release_read_lock()
104 lock->num_readers--; in acpi_ut_release_read_lock()
105 if (lock->num_readers == 0) { in acpi_ut_release_read_lock()
106 acpi_os_release_mutex(lock->writer_mutex); in acpi_ut_release_read_lock()
109 acpi_os_release_mutex(lock->reader_mutex); in acpi_ut_release_read_lock()
110 return (status); in acpi_ut_release_read_lock()
118 * PARAMETERS: lock - Pointer to a valid RW lock
120 * RETURN: Status
123 * release the writer mutex associated with the lock. Acquisition
124 * of the lock is fully exclusive and will block all readers and
129 acpi_status acpi_ut_acquire_write_lock(struct acpi_rw_lock *lock) in acpi_ut_acquire_write_lock() argument
131 acpi_status status; in acpi_ut_acquire_write_lock() local
133 status = acpi_os_acquire_mutex(lock->writer_mutex, ACPI_WAIT_FOREVER); in acpi_ut_acquire_write_lock()
134 return (status); in acpi_ut_acquire_write_lock()
137 void acpi_ut_release_write_lock(struct acpi_rw_lock *lock) in acpi_ut_release_write_lock() argument
140 acpi_os_release_mutex(lock->writer_mutex); in acpi_ut_release_write_lock()