PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / acpi / acpica / nsxfobj.c
blob0e6d79e462d4f8c7233dc77ad37ad6f893faaea9
1 /*******************************************************************************
3 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4 * ACPI Object oriented interfaces
6 ******************************************************************************/
8 /*
9 * Copyright (C) 2000 - 2013, Intel Corp.
10 * All rights reserved.
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
45 #define EXPORT_ACPI_INTERFACES
47 #include <acpi/acpi.h>
48 #include "accommon.h"
49 #include "acnamesp.h"
51 #define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME("nsxfobj")
54 /*******************************************************************************
56 * FUNCTION: acpi_get_id
58 * PARAMETERS: Handle - Handle of object whose id is desired
59 * ret_id - Where the id will be placed
61 * RETURN: Status
63 * DESCRIPTION: This routine returns the owner id associated with a handle
65 ******************************************************************************/
66 acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
68 struct acpi_namespace_node *node;
69 acpi_status status;
71 /* Parameter Validation */
73 if (!ret_id) {
74 return (AE_BAD_PARAMETER);
77 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
78 if (ACPI_FAILURE(status)) {
79 return (status);
82 /* Convert and validate the handle */
84 node = acpi_ns_validate_handle(handle);
85 if (!node) {
86 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
87 return (AE_BAD_PARAMETER);
90 *ret_id = node->owner_id;
92 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
93 return (status);
96 ACPI_EXPORT_SYMBOL(acpi_get_id)
98 /*******************************************************************************
100 * FUNCTION: acpi_get_type
102 * PARAMETERS: handle - Handle of object whose type is desired
103 * ret_type - Where the type will be placed
105 * RETURN: Status
107 * DESCRIPTION: This routine returns the type associatd with a particular handle
109 ******************************************************************************/
110 acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
112 struct acpi_namespace_node *node;
113 acpi_status status;
115 /* Parameter Validation */
117 if (!ret_type) {
118 return (AE_BAD_PARAMETER);
122 * Special case for the predefined Root Node
123 * (return type ANY)
125 if (handle == ACPI_ROOT_OBJECT) {
126 *ret_type = ACPI_TYPE_ANY;
127 return (AE_OK);
130 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
131 if (ACPI_FAILURE(status)) {
132 return (status);
135 /* Convert and validate the handle */
137 node = acpi_ns_validate_handle(handle);
138 if (!node) {
139 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
140 return (AE_BAD_PARAMETER);
143 *ret_type = node->type;
145 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
146 return (status);
149 ACPI_EXPORT_SYMBOL(acpi_get_type)
151 /*******************************************************************************
153 * FUNCTION: acpi_get_parent
155 * PARAMETERS: handle - Handle of object whose parent is desired
156 * ret_handle - Where the parent handle will be placed
158 * RETURN: Status
160 * DESCRIPTION: Returns a handle to the parent of the object represented by
161 * Handle.
163 ******************************************************************************/
164 acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
166 struct acpi_namespace_node *node;
167 struct acpi_namespace_node *parent_node;
168 acpi_status status;
170 if (!ret_handle) {
171 return (AE_BAD_PARAMETER);
174 /* Special case for the predefined Root Node (no parent) */
176 if (handle == ACPI_ROOT_OBJECT) {
177 return (AE_NULL_ENTRY);
180 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
181 if (ACPI_FAILURE(status)) {
182 return (status);
185 /* Convert and validate the handle */
187 node = acpi_ns_validate_handle(handle);
188 if (!node) {
189 status = AE_BAD_PARAMETER;
190 goto unlock_and_exit;
193 /* Get the parent entry */
195 parent_node = node->parent;
196 *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node);
198 /* Return exception if parent is null */
200 if (!parent_node) {
201 status = AE_NULL_ENTRY;
204 unlock_and_exit:
206 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
207 return (status);
210 ACPI_EXPORT_SYMBOL(acpi_get_parent)
212 /*******************************************************************************
214 * FUNCTION: acpi_get_next_object
216 * PARAMETERS: type - Type of object to be searched for
217 * parent - Parent object whose children we are getting
218 * last_child - Previous child that was found.
219 * The NEXT child will be returned
220 * ret_handle - Where handle to the next object is placed
222 * RETURN: Status
224 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
225 * valid, Scope is ignored. Otherwise, the first object within
226 * Scope is returned.
228 ******************************************************************************/
229 acpi_status
230 acpi_get_next_object(acpi_object_type type,
231 acpi_handle parent,
232 acpi_handle child, acpi_handle * ret_handle)
234 acpi_status status;
235 struct acpi_namespace_node *node;
236 struct acpi_namespace_node *parent_node = NULL;
237 struct acpi_namespace_node *child_node = NULL;
239 /* Parameter validation */
241 if (type > ACPI_TYPE_EXTERNAL_MAX) {
242 return (AE_BAD_PARAMETER);
245 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
246 if (ACPI_FAILURE(status)) {
247 return (status);
250 /* If null handle, use the parent */
252 if (!child) {
254 /* Start search at the beginning of the specified scope */
256 parent_node = acpi_ns_validate_handle(parent);
257 if (!parent_node) {
258 status = AE_BAD_PARAMETER;
259 goto unlock_and_exit;
261 } else {
262 /* Non-null handle, ignore the parent */
263 /* Convert and validate the handle */
265 child_node = acpi_ns_validate_handle(child);
266 if (!child_node) {
267 status = AE_BAD_PARAMETER;
268 goto unlock_and_exit;
272 /* Internal function does the real work */
274 node = acpi_ns_get_next_node_typed(type, parent_node, child_node);
275 if (!node) {
276 status = AE_NOT_FOUND;
277 goto unlock_and_exit;
280 if (ret_handle) {
281 *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
284 unlock_and_exit:
286 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
287 return (status);
290 ACPI_EXPORT_SYMBOL(acpi_get_next_object)