aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/namespace/nsxfeval.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/namespace/nsxfeval.c')
-rw-r--r--drivers/acpi/namespace/nsxfeval.c203
1 files changed, 103 insertions, 100 deletions
diff --git a/drivers/acpi/namespace/nsxfeval.c b/drivers/acpi/namespace/nsxfeval.c
index a95f636dc35d..6d9bd45af30a 100644
--- a/drivers/acpi/namespace/nsxfeval.c
+++ b/drivers/acpi/namespace/nsxfeval.c
@@ -42,8 +42,6 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45#include <linux/module.h>
46
47#include <acpi/acpi.h> 45#include <acpi/acpi.h>
48#include <acpi/acnamesp.h> 46#include <acpi/acnamesp.h>
49#include <acpi/acinterp.h> 47#include <acpi/acinterp.h>
@@ -51,6 +49,7 @@
51#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
52ACPI_MODULE_NAME("nsxfeval") 50ACPI_MODULE_NAME("nsxfeval")
53 51
52#ifdef ACPI_FUTURE_USAGE
54/******************************************************************************* 53/*******************************************************************************
55 * 54 *
56 * FUNCTION: acpi_evaluate_object_typed 55 * FUNCTION: acpi_evaluate_object_typed
@@ -71,18 +70,17 @@ ACPI_MODULE_NAME("nsxfeval")
71 * be valid (non-null) 70 * be valid (non-null)
72 * 71 *
73 ******************************************************************************/ 72 ******************************************************************************/
74#ifdef ACPI_FUTURE_USAGE
75acpi_status 73acpi_status
76acpi_evaluate_object_typed(acpi_handle handle, 74acpi_evaluate_object_typed(acpi_handle handle,
77 acpi_string pathname, 75 acpi_string pathname,
78 struct acpi_object_list *external_params, 76 struct acpi_object_list * external_params,
79 struct acpi_buffer *return_buffer, 77 struct acpi_buffer * return_buffer,
80 acpi_object_type return_type) 78 acpi_object_type return_type)
81{ 79{
82 acpi_status status; 80 acpi_status status;
83 u8 must_free = FALSE; 81 u8 must_free = FALSE;
84 82
85 ACPI_FUNCTION_TRACE("acpi_evaluate_object_typed"); 83 ACPI_FUNCTION_TRACE(acpi_evaluate_object_typed);
86 84
87 /* Return buffer must be valid */ 85 /* Return buffer must be valid */
88 86
@@ -110,6 +108,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
110 } 108 }
111 109
112 if (return_buffer->length == 0) { 110 if (return_buffer->length == 0) {
111
113 /* Error because caller specifically asked for a return value */ 112 /* Error because caller specifically asked for a return value */
114 113
115 ACPI_ERROR((AE_INFO, "No return value")); 114 ACPI_ERROR((AE_INFO, "No return value"));
@@ -131,6 +130,7 @@ acpi_evaluate_object_typed(acpi_handle handle,
131 acpi_ut_get_type_name(return_type))); 130 acpi_ut_get_type_name(return_type)));
132 131
133 if (must_free) { 132 if (must_free) {
133
134 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */ 134 /* Caller used ACPI_ALLOCATE_BUFFER, free the return buffer */
135 135
136 acpi_os_free(return_buffer->pointer); 136 acpi_os_free(return_buffer->pointer);
@@ -140,6 +140,8 @@ acpi_evaluate_object_typed(acpi_handle handle,
140 return_buffer->length = 0; 140 return_buffer->length = 0;
141 return_ACPI_STATUS(AE_TYPE); 141 return_ACPI_STATUS(AE_TYPE);
142} 142}
143
144ACPI_EXPORT_SYMBOL(acpi_evaluate_object_typed)
143#endif /* ACPI_FUTURE_USAGE */ 145#endif /* ACPI_FUTURE_USAGE */
144 146
145/******************************************************************************* 147/*******************************************************************************
@@ -161,7 +163,6 @@ acpi_evaluate_object_typed(acpi_handle handle,
161 * be valid (non-null) 163 * be valid (non-null)
162 * 164 *
163 ******************************************************************************/ 165 ******************************************************************************/
164
165acpi_status 166acpi_status
166acpi_evaluate_object(acpi_handle handle, 167acpi_evaluate_object(acpi_handle handle,
167 acpi_string pathname, 168 acpi_string pathname,
@@ -170,51 +171,61 @@ acpi_evaluate_object(acpi_handle handle,
170{ 171{
171 acpi_status status; 172 acpi_status status;
172 acpi_status status2; 173 acpi_status status2;
173 struct acpi_parameter_info info; 174 struct acpi_evaluate_info *info;
174 acpi_size buffer_space_needed; 175 acpi_size buffer_space_needed;
175 u32 i; 176 u32 i;
176 177
177 ACPI_FUNCTION_TRACE("acpi_evaluate_object"); 178 ACPI_FUNCTION_TRACE(acpi_evaluate_object);
178 179
179 info.node = handle; 180 /* Allocate and initialize the evaluation information block */
180 info.parameters = NULL; 181
181 info.return_object = NULL; 182 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
182 info.parameter_type = ACPI_PARAM_ARGS; 183 if (!info) {
184 return_ACPI_STATUS(AE_NO_MEMORY);
185 }
186
187 info->pathname = pathname;
188 info->parameter_type = ACPI_PARAM_ARGS;
189
190 /* Convert and validate the device handle */
191
192 info->prefix_node = acpi_ns_map_handle_to_node(handle);
193 if (!info->prefix_node) {
194 status = AE_BAD_PARAMETER;
195 goto cleanup;
196 }
183 197
184 /* 198 /*
185 * If there are parameters to be passed to the object 199 * If there are parameters to be passed to a control method, the external
186 * (which must be a control method), the external objects 200 * objects must all be converted to internal objects
187 * must be converted to internal objects
188 */ 201 */
189 if (external_params && external_params->count) { 202 if (external_params && external_params->count) {
190 /* 203 /*
191 * Allocate a new parameter block for the internal objects 204 * Allocate a new parameter block for the internal objects
192 * Add 1 to count to allow for null terminated internal list 205 * Add 1 to count to allow for null terminated internal list
193 */ 206 */
194 info.parameters = ACPI_MEM_CALLOCATE(((acpi_size) 207 info->parameters = ACPI_ALLOCATE_ZEROED(((acpi_size)
195 external_params->count + 208 external_params->
196 1) * sizeof(void *)); 209 count +
197 if (!info.parameters) { 210 1) * sizeof(void *));
198 return_ACPI_STATUS(AE_NO_MEMORY); 211 if (!info->parameters) {
212 status = AE_NO_MEMORY;
213 goto cleanup;
199 } 214 }
200 215
201 /* 216 /* Convert each external object in the list to an internal object */
202 * Convert each external object in the list to an 217
203 * internal object
204 */
205 for (i = 0; i < external_params->count; i++) { 218 for (i = 0; i < external_params->count; i++) {
206 status = 219 status =
207 acpi_ut_copy_eobject_to_iobject(&external_params-> 220 acpi_ut_copy_eobject_to_iobject(&external_params->
208 pointer[i], 221 pointer[i],
209 &info. 222 &info->
210 parameters[i]); 223 parameters[i]);
211 if (ACPI_FAILURE(status)) { 224 if (ACPI_FAILURE(status)) {
212 acpi_ut_delete_internal_object_list(info. 225 goto cleanup;
213 parameters);
214 return_ACPI_STATUS(status);
215 } 226 }
216 } 227 }
217 info.parameters[external_params->count] = NULL; 228 info->parameters[external_params->count] = NULL;
218 } 229 }
219 230
220 /* 231 /*
@@ -224,43 +235,31 @@ acpi_evaluate_object(acpi_handle handle,
224 * 3) Valid handle 235 * 3) Valid handle
225 */ 236 */
226 if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) { 237 if ((pathname) && (acpi_ns_valid_root_prefix(pathname[0]))) {
227 /* 238
228 * The path is fully qualified, just evaluate by name 239 /* The path is fully qualified, just evaluate by name */
229 */ 240
230 status = acpi_ns_evaluate_by_name(pathname, &info); 241 info->prefix_node = NULL;
242 status = acpi_ns_evaluate(info);
231 } else if (!handle) { 243 } else if (!handle) {
232 /* 244 /*
233 * A handle is optional iff a fully qualified pathname 245 * A handle is optional iff a fully qualified pathname is specified.
234 * is specified. Since we've already handled fully 246 * Since we've already handled fully qualified names above, this is
235 * qualified names above, this is an error 247 * an error
236 */ 248 */
237 if (!pathname) { 249 if (!pathname) {
238 ACPI_ERROR((AE_INFO, 250 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
239 "Both Handle and Pathname are NULL")); 251 "Both Handle and Pathname are NULL"));
240 } else { 252 } else {
241 ACPI_ERROR((AE_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
242 "Handle is NULL and Pathname is relative")); 254 "Null Handle with relative pathname [%s]",
255 pathname));
243 } 256 }
244 257
245 status = AE_BAD_PARAMETER; 258 status = AE_BAD_PARAMETER;
246 } else { 259 } else {
247 /* 260 /* We have a namespace a node and a possible relative path */
248 * We get here if we have a handle -- and if we have a 261
249 * pathname it is relative. The handle will be validated 262 status = acpi_ns_evaluate(info);
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 */
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);
263 }
264 } 263 }
265 264
266 /* 265 /*
@@ -268,10 +267,10 @@ acpi_evaluate_object(acpi_handle handle,
268 * copy the return value to an external object. 267 * copy the return value to an external object.
269 */ 268 */
270 if (return_buffer) { 269 if (return_buffer) {
271 if (!info.return_object) { 270 if (!info->return_object) {
272 return_buffer->length = 0; 271 return_buffer->length = 0;
273 } else { 272 } else {
274 if (ACPI_GET_DESCRIPTOR_TYPE(info.return_object) == 273 if (ACPI_GET_DESCRIPTOR_TYPE(info->return_object) ==
275 ACPI_DESC_TYPE_NAMED) { 274 ACPI_DESC_TYPE_NAMED) {
276 /* 275 /*
277 * If we received a NS Node as a return object, this means that 276 * If we received a NS Node as a return object, this means that
@@ -282,19 +281,19 @@ acpi_evaluate_object(acpi_handle handle,
282 * support for various types at a later date if necessary. 281 * support for various types at a later date if necessary.
283 */ 282 */
284 status = AE_TYPE; 283 status = AE_TYPE;
285 info.return_object = NULL; /* No need to delete a NS Node */ 284 info->return_object = NULL; /* No need to delete a NS Node */
286 return_buffer->length = 0; 285 return_buffer->length = 0;
287 } 286 }
288 287
289 if (ACPI_SUCCESS(status)) { 288 if (ACPI_SUCCESS(status)) {
290 /* 289
291 * Find out how large a buffer is needed 290 /* Get the size of the returned object */
292 * to contain the returned object 291
293 */
294 status = 292 status =
295 acpi_ut_get_object_size(info.return_object, 293 acpi_ut_get_object_size(info->return_object,
296 &buffer_space_needed); 294 &buffer_space_needed);
297 if (ACPI_SUCCESS(status)) { 295 if (ACPI_SUCCESS(status)) {
296
298 /* Validate/Allocate/Clear caller buffer */ 297 /* Validate/Allocate/Clear caller buffer */
299 298
300 status = 299 status =
@@ -303,7 +302,8 @@ acpi_evaluate_object(acpi_handle handle,
303 buffer_space_needed); 302 buffer_space_needed);
304 if (ACPI_FAILURE(status)) { 303 if (ACPI_FAILURE(status)) {
305 /* 304 /*
306 * Caller's buffer is too small or a new one can't be allocated 305 * Caller's buffer is too small or a new one can't
306 * be allocated
307 */ 307 */
308 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 308 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
309 "Needed buffer size %X, %s\n", 309 "Needed buffer size %X, %s\n",
@@ -312,12 +312,11 @@ acpi_evaluate_object(acpi_handle handle,
312 acpi_format_exception 312 acpi_format_exception
313 (status))); 313 (status)));
314 } else { 314 } else {
315 /* 315 /* We have enough space for the object, build it */
316 * We have enough space for the object, build it 316
317 */
318 status = 317 status =
319 acpi_ut_copy_iobject_to_eobject 318 acpi_ut_copy_iobject_to_eobject
320 (info.return_object, 319 (info->return_object,
321 return_buffer); 320 return_buffer);
322 } 321 }
323 } 322 }
@@ -325,35 +324,37 @@ acpi_evaluate_object(acpi_handle handle,
325 } 324 }
326 } 325 }
327 326
328 if (info.return_object) { 327 if (info->return_object) {
329 /* 328 /*
330 * Delete the internal return object. NOTE: Interpreter 329 * Delete the internal return object. NOTE: Interpreter must be
331 * must be locked to avoid race condition. 330 * locked to avoid race condition.
332 */ 331 */
333 status2 = acpi_ex_enter_interpreter(); 332 status2 = acpi_ex_enter_interpreter();
334 if (ACPI_SUCCESS(status2)) { 333 if (ACPI_SUCCESS(status2)) {
335 /* 334
336 * Delete the internal return object. (Or at least 335 /* Remove one reference on the return object (should delete it) */
337 * decrement the reference count by one) 336
338 */ 337 acpi_ut_remove_reference(info->return_object);
339 acpi_ut_remove_reference(info.return_object);
340 acpi_ex_exit_interpreter(); 338 acpi_ex_exit_interpreter();
341 } 339 }
342 } 340 }
343 341
344 /* 342 cleanup:
345 * Free the input parameter list (if we created one), 343
346 */ 344 /* Free the input parameter list (if we created one) */
347 if (info.parameters) { 345
346 if (info->parameters) {
347
348 /* Free the allocated parameter block */ 348 /* Free the allocated parameter block */
349 349
350 acpi_ut_delete_internal_object_list(info.parameters); 350 acpi_ut_delete_internal_object_list(info->parameters);
351 } 351 }
352 352
353 ACPI_FREE(info);
353 return_ACPI_STATUS(status); 354 return_ACPI_STATUS(status);
354} 355}
355 356
356EXPORT_SYMBOL(acpi_evaluate_object); 357ACPI_EXPORT_SYMBOL(acpi_evaluate_object)
357 358
358/******************************************************************************* 359/*******************************************************************************
359 * 360 *
@@ -384,7 +385,6 @@ EXPORT_SYMBOL(acpi_evaluate_object);
384 * function, etc. 385 * function, etc.
385 * 386 *
386 ******************************************************************************/ 387 ******************************************************************************/
387
388acpi_status 388acpi_status
389acpi_walk_namespace(acpi_object_type type, 389acpi_walk_namespace(acpi_object_type type,
390 acpi_handle start_object, 390 acpi_handle start_object,
@@ -394,7 +394,7 @@ acpi_walk_namespace(acpi_object_type type,
394{ 394{
395 acpi_status status; 395 acpi_status status;
396 396
397 ACPI_FUNCTION_TRACE("acpi_walk_namespace"); 397 ACPI_FUNCTION_TRACE(acpi_walk_namespace);
398 398
399 /* Parameter validation */ 399 /* Parameter validation */
400 400
@@ -421,7 +421,7 @@ acpi_walk_namespace(acpi_object_type type,
421 return_ACPI_STATUS(status); 421 return_ACPI_STATUS(status);
422} 422}
423 423
424EXPORT_SYMBOL(acpi_walk_namespace); 424ACPI_EXPORT_SYMBOL(acpi_walk_namespace)
425 425
426/******************************************************************************* 426/*******************************************************************************
427 * 427 *
@@ -436,7 +436,6 @@ EXPORT_SYMBOL(acpi_walk_namespace);
436 * on that. 436 * on that.
437 * 437 *
438 ******************************************************************************/ 438 ******************************************************************************/
439
440static acpi_status 439static acpi_status
441acpi_ns_get_device_callback(acpi_handle obj_handle, 440acpi_ns_get_device_callback(acpi_handle obj_handle,
442 u32 nesting_level, 441 u32 nesting_level,
@@ -473,6 +472,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
473 } 472 }
474 473
475 if (!(flags & ACPI_STA_DEVICE_PRESENT)) { 474 if (!(flags & ACPI_STA_DEVICE_PRESENT)) {
475
476 /* Don't examine children of the device if not present */ 476 /* Don't examine children of the device if not present */
477 477
478 return (AE_CTRL_DEPTH); 478 return (AE_CTRL_DEPTH);
@@ -489,6 +489,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
489 } 489 }
490 490
491 if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) { 491 if (ACPI_STRNCMP(hid.value, info->hid, sizeof(hid.value)) != 0) {
492
492 /* Get the list of Compatible IDs */ 493 /* Get the list of Compatible IDs */
493 494
494 status = acpi_ut_execute_CID(node, &cid); 495 status = acpi_ut_execute_CID(node, &cid);
@@ -505,11 +506,11 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
505 sizeof(struct 506 sizeof(struct
506 acpi_compatible_id)) != 507 acpi_compatible_id)) !=
507 0) { 508 0) {
508 ACPI_MEM_FREE(cid); 509 ACPI_FREE(cid);
509 return (AE_OK); 510 return (AE_OK);
510 } 511 }
511 } 512 }
512 ACPI_MEM_FREE(cid); 513 ACPI_FREE(cid);
513 } 514 }
514 } 515 }
515 516
@@ -551,7 +552,7 @@ acpi_get_devices(char *HID,
551 acpi_status status; 552 acpi_status status;
552 struct acpi_get_devices_info info; 553 struct acpi_get_devices_info info;
553 554
554 ACPI_FUNCTION_TRACE("acpi_get_devices"); 555 ACPI_FUNCTION_TRACE(acpi_get_devices);
555 556
556 /* Parameter validation */ 557 /* Parameter validation */
557 558
@@ -563,9 +564,9 @@ acpi_get_devices(char *HID,
563 * We're going to call their callback from OUR callback, so we need 564 * We're going to call their callback from OUR callback, so we need
564 * to know what it is, and their context parameter. 565 * to know what it is, and their context parameter.
565 */ 566 */
567 info.hid = HID;
566 info.context = context; 568 info.context = context;
567 info.user_function = user_function; 569 info.user_function = user_function;
568 info.hid = HID;
569 570
570 /* 571 /*
571 * Lock the namespace around the walk. 572 * Lock the namespace around the walk.
@@ -578,9 +579,8 @@ acpi_get_devices(char *HID,
578 return_ACPI_STATUS(status); 579 return_ACPI_STATUS(status);
579 } 580 }
580 581
581 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, 582 status = acpi_ns_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
582 ACPI_ROOT_OBJECT, ACPI_UINT32_MAX, 583 ACPI_UINT32_MAX, ACPI_NS_WALK_UNLOCK,
583 ACPI_NS_WALK_UNLOCK,
584 acpi_ns_get_device_callback, &info, 584 acpi_ns_get_device_callback, &info,
585 return_value); 585 return_value);
586 586
@@ -588,7 +588,7 @@ acpi_get_devices(char *HID,
588 return_ACPI_STATUS(status); 588 return_ACPI_STATUS(status);
589} 589}
590 590
591EXPORT_SYMBOL(acpi_get_devices); 591ACPI_EXPORT_SYMBOL(acpi_get_devices)
592 592
593/******************************************************************************* 593/*******************************************************************************
594 * 594 *
@@ -603,7 +603,6 @@ EXPORT_SYMBOL(acpi_get_devices);
603 * DESCRIPTION: Attach arbitrary data and handler to a namespace node. 603 * DESCRIPTION: Attach arbitrary data and handler to a namespace node.
604 * 604 *
605 ******************************************************************************/ 605 ******************************************************************************/
606
607acpi_status 606acpi_status
608acpi_attach_data(acpi_handle obj_handle, 607acpi_attach_data(acpi_handle obj_handle,
609 acpi_object_handler handler, void *data) 608 acpi_object_handler handler, void *data)
@@ -637,6 +636,8 @@ acpi_attach_data(acpi_handle obj_handle,
637 return (status); 636 return (status);
638} 637}
639 638
639ACPI_EXPORT_SYMBOL(acpi_attach_data)
640
640/******************************************************************************* 641/*******************************************************************************
641 * 642 *
642 * FUNCTION: acpi_detach_data 643 * FUNCTION: acpi_detach_data
@@ -649,7 +650,6 @@ acpi_attach_data(acpi_handle obj_handle,
649 * DESCRIPTION: Remove data that was previously attached to a node. 650 * DESCRIPTION: Remove data that was previously attached to a node.
650 * 651 *
651 ******************************************************************************/ 652 ******************************************************************************/
652
653acpi_status 653acpi_status
654acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler) 654acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
655{ 655{
@@ -682,6 +682,8 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
682 return (status); 682 return (status);
683} 683}
684 684
685ACPI_EXPORT_SYMBOL(acpi_detach_data)
686
685/******************************************************************************* 687/*******************************************************************************
686 * 688 *
687 * FUNCTION: acpi_get_data 689 * FUNCTION: acpi_get_data
@@ -695,7 +697,6 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
695 * DESCRIPTION: Retrieve data that was previously attached to a namespace node. 697 * DESCRIPTION: Retrieve data that was previously attached to a namespace node.
696 * 698 *
697 ******************************************************************************/ 699 ******************************************************************************/
698
699acpi_status 700acpi_status
700acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data) 701acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
701{ 702{
@@ -727,3 +728,5 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
727 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 728 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
728 return (status); 729 return (status);
729} 730}
731
732ACPI_EXPORT_SYMBOL(acpi_get_data)