Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Module Name: nsxfeval - Public interfaces to the ACPI subsystem |
| 4 | * ACPI Object evaluation interfaces |
| 5 | * |
| 6 | ******************************************************************************/ |
| 7 | |
| 8 | /* |
Bob Moore | 4a90c7e | 2006-01-13 16:22:00 -0500 | [diff] [blame] | 9 | * Copyright (C) 2000 - 2006, R. Byron Moore |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * All rights reserved. |
| 11 | * |
| 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. |
| 26 | * |
| 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. |
| 30 | * |
| 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. |
| 43 | */ |
| 44 | |
| 45 | #include <linux/module.h> |
| 46 | |
| 47 | #include <acpi/acpi.h> |
| 48 | #include <acpi/acnamesp.h> |
| 49 | #include <acpi/acinterp.h> |
| 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #define _COMPONENT ACPI_NAMESPACE |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 52 | ACPI_MODULE_NAME("nsxfeval") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | |
| 54 | /******************************************************************************* |
| 55 | * |
| 56 | * FUNCTION: acpi_evaluate_object_typed |
| 57 | * |
| 58 | * PARAMETERS: Handle - Object handle (optional) |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 59 | * Pathname - Object pathname (optional) |
| 60 | * external_params - List of parameters to pass to method, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | * terminated by NULL. May be NULL |
| 62 | * if no parameters are being passed. |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 63 | * return_buffer - Where to put method's return value (if |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | * any). If NULL, no value is returned. |
| 65 | * return_type - Expected type of return object |
| 66 | * |
| 67 | * RETURN: Status |
| 68 | * |
| 69 | * DESCRIPTION: Find and evaluate the given object, passing the given |
| 70 | * parameters if necessary. One of "Handle" or "Pathname" must |
| 71 | * be valid (non-null) |
| 72 | * |
| 73 | ******************************************************************************/ |
| 74 | #ifdef ACPI_FUTURE_USAGE |
| 75 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 76 | acpi_evaluate_object_typed(acpi_handle handle, |
| 77 | acpi_string pathname, |
| 78 | struct acpi_object_list *external_params, |
| 79 | struct acpi_buffer *return_buffer, |
| 80 | acpi_object_type return_type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | acpi_status status; |
| 83 | u8 must_free = FALSE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 85 | ACPI_FUNCTION_TRACE("acpi_evaluate_object_typed"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | /* Return buffer must be valid */ |
| 88 | |
| 89 | if (!return_buffer) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 90 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | if (return_buffer->length == ACPI_ALLOCATE_BUFFER) { |
| 94 | must_free = TRUE; |
| 95 | } |
| 96 | |
| 97 | /* Evaluate the object */ |
| 98 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 99 | status = |
| 100 | acpi_evaluate_object(handle, pathname, external_params, |
| 101 | return_buffer); |
| 102 | if (ACPI_FAILURE(status)) { |
| 103 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* Type ANY means "don't care" */ |
| 107 | |
| 108 | if (return_type == ACPI_TYPE_ANY) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 109 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | if (return_buffer->length == 0) { |
| 113 | /* Error because caller specifically asked for a return value */ |
| 114 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 115 | ACPI_ERROR((AE_INFO, "No return value")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 116 | return_ACPI_STATUS(AE_NULL_OBJECT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | /* Examine the object type returned from evaluate_object */ |
| 120 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | if (((union acpi_object *)return_buffer->pointer)->type == return_type) { |
| 122 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | /* Return object type does not match requested type */ |
| 126 | |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 127 | ACPI_ERROR((AE_INFO, |
| 128 | "Incorrect return type [%s] requested [%s]", |
| 129 | acpi_ut_get_type_name(((union acpi_object *)return_buffer-> |
| 130 | pointer)->type), |
| 131 | acpi_ut_get_type_name(return_type))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | if (must_free) { |
| 134 | /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ |
| 135 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 136 | acpi_os_free(return_buffer->pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | return_buffer->pointer = NULL; |
| 138 | } |
| 139 | |
| 140 | return_buffer->length = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 141 | return_ACPI_STATUS(AE_TYPE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | #endif /* ACPI_FUTURE_USAGE */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
| 145 | /******************************************************************************* |
| 146 | * |
| 147 | * FUNCTION: acpi_evaluate_object |
| 148 | * |
| 149 | * PARAMETERS: Handle - Object handle (optional) |
| 150 | * Pathname - Object pathname (optional) |
| 151 | * external_params - List of parameters to pass to method, |
| 152 | * terminated by NULL. May be NULL |
| 153 | * if no parameters are being passed. |
| 154 | * return_buffer - Where to put method's return value (if |
| 155 | * any). If NULL, no value is returned. |
| 156 | * |
| 157 | * RETURN: Status |
| 158 | * |
| 159 | * DESCRIPTION: Find and evaluate the given object, passing the given |
| 160 | * parameters if necessary. One of "Handle" or "Pathname" must |
| 161 | * be valid (non-null) |
| 162 | * |
| 163 | ******************************************************************************/ |
| 164 | |
| 165 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 166 | acpi_evaluate_object(acpi_handle handle, |
| 167 | acpi_string pathname, |
| 168 | struct acpi_object_list *external_params, |
| 169 | struct acpi_buffer *return_buffer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | acpi_status status; |
| 172 | acpi_status status2; |
| 173 | struct acpi_parameter_info info; |
| 174 | acpi_size buffer_space_needed; |
| 175 | u32 i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 177 | ACPI_FUNCTION_TRACE("acpi_evaluate_object"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | |
| 179 | info.node = handle; |
| 180 | info.parameters = NULL; |
| 181 | info.return_object = NULL; |
| 182 | info.parameter_type = ACPI_PARAM_ARGS; |
| 183 | |
| 184 | /* |
| 185 | * If there are parameters to be passed to the object |
| 186 | * (which must be a control method), the external objects |
| 187 | * must be converted to internal objects |
| 188 | */ |
| 189 | if (external_params && external_params->count) { |
| 190 | /* |
| 191 | * Allocate a new parameter block for the internal objects |
| 192 | * Add 1 to count to allow for null terminated internal list |
| 193 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 194 | info.parameters = ACPI_MEM_CALLOCATE(((acpi_size) |
| 195 | external_params->count + |
| 196 | 1) * sizeof(void *)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | if (!info.parameters) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 198 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | /* |
| 202 | * Convert each external object in the list to an |
| 203 | * internal object |
| 204 | */ |
| 205 | for (i = 0; i < external_params->count; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 206 | status = |
| 207 | acpi_ut_copy_eobject_to_iobject(&external_params-> |
| 208 | pointer[i], |
| 209 | &info. |
| 210 | parameters[i]); |
| 211 | if (ACPI_FAILURE(status)) { |
| 212 | acpi_ut_delete_internal_object_list(info. |
| 213 | parameters); |
| 214 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | } |
| 216 | } |
| 217 | info.parameters[external_params->count] = NULL; |
| 218 | } |
| 219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | /* |
| 221 | * Three major cases: |
| 222 | * 1) Fully qualified pathname |
| 223 | * 2) No handle, not fully qualified pathname (error) |
| 224 | * 3) Valid handle |
| 225 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | /* |
| 228 | * The path is fully qualified, just evaluate by name |
| 229 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 230 | status = acpi_ns_evaluate_by_name(pathname, &info); |
| 231 | } else if (!handle) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | /* |
| 233 | * A handle is optional iff a fully qualified pathname |
| 234 | * is specified. Since we've already handled fully |
| 235 | * qualified names above, this is an error |
| 236 | */ |
| 237 | if (!pathname) { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 238 | ACPI_ERROR((AE_INFO, |
| 239 | "Both Handle and Pathname are NULL")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | } else { |
Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 241 | ACPI_ERROR((AE_INFO, |
| 242 | "Handle is NULL and Pathname is relative")); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | status = AE_BAD_PARAMETER; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 246 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | /* |
| 248 | * We get here if we have a handle -- and if we have a |
| 249 | * pathname it is relative. The handle will be validated |
| 250 | * in the lower procedures |
| 251 | */ |
| 252 | if (!pathname) { |
| 253 | /* |
| 254 | * The null pathname case means the handle is for |
| 255 | * the actual object to be evaluated |
| 256 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 257 | status = acpi_ns_evaluate_by_handle(&info); |
| 258 | } else { |
| 259 | /* |
| 260 | * Both a Handle and a relative Pathname |
| 261 | */ |
| 262 | status = acpi_ns_evaluate_relative(pathname, &info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | } |
| 264 | } |
| 265 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | /* |
| 267 | * If we are expecting a return value, and all went well above, |
| 268 | * copy the return value to an external object. |
| 269 | */ |
| 270 | if (return_buffer) { |
| 271 | if (!info.return_object) { |
| 272 | return_buffer->length = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 273 | } else { |
| 274 | if (ACPI_GET_DESCRIPTOR_TYPE(info.return_object) == |
| 275 | ACPI_DESC_TYPE_NAMED) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | /* |
| 277 | * If we received a NS Node as a return object, this means that |
| 278 | * the object we are evaluating has nothing interesting to |
| 279 | * return (such as a mutex, etc.) We return an error because |
| 280 | * these types are essentially unsupported by this interface. |
| 281 | * We don't check up front because this makes it easier to add |
| 282 | * support for various types at a later date if necessary. |
| 283 | */ |
| 284 | status = AE_TYPE; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 285 | info.return_object = NULL; /* No need to delete a NS Node */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | return_buffer->length = 0; |
| 287 | } |
| 288 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 289 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | /* |
| 291 | * Find out how large a buffer is needed |
| 292 | * to contain the returned object |
| 293 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 294 | status = |
| 295 | acpi_ut_get_object_size(info.return_object, |
| 296 | &buffer_space_needed); |
| 297 | if (ACPI_SUCCESS(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | /* Validate/Allocate/Clear caller buffer */ |
| 299 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 300 | status = |
| 301 | acpi_ut_initialize_buffer |
| 302 | (return_buffer, |
| 303 | buffer_space_needed); |
| 304 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | /* |
| 306 | * Caller's buffer is too small or a new one can't be allocated |
| 307 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 308 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, |
| 309 | "Needed buffer size %X, %s\n", |
| 310 | (u32) |
| 311 | buffer_space_needed, |
| 312 | acpi_format_exception |
| 313 | (status))); |
| 314 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | /* |
| 316 | * We have enough space for the object, build it |
| 317 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 318 | status = |
| 319 | acpi_ut_copy_iobject_to_eobject |
| 320 | (info.return_object, |
| 321 | return_buffer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | if (info.return_object) { |
| 329 | /* |
| 330 | * Delete the internal return object. NOTE: Interpreter |
| 331 | * must be locked to avoid race condition. |
| 332 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | status2 = acpi_ex_enter_interpreter(); |
| 334 | if (ACPI_SUCCESS(status2)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | /* |
| 336 | * Delete the internal return object. (Or at least |
| 337 | * decrement the reference count by one) |
| 338 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 339 | acpi_ut_remove_reference(info.return_object); |
| 340 | acpi_ex_exit_interpreter(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
| 342 | } |
| 343 | |
| 344 | /* |
| 345 | * Free the input parameter list (if we created one), |
| 346 | */ |
| 347 | if (info.parameters) { |
| 348 | /* Free the allocated parameter block */ |
| 349 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 350 | acpi_ut_delete_internal_object_list(info.parameters); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 353 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 355 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 356 | EXPORT_SYMBOL(acpi_evaluate_object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | |
| 358 | /******************************************************************************* |
| 359 | * |
| 360 | * FUNCTION: acpi_walk_namespace |
| 361 | * |
| 362 | * PARAMETERS: Type - acpi_object_type to search for |
| 363 | * start_object - Handle in namespace where search begins |
| 364 | * max_depth - Depth to which search is to reach |
| 365 | * user_function - Called when an object of "Type" is found |
| 366 | * Context - Passed to user function |
| 367 | * return_value - Location where return value of |
| 368 | * user_function is put if terminated early |
| 369 | * |
| 370 | * RETURNS Return value from the user_function if terminated early. |
| 371 | * Otherwise, returns NULL. |
| 372 | * |
| 373 | * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, |
| 374 | * starting (and ending) at the object specified by start_handle. |
| 375 | * The user_function is called whenever an object that matches |
| 376 | * the type parameter is found. If the user function returns |
| 377 | * a non-zero value, the search is terminated immediately and this |
| 378 | * value is returned to the caller. |
| 379 | * |
| 380 | * The point of this procedure is to provide a generic namespace |
| 381 | * walk routine that can be called from multiple places to |
| 382 | * provide multiple services; the User Function can be tailored |
| 383 | * to each task, whether it is a print function, a compare |
| 384 | * function, etc. |
| 385 | * |
| 386 | ******************************************************************************/ |
| 387 | |
| 388 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 389 | acpi_walk_namespace(acpi_object_type type, |
| 390 | acpi_handle start_object, |
| 391 | u32 max_depth, |
| 392 | acpi_walk_callback user_function, |
| 393 | void *context, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 395 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 397 | ACPI_FUNCTION_TRACE("acpi_walk_namespace"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | |
| 399 | /* Parameter validation */ |
| 400 | |
Bob Moore | 96db255 | 2005-11-02 00:00:00 -0500 | [diff] [blame] | 401 | if ((type > ACPI_TYPE_LOCAL_MAX) || (!max_depth) || (!user_function)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 402 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | /* |
| 406 | * Lock the namespace around the walk. |
| 407 | * The namespace will be unlocked/locked around each call |
| 408 | * to the user function - since this function |
| 409 | * must be allowed to make Acpi calls itself. |
| 410 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 412 | if (ACPI_FAILURE(status)) { |
| 413 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 416 | status = acpi_ns_walk_namespace(type, start_object, max_depth, |
| 417 | ACPI_NS_WALK_UNLOCK, |
| 418 | user_function, context, return_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 420 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 421 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 422 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 424 | EXPORT_SYMBOL(acpi_walk_namespace); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | |
| 426 | /******************************************************************************* |
| 427 | * |
| 428 | * FUNCTION: acpi_ns_get_device_callback |
| 429 | * |
| 430 | * PARAMETERS: Callback from acpi_get_device |
| 431 | * |
| 432 | * RETURN: Status |
| 433 | * |
| 434 | * DESCRIPTION: Takes callbacks from walk_namespace and filters out all non- |
| 435 | * present devices, or if they specified a HID, it filters based |
| 436 | * on that. |
| 437 | * |
| 438 | ******************************************************************************/ |
| 439 | |
| 440 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 441 | acpi_ns_get_device_callback(acpi_handle obj_handle, |
| 442 | u32 nesting_level, |
| 443 | void *context, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 445 | struct acpi_get_devices_info *info = context; |
| 446 | acpi_status status; |
| 447 | struct acpi_namespace_node *node; |
| 448 | u32 flags; |
| 449 | struct acpi_device_id hid; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | struct acpi_compatible_id_list *cid; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 451 | acpi_native_uint i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 452 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 453 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 454 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | return (status); |
| 456 | } |
| 457 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 458 | node = acpi_ns_map_handle_to_node(obj_handle); |
| 459 | status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 460 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | return (status); |
| 462 | } |
| 463 | |
| 464 | if (!node) { |
| 465 | return (AE_BAD_PARAMETER); |
| 466 | } |
| 467 | |
| 468 | /* Run _STA to determine if device is present */ |
| 469 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 470 | status = acpi_ut_execute_STA(node, &flags); |
| 471 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | return (AE_CTRL_DEPTH); |
| 473 | } |
| 474 | |
Bob Moore | defba1d | 2005-12-16 17:05:00 -0500 | [diff] [blame] | 475 | if (!(flags & ACPI_STA_DEVICE_PRESENT)) { |
| 476 | /* Don't examine children of the device if not present */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
| 478 | return (AE_CTRL_DEPTH); |
| 479 | } |
| 480 | |
| 481 | /* Filter based on device HID & CID */ |
| 482 | |
| 483 | if (info->hid != NULL) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 484 | status = acpi_ut_execute_HID(node, &hid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | if (status == AE_NOT_FOUND) { |
| 486 | return (AE_OK); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 487 | } else if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | return (AE_CTRL_DEPTH); |
| 489 | } |
| 490 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 491 | if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | /* Get the list of Compatible IDs */ |
| 493 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 494 | status = acpi_ut_execute_CID(node, &cid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | if (status == AE_NOT_FOUND) { |
| 496 | return (AE_OK); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 497 | } else if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | return (AE_CTRL_DEPTH); |
| 499 | } |
| 500 | |
| 501 | /* Walk the CID list */ |
| 502 | |
| 503 | for (i = 0; i < cid->count; i++) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 504 | if (ACPI_STRNCMP(cid->id[i].value, info->hid, |
| 505 | sizeof(struct |
| 506 | acpi_compatible_id)) != |
| 507 | 0) { |
| 508 | ACPI_MEM_FREE(cid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | return (AE_OK); |
| 510 | } |
| 511 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 512 | ACPI_MEM_FREE(cid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | } |
| 514 | } |
| 515 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 516 | status = info->user_function(obj_handle, nesting_level, info->context, |
| 517 | return_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | return (status); |
| 519 | } |
| 520 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | /******************************************************************************* |
| 522 | * |
| 523 | * FUNCTION: acpi_get_devices |
| 524 | * |
| 525 | * PARAMETERS: HID - HID to search for. Can be NULL. |
| 526 | * user_function - Called when a matching object is found |
| 527 | * Context - Passed to user function |
| 528 | * return_value - Location where return value of |
| 529 | * user_function is put if terminated early |
| 530 | * |
| 531 | * RETURNS Return value from the user_function if terminated early. |
| 532 | * Otherwise, returns NULL. |
| 533 | * |
| 534 | * DESCRIPTION: Performs a modified depth-first walk of the namespace tree, |
| 535 | * starting (and ending) at the object specified by start_handle. |
| 536 | * The user_function is called whenever an object of type |
| 537 | * Device is found. If the user function returns |
| 538 | * a non-zero value, the search is terminated immediately and this |
| 539 | * value is returned to the caller. |
| 540 | * |
| 541 | * This is a wrapper for walk_namespace, but the callback performs |
| 542 | * additional filtering. Please see acpi_get_device_callback. |
| 543 | * |
| 544 | ******************************************************************************/ |
| 545 | |
| 546 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 547 | acpi_get_devices(char *HID, |
| 548 | acpi_walk_callback user_function, |
| 549 | void *context, void **return_value) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 551 | acpi_status status; |
| 552 | struct acpi_get_devices_info info; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 554 | ACPI_FUNCTION_TRACE("acpi_get_devices"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 555 | |
| 556 | /* Parameter validation */ |
| 557 | |
| 558 | if (!user_function) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 559 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | /* |
| 563 | * We're going to call their callback from OUR callback, so we need |
| 564 | * to know what it is, and their context parameter. |
| 565 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 566 | info.context = context; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | info.user_function = user_function; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 568 | info.hid = HID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | |
| 570 | /* |
| 571 | * Lock the namespace around the walk. |
| 572 | * The namespace will be unlocked/locked around each call |
| 573 | * to the user function - since this function |
| 574 | * must be allowed to make Acpi calls itself. |
| 575 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 576 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 577 | if (ACPI_FAILURE(status)) { |
| 578 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | } |
| 580 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 581 | status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, |
| 582 | ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, |
| 583 | ACPI_NS_WALK_UNLOCK, |
| 584 | acpi_ns_get_device_callback, &info, |
| 585 | return_value); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 586 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 587 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
| 588 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 589 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 591 | EXPORT_SYMBOL(acpi_get_devices); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 592 | |
| 593 | /******************************************************************************* |
| 594 | * |
| 595 | * FUNCTION: acpi_attach_data |
| 596 | * |
| 597 | * PARAMETERS: obj_handle - Namespace node |
| 598 | * Handler - Handler for this attachment |
| 599 | * Data - Pointer to data to be attached |
| 600 | * |
| 601 | * RETURN: Status |
| 602 | * |
| 603 | * DESCRIPTION: Attach arbitrary data and handler to a namespace node. |
| 604 | * |
| 605 | ******************************************************************************/ |
| 606 | |
| 607 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 608 | acpi_attach_data(acpi_handle obj_handle, |
| 609 | acpi_object_handler handler, void *data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 611 | struct acpi_namespace_node *node; |
| 612 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
| 614 | /* Parameter validation */ |
| 615 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 616 | if (!obj_handle || !handler || !data) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | return (AE_BAD_PARAMETER); |
| 618 | } |
| 619 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 620 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 621 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | return (status); |
| 623 | } |
| 624 | |
| 625 | /* Convert and validate the handle */ |
| 626 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 627 | node = acpi_ns_map_handle_to_node(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | if (!node) { |
| 629 | status = AE_BAD_PARAMETER; |
| 630 | goto unlock_and_exit; |
| 631 | } |
| 632 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 633 | status = acpi_ns_attach_data(node, handler, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 635 | unlock_and_exit: |
| 636 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | return (status); |
| 638 | } |
| 639 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 640 | /******************************************************************************* |
| 641 | * |
| 642 | * FUNCTION: acpi_detach_data |
| 643 | * |
| 644 | * PARAMETERS: obj_handle - Namespace node handle |
| 645 | * Handler - Handler used in call to acpi_attach_data |
| 646 | * |
| 647 | * RETURN: Status |
| 648 | * |
| 649 | * DESCRIPTION: Remove data that was previously attached to a node. |
| 650 | * |
| 651 | ******************************************************************************/ |
| 652 | |
| 653 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 654 | acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 656 | struct acpi_namespace_node *node; |
| 657 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | |
| 659 | /* Parameter validation */ |
| 660 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 661 | if (!obj_handle || !handler) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 662 | return (AE_BAD_PARAMETER); |
| 663 | } |
| 664 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 665 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 666 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | return (status); |
| 668 | } |
| 669 | |
| 670 | /* Convert and validate the handle */ |
| 671 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 672 | node = acpi_ns_map_handle_to_node(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | if (!node) { |
| 674 | status = AE_BAD_PARAMETER; |
| 675 | goto unlock_and_exit; |
| 676 | } |
| 677 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 678 | status = acpi_ns_detach_data(node, handler); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 679 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 680 | unlock_and_exit: |
| 681 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | return (status); |
| 683 | } |
| 684 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | /******************************************************************************* |
| 686 | * |
| 687 | * FUNCTION: acpi_get_data |
| 688 | * |
| 689 | * PARAMETERS: obj_handle - Namespace node |
| 690 | * Handler - Handler used in call to attach_data |
| 691 | * Data - Where the data is returned |
| 692 | * |
| 693 | * RETURN: Status |
| 694 | * |
| 695 | * DESCRIPTION: Retrieve data that was previously attached to a namespace node. |
| 696 | * |
| 697 | ******************************************************************************/ |
| 698 | |
| 699 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 700 | acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 702 | struct acpi_namespace_node *node; |
| 703 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | |
| 705 | /* Parameter validation */ |
| 706 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 707 | if (!obj_handle || !handler || !data) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | return (AE_BAD_PARAMETER); |
| 709 | } |
| 710 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 711 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
| 712 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 713 | return (status); |
| 714 | } |
| 715 | |
| 716 | /* Convert and validate the handle */ |
| 717 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 718 | node = acpi_ns_map_handle_to_node(obj_handle); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | if (!node) { |
| 720 | status = AE_BAD_PARAMETER; |
| 721 | goto unlock_and_exit; |
| 722 | } |
| 723 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 724 | status = acpi_ns_get_attached_data(node, handler, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 726 | unlock_and_exit: |
| 727 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 728 | return (status); |
| 729 | } |