[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / acpi / namespace / nsxfobj.c
blob19acf32674b94e13872a6e0016f7c485ad2e9bda
1 /*******************************************************************************
3 * Module Name: nsxfobj - Public interfaces to the ACPI subsystem
4 * ACPI Object oriented interfaces
6 ******************************************************************************/
8 /*
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
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 #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
61 * RETURN: Status
63 * DESCRIPTION: This routine returns the type associatd with a particular handle
65 ******************************************************************************/
67 acpi_status
68 acpi_get_type (
69 acpi_handle handle,
70 acpi_object_type *ret_type)
72 struct acpi_namespace_node *node;
73 acpi_status status;
76 /* Parameter Validation */
78 if (!ret_type) {
79 return (AE_BAD_PARAMETER);
83 * Special case for the predefined Root Node
84 * (return type ANY)
86 if (handle == ACPI_ROOT_OBJECT) {
87 *ret_type = ACPI_TYPE_ANY;
88 return (AE_OK);
91 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
92 if (ACPI_FAILURE (status)) {
93 return (status);
96 /* Convert and validate the handle */
98 node = acpi_ns_map_handle_to_node (handle);
99 if (!node) {
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);
108 return (status);
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
120 * RETURN: Status
122 * DESCRIPTION: Returns a handle to the parent of the object represented by
123 * Handle.
125 ******************************************************************************/
127 acpi_status
128 acpi_get_parent (
129 acpi_handle handle,
130 acpi_handle *ret_handle)
132 struct acpi_namespace_node *node;
133 acpi_status status;
136 if (!ret_handle) {
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)) {
148 return (status);
151 /* Convert and validate the handle */
153 node = acpi_ns_map_handle_to_node (handle);
154 if (!node) {
155 status = AE_BAD_PARAMETER;
156 goto unlock_and_exit;
159 /* Get the parent entry */
161 *ret_handle =
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;
171 unlock_and_exit:
173 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
174 return (status);
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
189 * RETURN: Status
191 * DESCRIPTION: Return the next peer object within the namespace. If Handle is
192 * valid, Scope is ignored. Otherwise, the first object within
193 * Scope is returned.
195 ******************************************************************************/
197 acpi_status
198 acpi_get_next_object (
199 acpi_object_type type,
200 acpi_handle parent,
201 acpi_handle child,
202 acpi_handle *ret_handle)
204 acpi_status status;
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)) {
218 return (status);
221 /* If null handle, use the parent */
223 if (!child) {
224 /* Start search at the beginning of the specified scope */
226 parent_node = acpi_ns_map_handle_to_node (parent);
227 if (!parent_node) {
228 status = AE_BAD_PARAMETER;
229 goto unlock_and_exit;
232 else {
233 /* Non-null handle, ignore the parent */
234 /* Convert and validate the handle */
236 child_node = acpi_ns_map_handle_to_node (child);
237 if (!child_node) {
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);
246 if (!node) {
247 status = AE_NOT_FOUND;
248 goto unlock_and_exit;
251 if (ret_handle) {
252 *ret_handle = acpi_ns_convert_entry_to_handle (node);
256 unlock_and_exit:
258 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
259 return (status);
261 EXPORT_SYMBOL(acpi_get_next_object);