PRCM: 34XX: Fix wrong shift value used in dpll4_m4x2_ck enable bit
[linux-ginger.git] / drivers / acpi / namespace / nsxfname.c
bloba287ed550f5474db1802e2bb785ecd3531b33f10
1 /******************************************************************************
3 * Module Name: nsxfname - Public interfaces to the ACPI subsystem
4 * ACPI Namespace oriented interfaces
6 *****************************************************************************/
8 /*
9 * Copyright (C) 2000 - 2008, 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 #include <acpi/acpi.h>
46 #include <acpi/acnamesp.h>
48 #define _COMPONENT ACPI_NAMESPACE
49 ACPI_MODULE_NAME("nsxfname")
51 /******************************************************************************
53 * FUNCTION: acpi_get_handle
55 * PARAMETERS: Parent - Object to search under (search scope).
56 * Pathname - Pointer to an asciiz string containing the
57 * name
58 * ret_handle - Where the return handle is returned
60 * RETURN: Status
62 * DESCRIPTION: This routine will search for a caller specified name in the
63 * name space. The caller can restrict the search region by
64 * specifying a non NULL parent. The parent value is itself a
65 * namespace handle.
67 ******************************************************************************/
68 acpi_status
69 acpi_get_handle(acpi_handle parent,
70 acpi_string pathname, acpi_handle * ret_handle)
72 acpi_status status;
73 struct acpi_namespace_node *node = NULL;
74 struct acpi_namespace_node *prefix_node = NULL;
76 ACPI_FUNCTION_ENTRY();
78 /* Parameter Validation */
80 if (!ret_handle || !pathname) {
81 return (AE_BAD_PARAMETER);
84 /* Convert a parent handle to a prefix node */
86 if (parent) {
87 prefix_node = acpi_ns_map_handle_to_node(parent);
88 if (!prefix_node) {
89 return (AE_BAD_PARAMETER);
94 * Valid cases are:
95 * 1) Fully qualified pathname
96 * 2) Parent + Relative pathname
98 * Error for <null Parent + relative path>
100 if (acpi_ns_valid_root_prefix(pathname[0])) {
102 /* Pathname is fully qualified (starts with '\') */
104 /* Special case for root-only, since we can't search for it */
106 if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
107 *ret_handle =
108 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
109 return (AE_OK);
111 } else if (!prefix_node) {
113 /* Relative path with null prefix is disallowed */
115 return (AE_BAD_PARAMETER);
118 /* Find the Node and convert to a handle */
120 status =
121 acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
122 if (ACPI_SUCCESS(status)) {
123 *ret_handle = acpi_ns_convert_entry_to_handle(node);
126 return (status);
129 ACPI_EXPORT_SYMBOL(acpi_get_handle)
131 /******************************************************************************
133 * FUNCTION: acpi_get_name
135 * PARAMETERS: Handle - Handle to be converted to a pathname
136 * name_type - Full pathname or single segment
137 * Buffer - Buffer for returned path
139 * RETURN: Pointer to a string containing the fully qualified Name.
141 * DESCRIPTION: This routine returns the fully qualified name associated with
142 * the Handle parameter. This and the acpi_pathname_to_handle are
143 * complementary functions.
145 ******************************************************************************/
146 acpi_status
147 acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
149 acpi_status status;
150 struct acpi_namespace_node *node;
152 /* Parameter validation */
154 if (name_type > ACPI_NAME_TYPE_MAX) {
155 return (AE_BAD_PARAMETER);
158 status = acpi_ut_validate_buffer(buffer);
159 if (ACPI_FAILURE(status)) {
160 return (status);
163 if (name_type == ACPI_FULL_PATHNAME) {
165 /* Get the full pathname (From the namespace root) */
167 status = acpi_ns_handle_to_pathname(handle, buffer);
168 return (status);
172 * Wants the single segment ACPI name.
173 * Validate handle and convert to a namespace Node
175 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
176 if (ACPI_FAILURE(status)) {
177 return (status);
180 node = acpi_ns_map_handle_to_node(handle);
181 if (!node) {
182 status = AE_BAD_PARAMETER;
183 goto unlock_and_exit;
186 /* Validate/Allocate/Clear caller buffer */
188 status = acpi_ut_initialize_buffer(buffer, ACPI_PATH_SEGMENT_LENGTH);
189 if (ACPI_FAILURE(status)) {
190 goto unlock_and_exit;
193 /* Just copy the ACPI name from the Node and zero terminate it */
195 ACPI_STRNCPY(buffer->pointer, acpi_ut_get_node_name(node),
196 ACPI_NAME_SIZE);
197 ((char *)buffer->pointer)[ACPI_NAME_SIZE] = 0;
198 status = AE_OK;
200 unlock_and_exit:
202 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
203 return (status);
206 ACPI_EXPORT_SYMBOL(acpi_get_name)
208 /******************************************************************************
210 * FUNCTION: acpi_get_object_info
212 * PARAMETERS: Handle - Object Handle
213 * Buffer - Where the info is returned
215 * RETURN: Status
217 * DESCRIPTION: Returns information about an object as gleaned from the
218 * namespace node and possibly by running several standard
219 * control methods (Such as in the case of a device.)
221 ******************************************************************************/
222 acpi_status
223 acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
225 acpi_status status;
226 struct acpi_namespace_node *node;
227 struct acpi_device_info *info;
228 struct acpi_device_info *return_info;
229 struct acpi_compatible_id_list *cid_list = NULL;
230 acpi_size size;
232 /* Parameter validation */
234 if (!handle || !buffer) {
235 return (AE_BAD_PARAMETER);
238 status = acpi_ut_validate_buffer(buffer);
239 if (ACPI_FAILURE(status)) {
240 return (status);
243 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_device_info));
244 if (!info) {
245 return (AE_NO_MEMORY);
248 status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
249 if (ACPI_FAILURE(status)) {
250 goto cleanup;
253 node = acpi_ns_map_handle_to_node(handle);
254 if (!node) {
255 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
256 goto cleanup;
259 /* Init return structure */
261 size = sizeof(struct acpi_device_info);
263 info->type = node->type;
264 info->name = node->name.integer;
265 info->valid = 0;
267 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
268 if (ACPI_FAILURE(status)) {
269 goto cleanup;
272 /* If not a device, we are all done */
274 if (info->type == ACPI_TYPE_DEVICE) {
276 * Get extra info for ACPI Devices objects only:
277 * Run the Device _HID, _UID, _CID, _STA, _ADR and _sx_d methods.
279 * Note: none of these methods are required, so they may or may
280 * not be present for this device. The Info->Valid bitfield is used
281 * to indicate which methods were found and ran successfully.
284 /* Execute the Device._HID method */
286 status = acpi_ut_execute_HID(node, &info->hardware_id);
287 if (ACPI_SUCCESS(status)) {
288 info->valid |= ACPI_VALID_HID;
291 /* Execute the Device._UID method */
293 status = acpi_ut_execute_UID(node, &info->unique_id);
294 if (ACPI_SUCCESS(status)) {
295 info->valid |= ACPI_VALID_UID;
298 /* Execute the Device._CID method */
300 status = acpi_ut_execute_CID(node, &cid_list);
301 if (ACPI_SUCCESS(status)) {
302 size += cid_list->size;
303 info->valid |= ACPI_VALID_CID;
306 /* Execute the Device._STA method */
308 status = acpi_ut_execute_STA(node, &info->current_status);
309 if (ACPI_SUCCESS(status)) {
310 info->valid |= ACPI_VALID_STA;
313 /* Execute the Device._ADR method */
315 status = acpi_ut_evaluate_numeric_object(METHOD_NAME__ADR, node,
316 &info->address);
317 if (ACPI_SUCCESS(status)) {
318 info->valid |= ACPI_VALID_ADR;
321 /* Execute the Device._sx_d methods */
323 status = acpi_ut_execute_sxds(node, info->highest_dstates);
324 if (ACPI_SUCCESS(status)) {
325 info->valid |= ACPI_VALID_SXDS;
329 /* Validate/Allocate/Clear caller buffer */
331 status = acpi_ut_initialize_buffer(buffer, size);
332 if (ACPI_FAILURE(status)) {
333 goto cleanup;
336 /* Populate the return buffer */
338 return_info = buffer->pointer;
339 ACPI_MEMCPY(return_info, info, sizeof(struct acpi_device_info));
341 if (cid_list) {
342 ACPI_MEMCPY(&return_info->compatibility_id, cid_list,
343 cid_list->size);
346 cleanup:
347 ACPI_FREE(info);
348 if (cid_list) {
349 ACPI_FREE(cid_list);
351 return (status);
354 ACPI_EXPORT_SYMBOL(acpi_get_object_info)