[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / acpi / namespace / nsxfname.c
blobf2405efd1b9a89157fc4a74a4a7d8a4b15f9ef37
1 /******************************************************************************
3 * Module Name: nsxfname - Public interfaces to the ACPI subsystem
4 * ACPI Namespace 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 ("nsxfname")
55 /******************************************************************************
57 * FUNCTION: acpi_get_handle
59 * PARAMETERS: Parent - Object to search under (search scope).
60 * path_name - Pointer to an asciiz string containing the
61 * name
62 * ret_handle - Where the return handle is placed
64 * RETURN: Status
66 * DESCRIPTION: This routine will search for a caller specified name in the
67 * name space. The caller can restrict the search region by
68 * specifying a non NULL parent. The parent value is itself a
69 * namespace handle.
71 ******************************************************************************/
73 acpi_status
74 acpi_get_handle (
75 acpi_handle parent,
76 acpi_string pathname,
77 acpi_handle *ret_handle)
79 acpi_status status;
80 struct acpi_namespace_node *node = NULL;
81 struct acpi_namespace_node *prefix_node = NULL;
84 ACPI_FUNCTION_ENTRY ();
87 /* Parameter Validation */
89 if (!ret_handle || !pathname) {
90 return (AE_BAD_PARAMETER);
93 /* Convert a parent handle to a prefix node */
95 if (parent) {
96 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
97 if (ACPI_FAILURE (status)) {
98 return (status);
101 prefix_node = acpi_ns_map_handle_to_node (parent);
102 if (!prefix_node) {
103 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
104 return (AE_BAD_PARAMETER);
107 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
108 if (ACPI_FAILURE (status)) {
109 return (status);
113 /* Special case for root, since we can't search for it */
115 if (ACPI_STRCMP (pathname, ACPI_NS_ROOT_PATH) == 0) {
116 *ret_handle = acpi_ns_convert_entry_to_handle (acpi_gbl_root_node);
117 return (AE_OK);
121 * Find the Node and convert to a handle
123 status = acpi_ns_get_node_by_path (pathname, prefix_node, ACPI_NS_NO_UPSEARCH,
124 &node);
126 *ret_handle = NULL;
127 if (ACPI_SUCCESS (status)) {
128 *ret_handle = acpi_ns_convert_entry_to_handle (node);
131 return (status);
133 EXPORT_SYMBOL(acpi_get_handle);
136 /******************************************************************************
138 * FUNCTION: acpi_get_name
140 * PARAMETERS: Handle - Handle to be converted to a pathname
141 * name_type - Full pathname or single segment
142 * Buffer - Buffer for returned path
144 * RETURN: Pointer to a string containing the fully qualified Name.
146 * DESCRIPTION: This routine returns the fully qualified name associated with
147 * the Handle parameter. This and the acpi_pathname_to_handle are
148 * complementary functions.
150 ******************************************************************************/
152 acpi_status
153 acpi_get_name (
154 acpi_handle handle,
155 u32 name_type,
156 struct acpi_buffer *buffer)
158 acpi_status status;
159 struct acpi_namespace_node *node;
162 /* Parameter validation */
164 if (name_type > ACPI_NAME_TYPE_MAX) {
165 return (AE_BAD_PARAMETER);
168 status = acpi_ut_validate_buffer (buffer);
169 if (ACPI_FAILURE (status)) {
170 return (status);
173 if (name_type == ACPI_FULL_PATHNAME) {
174 /* Get the full pathname (From the namespace root) */
176 status = acpi_ns_handle_to_pathname (handle, buffer);
177 return (status);
181 * Wants the single segment ACPI name.
182 * Validate handle and convert to a namespace Node
184 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
185 if (ACPI_FAILURE (status)) {
186 return (status);
189 node = acpi_ns_map_handle_to_node (handle);
190 if (!node) {
191 status = AE_BAD_PARAMETER;
192 goto unlock_and_exit;
195 /* Validate/Allocate/Clear caller buffer */
197 status = acpi_ut_initialize_buffer (buffer, ACPI_PATH_SEGMENT_LENGTH);
198 if (ACPI_FAILURE (status)) {
199 goto unlock_and_exit;
202 /* Just copy the ACPI name from the Node and zero terminate it */
204 ACPI_STRNCPY (buffer->pointer, acpi_ut_get_node_name (node),
205 ACPI_NAME_SIZE);
206 ((char *) buffer->pointer) [ACPI_NAME_SIZE] = 0;
207 status = AE_OK;
210 unlock_and_exit:
212 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
213 return (status);
215 EXPORT_SYMBOL(acpi_get_name);
218 /******************************************************************************
220 * FUNCTION: acpi_get_object_info
222 * PARAMETERS: Handle - Object Handle
223 * Info - Where the info is returned
225 * RETURN: Status
227 * DESCRIPTION: Returns information about an object as gleaned from the
228 * namespace node and possibly by running several standard
229 * control methods (Such as in the case of a device.)
231 ******************************************************************************/
233 acpi_status
234 acpi_get_object_info (
235 acpi_handle handle,
236 struct acpi_buffer *buffer)
238 acpi_status status;
239 struct acpi_namespace_node *node;
240 struct acpi_device_info *info;
241 struct acpi_device_info *return_info;
242 struct acpi_compatible_id_list *cid_list = NULL;
243 acpi_size size;
246 /* Parameter validation */
248 if (!handle || !buffer) {
249 return (AE_BAD_PARAMETER);
252 status = acpi_ut_validate_buffer (buffer);
253 if (ACPI_FAILURE (status)) {
254 return (status);
257 info = ACPI_MEM_CALLOCATE (sizeof (struct acpi_device_info));
258 if (!info) {
259 return (AE_NO_MEMORY);
262 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
263 if (ACPI_FAILURE (status)) {
264 goto cleanup;
267 node = acpi_ns_map_handle_to_node (handle);
268 if (!node) {
269 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
270 goto cleanup;
273 /* Init return structure */
275 size = sizeof (struct acpi_device_info);
277 info->type = node->type;
278 info->name = node->name.integer;
279 info->valid = 0;
281 status = acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
282 if (ACPI_FAILURE (status)) {
283 goto cleanup;
286 /* If not a device, we are all done */
288 if (info->type == ACPI_TYPE_DEVICE) {
290 * Get extra info for ACPI Devices objects only:
291 * Run the Device _HID, _UID, _CID, _STA, _ADR and _sx_d methods.
293 * Note: none of these methods are required, so they may or may
294 * not be present for this device. The Info->Valid bitfield is used
295 * to indicate which methods were found and ran successfully.
298 /* Execute the Device._HID method */
300 status = acpi_ut_execute_HID (node, &info->hardware_id);
301 if (ACPI_SUCCESS (status)) {
302 info->valid |= ACPI_VALID_HID;
305 /* Execute the Device._UID method */
307 status = acpi_ut_execute_UID (node, &info->unique_id);
308 if (ACPI_SUCCESS (status)) {
309 info->valid |= ACPI_VALID_UID;
312 /* Execute the Device._CID method */
314 status = acpi_ut_execute_CID (node, &cid_list);
315 if (ACPI_SUCCESS (status)) {
316 size += ((acpi_size) cid_list->count - 1) *
317 sizeof (struct acpi_compatible_id);
318 info->valid |= ACPI_VALID_CID;
321 /* Execute the Device._STA method */
323 status = acpi_ut_execute_STA (node, &info->current_status);
324 if (ACPI_SUCCESS (status)) {
325 info->valid |= ACPI_VALID_STA;
328 /* Execute the Device._ADR method */
330 status = acpi_ut_evaluate_numeric_object (METHOD_NAME__ADR, node,
331 &info->address);
332 if (ACPI_SUCCESS (status)) {
333 info->valid |= ACPI_VALID_ADR;
336 /* Execute the Device._sx_d methods */
338 status = acpi_ut_execute_sxds (node, info->highest_dstates);
339 if (ACPI_SUCCESS (status)) {
340 info->valid |= ACPI_VALID_SXDS;
344 /* Validate/Allocate/Clear caller buffer */
346 status = acpi_ut_initialize_buffer (buffer, size);
347 if (ACPI_FAILURE (status)) {
348 goto cleanup;
351 /* Populate the return buffer */
353 return_info = buffer->pointer;
354 ACPI_MEMCPY (return_info, info, sizeof (struct acpi_device_info));
356 if (cid_list) {
357 ACPI_MEMCPY (&return_info->compatibility_id, cid_list, cid_list->size);
361 cleanup:
362 ACPI_MEM_FREE (info);
363 if (cid_list) {
364 ACPI_MEM_FREE (cid_list);
366 return (status);
368 EXPORT_SYMBOL(acpi_get_object_info);