io_uring: ensure finish_wait() is always called in __io_uring_task_cancel()
[linux/fpc-iii.git] / drivers / acpi / acpica / nsxfobj.c
blob324269481160bddc55086ca61142feaff1f4f200
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
5 * ACPI Object oriented interfaces
7 ******************************************************************************/
9 #define EXPORT_ACPI_INTERFACES
11 #include <acpi/acpi.h>
12 #include "accommon.h"
13 #include "acnamesp.h"
15 #define _COMPONENT ACPI_NAMESPACE
16 ACPI_MODULE_NAME("nsxfobj")
18 /*******************************************************************************
20 * FUNCTION: acpi_get_type
22 * PARAMETERS: handle - Handle of object whose type is desired
23 * ret_type - Where the type will be placed
25 * RETURN: Status
27 * DESCRIPTION: This routine returns the type associated with a particular
28 * handle
30 ******************************************************************************/
31 acpi_status acpi_get_type(acpi_handle handle, acpi_object_type *ret_type)
33 struct acpi_namespace_node *node;
34 acpi_status status;
36 /* Parameter Validation */
38 if (!ret_type) {
39 return (AE_BAD_PARAMETER);
42 /* Special case for the predefined Root Node (return type ANY) */
44 if (handle == ACPI_ROOT_OBJECT) {
45 *ret_type = ACPI_TYPE_ANY;
46 return (AE_OK);
49 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
50 if (ACPI_FAILURE(status)) {
51 return (status);
54 /* Convert and validate the handle */
56 node = acpi_ns_validate_handle(handle);
57 if (!node) {
58 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
59 return (AE_BAD_PARAMETER);
62 *ret_type = node->type;
64 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
65 return (status);
68 ACPI_EXPORT_SYMBOL(acpi_get_type)
70 /*******************************************************************************
72 * FUNCTION: acpi_get_parent
74 * PARAMETERS: handle - Handle of object whose parent is desired
75 * ret_handle - Where the parent handle will be placed
77 * RETURN: Status
79 * DESCRIPTION: Returns a handle to the parent of the object represented by
80 * Handle.
82 ******************************************************************************/
83 acpi_status acpi_get_parent(acpi_handle handle, acpi_handle *ret_handle)
85 struct acpi_namespace_node *node;
86 struct acpi_namespace_node *parent_node;
87 acpi_status status;
89 if (!ret_handle) {
90 return (AE_BAD_PARAMETER);
93 /* Special case for the predefined Root Node (no parent) */
95 if (handle == ACPI_ROOT_OBJECT) {
96 return (AE_NULL_ENTRY);
99 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
100 if (ACPI_FAILURE(status)) {
101 return (status);
104 /* Convert and validate the handle */
106 node = acpi_ns_validate_handle(handle);
107 if (!node) {
108 status = AE_BAD_PARAMETER;
109 goto unlock_and_exit;
112 /* Get the parent entry */
114 parent_node = node->parent;
115 *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node);
117 /* Return exception if parent is null */
119 if (!parent_node) {
120 status = AE_NULL_ENTRY;
123 unlock_and_exit:
125 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
126 return (status);
129 ACPI_EXPORT_SYMBOL(acpi_get_parent)
131 /*******************************************************************************
133 * FUNCTION: acpi_get_next_object
135 * PARAMETERS: type - Type of object to be searched for
136 * parent - Parent object whose children we are getting
137 * last_child - Previous child that was found.
138 * The NEXT child will be returned
139 * ret_handle - Where handle to the next object is placed
141 * RETURN: Status
143 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
144 * valid, Scope is ignored. Otherwise, the first object within
145 * Scope is returned.
147 ******************************************************************************/
148 acpi_status
149 acpi_get_next_object(acpi_object_type type,
150 acpi_handle parent,
151 acpi_handle child, acpi_handle *ret_handle)
153 acpi_status status;
154 struct acpi_namespace_node *node;
155 struct acpi_namespace_node *parent_node = NULL;
156 struct acpi_namespace_node *child_node = NULL;
158 /* Parameter validation */
160 if (type > ACPI_TYPE_EXTERNAL_MAX) {
161 return (AE_BAD_PARAMETER);
164 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
165 if (ACPI_FAILURE(status)) {
166 return (status);
169 /* If null handle, use the parent */
171 if (!child) {
173 /* Start search at the beginning of the specified scope */
175 parent_node = acpi_ns_validate_handle(parent);
176 if (!parent_node) {
177 status = AE_BAD_PARAMETER;
178 goto unlock_and_exit;
180 } else {
181 /* Non-null handle, ignore the parent */
182 /* Convert and validate the handle */
184 child_node = acpi_ns_validate_handle(child);
185 if (!child_node) {
186 status = AE_BAD_PARAMETER;
187 goto unlock_and_exit;
191 /* Internal function does the real work */
193 node = acpi_ns_get_next_node_typed(type, parent_node, child_node);
194 if (!node) {
195 status = AE_NOT_FOUND;
196 goto unlock_and_exit;
199 if (ret_handle) {
200 *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
203 unlock_and_exit:
205 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
206 return (status);
209 ACPI_EXPORT_SYMBOL(acpi_get_next_object)