1 /*******************************************************************************
3 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4 * ACPI Object oriented interfaces
6 ******************************************************************************/
9 * Copyright (C) 2000 - 2005, R. Byron Moore
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
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.
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 #include <linux/module.h>
47 #include <acpi/acpi.h>
48 #include <acpi/acnamesp.h>
51 #define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsxfobj")
54 /*******************************************************************************
56 * FUNCTION: acpi_get_type
58 * PARAMETERS: Handle - Handle of object whose type is desired
59 * *ret_type - Where the type will be placed
63 * DESCRIPTION: This routine returns the type associatd with a particular handle
65 ******************************************************************************/
70 acpi_object_type
*ret_type
)
72 struct acpi_namespace_node
*node
;
76 /* Parameter Validation */
79 return (AE_BAD_PARAMETER
);
83 * Special case for the predefined Root Node
86 if (handle
== ACPI_ROOT_OBJECT
) {
87 *ret_type
= ACPI_TYPE_ANY
;
91 status
= acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE
);
92 if (ACPI_FAILURE (status
)) {
96 /* Convert and validate the handle */
98 node
= acpi_ns_map_handle_to_node (handle
);
100 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE
);
101 return (AE_BAD_PARAMETER
);
104 *ret_type
= node
->type
;
107 status
= acpi_ut_release_mutex (ACPI_MTX_NAMESPACE
);
110 EXPORT_SYMBOL(acpi_get_type
);
113 /*******************************************************************************
115 * FUNCTION: acpi_get_parent
117 * PARAMETERS: Handle - Handle of object whose parent is desired
118 * ret_handle - Where the parent handle will be placed
122 * DESCRIPTION: Returns a handle to the parent of the object represented by
125 ******************************************************************************/
130 acpi_handle
*ret_handle
)
132 struct acpi_namespace_node
*node
;
137 return (AE_BAD_PARAMETER
);
140 /* Special case for the predefined Root Node (no parent) */
142 if (handle
== ACPI_ROOT_OBJECT
) {
143 return (AE_NULL_ENTRY
);
146 status
= acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE
);
147 if (ACPI_FAILURE (status
)) {
151 /* Convert and validate the handle */
153 node
= acpi_ns_map_handle_to_node (handle
);
155 status
= AE_BAD_PARAMETER
;
156 goto unlock_and_exit
;
159 /* Get the parent entry */
162 acpi_ns_convert_entry_to_handle (acpi_ns_get_parent_node (node
));
164 /* Return exception if parent is null */
166 if (!acpi_ns_get_parent_node (node
)) {
167 status
= AE_NULL_ENTRY
;
173 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE
);
176 EXPORT_SYMBOL(acpi_get_parent
);
179 /*******************************************************************************
181 * FUNCTION: acpi_get_next_object
183 * PARAMETERS: Type - Type of object to be searched for
184 * Parent - Parent object whose children we are getting
185 * last_child - Previous child that was found.
186 * The NEXT child will be returned
187 * ret_handle - Where handle to the next object is placed
191 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
192 * valid, Scope is ignored. Otherwise, the first object within
195 ******************************************************************************/
198 acpi_get_next_object (
199 acpi_object_type type
,
202 acpi_handle
*ret_handle
)
205 struct acpi_namespace_node
*node
;
206 struct acpi_namespace_node
*parent_node
= NULL
;
207 struct acpi_namespace_node
*child_node
= NULL
;
210 /* Parameter validation */
212 if (type
> ACPI_TYPE_EXTERNAL_MAX
) {
213 return (AE_BAD_PARAMETER
);
216 status
= acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE
);
217 if (ACPI_FAILURE (status
)) {
221 /* If null handle, use the parent */
224 /* Start search at the beginning of the specified scope */
226 parent_node
= acpi_ns_map_handle_to_node (parent
);
228 status
= AE_BAD_PARAMETER
;
229 goto unlock_and_exit
;
233 /* Non-null handle, ignore the parent */
234 /* Convert and validate the handle */
236 child_node
= acpi_ns_map_handle_to_node (child
);
238 status
= AE_BAD_PARAMETER
;
239 goto unlock_and_exit
;
243 /* Internal function does the real work */
245 node
= acpi_ns_get_next_node (type
, parent_node
, child_node
);
247 status
= AE_NOT_FOUND
;
248 goto unlock_and_exit
;
252 *ret_handle
= acpi_ns_convert_entry_to_handle (node
);
258 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE
);
261 EXPORT_SYMBOL(acpi_get_next_object
);