aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2009-12-15 22:27:39 -0500
committerLen Brown <len.brown@intel.com>2009-12-15 22:27:39 -0500
commit173cc11a6e10c38ff7d4949b48e8d2eb0aee3e05 (patch)
tree44ac9a6fe4e9c51b2c54918aa338df7eda96b0a5 /drivers/acpi
parent8bea8672edfca7ec5f661cafb218f1205863b343 (diff)
parent88e5071525ad6814be3a8a2792ce9e81a0cca22a (diff)
Merge branch 'acpica' into release
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpica/acnamesp.h9
-rw-r--r--drivers/acpi/acpica/acobject.h6
-rw-r--r--drivers/acpi/acpica/dsmethod.c2
-rw-r--r--drivers/acpi/acpica/dswload.c64
-rw-r--r--drivers/acpi/acpica/evregion.c4
-rw-r--r--drivers/acpi/acpica/evrgnini.c15
-rw-r--r--drivers/acpi/acpica/evxface.c4
-rw-r--r--drivers/acpi/acpica/evxfevnt.c4
-rw-r--r--drivers/acpi/acpica/evxfregn.c4
-rw-r--r--drivers/acpi/acpica/exmutex.c18
-rw-r--r--drivers/acpi/acpica/nsaccess.c2
-rw-r--r--drivers/acpi/acpica/nsdump.c2
-rw-r--r--drivers/acpi/acpica/nseval.c18
-rw-r--r--drivers/acpi/acpica/nsnames.c2
-rw-r--r--drivers/acpi/acpica/nspredef.c93
-rw-r--r--drivers/acpi/acpica/nsrepair.c447
-rw-r--r--drivers/acpi/acpica/nsrepair2.c195
-rw-r--r--drivers/acpi/acpica/nsutils.c57
-rw-r--r--drivers/acpi/acpica/nsxfeval.c10
-rw-r--r--drivers/acpi/acpica/nsxfname.c10
-rw-r--r--drivers/acpi/acpica/nsxfobj.c14
-rw-r--r--drivers/acpi/acpica/psxface.c3
-rw-r--r--drivers/acpi/acpica/rsxface.c2
-rw-r--r--drivers/acpi/acpica/utcopy.c27
24 files changed, 715 insertions, 297 deletions
diff --git a/drivers/acpi/acpica/acnamesp.h b/drivers/acpi/acpica/acnamesp.h
index ab83919dda61..61edb156e8d0 100644
--- a/drivers/acpi/acpica/acnamesp.h
+++ b/drivers/acpi/acpica/acnamesp.h
@@ -296,6 +296,11 @@ acpi_ns_complex_repairs(struct acpi_predefined_data *data,
296 acpi_status validate_status, 296 acpi_status validate_status,
297 union acpi_operand_object **return_object_ptr); 297 union acpi_operand_object **return_object_ptr);
298 298
299void
300acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
301 u8 package_type,
302 union acpi_operand_object *obj_desc);
303
299/* 304/*
300 * nssearch - Namespace searching and entry 305 * nssearch - Namespace searching and entry
301 */ 306 */
@@ -354,9 +359,7 @@ acpi_ns_externalize_name(u32 internal_name_length,
354 const char *internal_name, 359 const char *internal_name,
355 u32 * converted_name_length, char **converted_name); 360 u32 * converted_name_length, char **converted_name);
356 361
357struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle); 362struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle);
358
359acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node);
360 363
361void acpi_ns_terminate(void); 364void acpi_ns_terminate(void);
362 365
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index b39d682a2140..64062b1be3ee 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -180,7 +180,11 @@ struct acpi_object_method {
180 u8 sync_level; 180 u8 sync_level;
181 union acpi_operand_object *mutex; 181 union acpi_operand_object *mutex;
182 u8 *aml_start; 182 u8 *aml_start;
183 ACPI_INTERNAL_METHOD implementation; 183 union {
184 ACPI_INTERNAL_METHOD implementation;
185 union acpi_operand_object *handler;
186 } extra;
187
184 u32 aml_length; 188 u32 aml_length;
185 u8 thread_count; 189 u8 thread_count;
186 acpi_owner_id owner_id; 190 acpi_owner_id owner_id;
diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c
index 567a4899a018..e786f9fd767f 100644
--- a/drivers/acpi/acpica/dsmethod.c
+++ b/drivers/acpi/acpica/dsmethod.c
@@ -414,7 +414,7 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread,
414 /* Invoke an internal method if necessary */ 414 /* Invoke an internal method if necessary */
415 415
416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 416 if (obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
417 status = obj_desc->method.implementation(next_walk_state); 417 status = obj_desc->method.extra.implementation(next_walk_state);
418 if (status == AE_OK) { 418 if (status == AE_OK) {
419 status = AE_CTRL_TERMINATE; 419 status = AE_CTRL_TERMINATE;
420 } 420 }
diff --git a/drivers/acpi/acpica/dswload.c b/drivers/acpi/acpica/dswload.c
index 10fc78517843..b40513dd6a6a 100644
--- a/drivers/acpi/acpica/dswload.c
+++ b/drivers/acpi/acpica/dswload.c
@@ -212,18 +212,19 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
212 case ACPI_TYPE_BUFFER: 212 case ACPI_TYPE_BUFFER:
213 213
214 /* 214 /*
215 * These types we will allow, but we will change the type. This 215 * These types we will allow, but we will change the type.
216 * enables some existing code of the form: 216 * This enables some existing code of the form:
217 * 217 *
218 * Name (DEB, 0) 218 * Name (DEB, 0)
219 * Scope (DEB) { ... } 219 * Scope (DEB) { ... }
220 * 220 *
221 * Note: silently change the type here. On the second pass, we will report 221 * Note: silently change the type here. On the second pass,
222 * a warning 222 * we will report a warning
223 */ 223 */
224 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 224 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
225 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)\n", 225 "Type override - [%4.4s] had invalid type (%s) "
226 path, 226 "for Scope operator, changed to type ANY\n",
227 acpi_ut_get_node_name(node),
227 acpi_ut_get_type_name(node->type))); 228 acpi_ut_get_type_name(node->type)));
228 229
229 node->type = ACPI_TYPE_ANY; 230 node->type = ACPI_TYPE_ANY;
@@ -235,8 +236,10 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
235 /* All other types are an error */ 236 /* All other types are an error */
236 237
237 ACPI_ERROR((AE_INFO, 238 ACPI_ERROR((AE_INFO,
238 "Invalid type (%s) for target of Scope operator [%4.4s] (Cannot override)", 239 "Invalid type (%s) for target of "
239 acpi_ut_get_type_name(node->type), path)); 240 "Scope operator [%4.4s] (Cannot override)",
241 acpi_ut_get_type_name(node->type),
242 acpi_ut_get_node_name(node)));
240 243
241 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 244 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
242 } 245 }
@@ -697,15 +700,16 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
697 case ACPI_TYPE_BUFFER: 700 case ACPI_TYPE_BUFFER:
698 701
699 /* 702 /*
700 * These types we will allow, but we will change the type. This 703 * These types we will allow, but we will change the type.
701 * enables some existing code of the form: 704 * This enables some existing code of the form:
702 * 705 *
703 * Name (DEB, 0) 706 * Name (DEB, 0)
704 * Scope (DEB) { ... } 707 * Scope (DEB) { ... }
705 */ 708 */
706 ACPI_WARNING((AE_INFO, 709 ACPI_WARNING((AE_INFO,
707 "Type override - [%4.4s] had invalid type (%s) for Scope operator, changed to (Scope)", 710 "Type override - [%4.4s] had invalid type (%s) "
708 buffer_ptr, 711 "for Scope operator, changed to type ANY\n",
712 acpi_ut_get_node_name(node),
709 acpi_ut_get_type_name(node->type))); 713 acpi_ut_get_type_name(node->type)));
710 714
711 node->type = ACPI_TYPE_ANY; 715 node->type = ACPI_TYPE_ANY;
@@ -717,9 +721,10 @@ acpi_ds_load2_begin_op(struct acpi_walk_state *walk_state,
717 /* All other types are an error */ 721 /* All other types are an error */
718 722
719 ACPI_ERROR((AE_INFO, 723 ACPI_ERROR((AE_INFO,
720 "Invalid type (%s) for target of Scope operator [%4.4s]", 724 "Invalid type (%s) for target of "
725 "Scope operator [%4.4s] (Cannot override)",
721 acpi_ut_get_type_name(node->type), 726 acpi_ut_get_type_name(node->type),
722 buffer_ptr)); 727 acpi_ut_get_node_name(node)));
723 728
724 return (AE_AML_OPERAND_TYPE); 729 return (AE_AML_OPERAND_TYPE);
725 } 730 }
@@ -1047,9 +1052,22 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1047 } 1052 }
1048 1053
1049 /* 1054 /*
1050 * If we are executing a method, initialize the region 1055 * The op_region is not fully parsed at this time. The only valid
1056 * argument is the space_id. (We must save the address of the
1057 * AML of the address and length operands)
1058 *
1059 * If we have a valid region, initialize it. The namespace is
1060 * unlocked at this point.
1061 *
1062 * Need to unlock interpreter if it is locked (if we are running
1063 * a control method), in order to allow _REG methods to be run
1064 * during acpi_ev_initialize_region.
1051 */ 1065 */
1052 if (walk_state->method_node) { 1066 if (walk_state->method_node) {
1067 /*
1068 * Executing a method: initialize the region and unlock
1069 * the interpreter
1070 */
1053 status = 1071 status =
1054 acpi_ex_create_region(op->named.data, 1072 acpi_ex_create_region(op->named.data,
1055 op->named.length, 1073 op->named.length,
@@ -1058,21 +1076,17 @@ acpi_status acpi_ds_load2_end_op(struct acpi_walk_state *walk_state)
1058 if (ACPI_FAILURE(status)) { 1076 if (ACPI_FAILURE(status)) {
1059 return (status); 1077 return (status);
1060 } 1078 }
1061 }
1062 1079
1063 /* 1080 acpi_ex_exit_interpreter();
1064 * The op_region is not fully parsed at this time. Only valid 1081 }
1065 * argument is the space_id. (We must save the address of the
1066 * AML of the address and length operands)
1067 */
1068 1082
1069 /*
1070 * If we have a valid region, initialize it
1071 * Namespace is NOT locked at this point.
1072 */
1073 status = 1083 status =
1074 acpi_ev_initialize_region 1084 acpi_ev_initialize_region
1075 (acpi_ns_get_attached_object(node), FALSE); 1085 (acpi_ns_get_attached_object(node), FALSE);
1086 if (walk_state->method_node) {
1087 acpi_ex_enter_interpreter();
1088 }
1089
1076 if (ACPI_FAILURE(status)) { 1090 if (ACPI_FAILURE(status)) {
1077 /* 1091 /*
1078 * If AE_NOT_EXIST is returned, it is not fatal 1092 * If AE_NOT_EXIST is returned, it is not fatal
diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c
index 0bc807c33a56..5336d911fbf0 100644
--- a/drivers/acpi/acpica/evregion.c
+++ b/drivers/acpi/acpica/evregion.c
@@ -718,7 +718,7 @@ acpi_ev_install_handler(acpi_handle obj_handle,
718 718
719 /* Convert and validate the device handle */ 719 /* Convert and validate the device handle */
720 720
721 node = acpi_ns_map_handle_to_node(obj_handle); 721 node = acpi_ns_validate_handle(obj_handle);
722 if (!node) { 722 if (!node) {
723 return (AE_BAD_PARAMETER); 723 return (AE_BAD_PARAMETER);
724 } 724 }
@@ -1087,7 +1087,7 @@ acpi_ev_reg_run(acpi_handle obj_handle,
1087 1087
1088 /* Convert and validate the device handle */ 1088 /* Convert and validate the device handle */
1089 1089
1090 node = acpi_ns_map_handle_to_node(obj_handle); 1090 node = acpi_ns_validate_handle(obj_handle);
1091 if (!node) { 1091 if (!node) {
1092 return (AE_BAD_PARAMETER); 1092 return (AE_BAD_PARAMETER);
1093 } 1093 }
diff --git a/drivers/acpi/acpica/evrgnini.c b/drivers/acpi/acpica/evrgnini.c
index cf29c4953028..ff168052a332 100644
--- a/drivers/acpi/acpica/evrgnini.c
+++ b/drivers/acpi/acpica/evrgnini.c
@@ -575,6 +575,21 @@ acpi_ev_initialize_region(union acpi_operand_object *region_obj,
575 handler_obj = obj_desc->thermal_zone.handler; 575 handler_obj = obj_desc->thermal_zone.handler;
576 break; 576 break;
577 577
578 case ACPI_TYPE_METHOD:
579 /*
580 * If we are executing module level code, the original
581 * Node's object was replaced by this Method object and we
582 * saved the handler in the method object.
583 *
584 * See acpi_ns_exec_module_code
585 */
586 if (obj_desc->method.
587 flags & AOPOBJ_MODULE_LEVEL) {
588 handler_obj =
589 obj_desc->method.extra.handler;
590 }
591 break;
592
578 default: 593 default:
579 /* Ignore other objects */ 594 /* Ignore other objects */
580 break; 595 break;
diff --git a/drivers/acpi/acpica/evxface.c b/drivers/acpi/acpica/evxface.c
index 10b8543dd466..2fe0809d4eb2 100644
--- a/drivers/acpi/acpica/evxface.c
+++ b/drivers/acpi/acpica/evxface.c
@@ -259,7 +259,7 @@ acpi_install_notify_handler(acpi_handle device,
259 259
260 /* Convert and validate the device handle */ 260 /* Convert and validate the device handle */
261 261
262 node = acpi_ns_map_handle_to_node(device); 262 node = acpi_ns_validate_handle(device);
263 if (!node) { 263 if (!node) {
264 status = AE_BAD_PARAMETER; 264 status = AE_BAD_PARAMETER;
265 goto unlock_and_exit; 265 goto unlock_and_exit;
@@ -425,7 +425,7 @@ acpi_remove_notify_handler(acpi_handle device,
425 425
426 /* Convert and validate the device handle */ 426 /* Convert and validate the device handle */
427 427
428 node = acpi_ns_map_handle_to_node(device); 428 node = acpi_ns_validate_handle(device);
429 if (!node) { 429 if (!node) {
430 status = AE_BAD_PARAMETER; 430 status = AE_BAD_PARAMETER;
431 goto unlock_and_exit; 431 goto unlock_and_exit;
diff --git a/drivers/acpi/acpica/evxfevnt.c b/drivers/acpi/acpica/evxfevnt.c
index 4721f58fe42c..eed7a38d25f2 100644
--- a/drivers/acpi/acpica/evxfevnt.c
+++ b/drivers/acpi/acpica/evxfevnt.c
@@ -610,7 +610,7 @@ acpi_install_gpe_block(acpi_handle gpe_device,
610 return (status); 610 return (status);
611 } 611 }
612 612
613 node = acpi_ns_map_handle_to_node(gpe_device); 613 node = acpi_ns_validate_handle(gpe_device);
614 if (!node) { 614 if (!node) {
615 status = AE_BAD_PARAMETER; 615 status = AE_BAD_PARAMETER;
616 goto unlock_and_exit; 616 goto unlock_and_exit;
@@ -698,7 +698,7 @@ acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
698 return (status); 698 return (status);
699 } 699 }
700 700
701 node = acpi_ns_map_handle_to_node(gpe_device); 701 node = acpi_ns_validate_handle(gpe_device);
702 if (!node) { 702 if (!node) {
703 status = AE_BAD_PARAMETER; 703 status = AE_BAD_PARAMETER;
704 goto unlock_and_exit; 704 goto unlock_and_exit;
diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c
index 7c3d2d356ffb..c98aa7c2d67c 100644
--- a/drivers/acpi/acpica/evxfregn.c
+++ b/drivers/acpi/acpica/evxfregn.c
@@ -89,7 +89,7 @@ acpi_install_address_space_handler(acpi_handle device,
89 89
90 /* Convert and validate the device handle */ 90 /* Convert and validate the device handle */
91 91
92 node = acpi_ns_map_handle_to_node(device); 92 node = acpi_ns_validate_handle(device);
93 if (!node) { 93 if (!node) {
94 status = AE_BAD_PARAMETER; 94 status = AE_BAD_PARAMETER;
95 goto unlock_and_exit; 95 goto unlock_and_exit;
@@ -155,7 +155,7 @@ acpi_remove_address_space_handler(acpi_handle device,
155 155
156 /* Convert and validate the device handle */ 156 /* Convert and validate the device handle */
157 157
158 node = acpi_ns_map_handle_to_node(device); 158 node = acpi_ns_validate_handle(device);
159 if (!node || 159 if (!node ||
160 ((node->type != ACPI_TYPE_DEVICE) && 160 ((node->type != ACPI_TYPE_DEVICE) &&
161 (node->type != ACPI_TYPE_PROCESSOR) && 161 (node->type != ACPI_TYPE_PROCESSOR) &&
diff --git a/drivers/acpi/acpica/exmutex.c b/drivers/acpi/acpica/exmutex.c
index 2f0114202b05..3c456bd575d0 100644
--- a/drivers/acpi/acpica/exmutex.c
+++ b/drivers/acpi/acpica/exmutex.c
@@ -375,6 +375,15 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
375 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED); 375 return_ACPI_STATUS(AE_AML_MUTEX_NOT_ACQUIRED);
376 } 376 }
377 377
378 /* Must have a valid thread ID */
379
380 if (!walk_state->thread) {
381 ACPI_ERROR((AE_INFO,
382 "Cannot release Mutex [%4.4s], null thread info",
383 acpi_ut_get_node_name(obj_desc->mutex.node)));
384 return_ACPI_STATUS(AE_AML_INTERNAL);
385 }
386
378 /* 387 /*
379 * The Mutex is owned, but this thread must be the owner. 388 * The Mutex is owned, but this thread must be the owner.
380 * Special case for Global Lock, any thread can release 389 * Special case for Global Lock, any thread can release
@@ -392,15 +401,6 @@ acpi_ex_release_mutex(union acpi_operand_object *obj_desc,
392 return_ACPI_STATUS(AE_AML_NOT_OWNER); 401 return_ACPI_STATUS(AE_AML_NOT_OWNER);
393 } 402 }
394 403
395 /* Must have a valid thread ID */
396
397 if (!walk_state->thread) {
398 ACPI_ERROR((AE_INFO,
399 "Cannot release Mutex [%4.4s], null thread info",
400 acpi_ut_get_node_name(obj_desc->mutex.node)));
401 return_ACPI_STATUS(AE_AML_INTERNAL);
402 }
403
404 /* 404 /*
405 * The sync level of the mutex must be equal to the current sync level. In 405 * The sync level of the mutex must be equal to the current sync level. In
406 * other words, the current level means that at least one mutex at that 406 * other words, the current level means that at least one mutex at that
diff --git a/drivers/acpi/acpica/nsaccess.c b/drivers/acpi/acpica/nsaccess.c
index 9c3cdbe2d82a..d622ba770000 100644
--- a/drivers/acpi/acpica/nsaccess.c
+++ b/drivers/acpi/acpica/nsaccess.c
@@ -165,7 +165,7 @@ acpi_status acpi_ns_root_initialize(void)
165 165
166 obj_desc->method.method_flags = 166 obj_desc->method.method_flags =
167 AML_METHOD_INTERNAL_ONLY; 167 AML_METHOD_INTERNAL_ONLY;
168 obj_desc->method.implementation = 168 obj_desc->method.extra.implementation =
169 acpi_ut_osi_implementation; 169 acpi_ut_osi_implementation;
170#endif 170#endif
171 break; 171 break;
diff --git a/drivers/acpi/acpica/nsdump.c b/drivers/acpi/acpica/nsdump.c
index 2deb986861ca..e37836e27e29 100644
--- a/drivers/acpi/acpica/nsdump.c
+++ b/drivers/acpi/acpica/nsdump.c
@@ -180,7 +180,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
180 return (AE_OK); 180 return (AE_OK);
181 } 181 }
182 182
183 this_node = acpi_ns_map_handle_to_node(obj_handle); 183 this_node = acpi_ns_validate_handle(obj_handle);
184 if (!this_node) { 184 if (!this_node) {
185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n", 185 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Invalid object handle %p\n",
186 obj_handle)); 186 obj_handle));
diff --git a/drivers/acpi/acpica/nseval.c b/drivers/acpi/acpica/nseval.c
index f771e978c403..af9fe9103734 100644
--- a/drivers/acpi/acpica/nseval.c
+++ b/drivers/acpi/acpica/nseval.c
@@ -381,6 +381,18 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
381 method_obj->method.next_object); 381 method_obj->method.next_object);
382 type = acpi_ns_get_type(parent_node); 382 type = acpi_ns_get_type(parent_node);
383 383
384 /*
385 * Get the region handler and save it in the method object. We may need
386 * this if an operation region declaration causes a _REG method to be run.
387 *
388 * We can't do this in acpi_ps_link_module_code because
389 * acpi_gbl_root_node->Object is NULL at PASS1.
390 */
391 if ((type == ACPI_TYPE_DEVICE) && parent_node->object) {
392 method_obj->method.extra.handler =
393 parent_node->object->device.handler;
394 }
395
384 /* Must clear next_object (acpi_ns_attach_object needs the field) */ 396 /* Must clear next_object (acpi_ns_attach_object needs the field) */
385 397
386 method_obj->method.next_object = NULL; 398 method_obj->method.next_object = NULL;
@@ -415,6 +427,12 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
415 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n", 427 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "Executed module-level code at %p\n",
416 method_obj->method.aml_start)); 428 method_obj->method.aml_start));
417 429
430 /* Delete a possible implicit return value (in slack mode) */
431
432 if (info->return_object) {
433 acpi_ut_remove_reference(info->return_object);
434 }
435
418 /* Detach the temporary method object */ 436 /* Detach the temporary method object */
419 437
420 acpi_ns_detach_object(parent_node); 438 acpi_ns_detach_object(parent_node);
diff --git a/drivers/acpi/acpica/nsnames.c b/drivers/acpi/acpica/nsnames.c
index af8e6bcee07e..8f9a4875ce26 100644
--- a/drivers/acpi/acpica/nsnames.c
+++ b/drivers/acpi/acpica/nsnames.c
@@ -232,7 +232,7 @@ acpi_ns_handle_to_pathname(acpi_handle target_handle,
232 232
233 ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle); 233 ACPI_FUNCTION_TRACE_PTR(ns_handle_to_pathname, target_handle);
234 234
235 node = acpi_ns_map_handle_to_node(target_handle); 235 node = acpi_ns_validate_handle(target_handle);
236 if (!node) { 236 if (!node) {
237 return_ACPI_STATUS(AE_BAD_PARAMETER); 237 return_ACPI_STATUS(AE_BAD_PARAMETER);
238 } 238 }
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index b05f42903c86..d34fa59548f7 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -216,29 +216,38 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
216 data->pathname = pathname; 216 data->pathname = pathname;
217 217
218 /* 218 /*
219 * Check that the type of the return object is what is expected for 219 * Check that the type of the main return object is what is expected
220 * this predefined name 220 * for this predefined name
221 */ 221 */
222 status = acpi_ns_check_object_type(data, return_object_ptr, 222 status = acpi_ns_check_object_type(data, return_object_ptr,
223 predefined->info.expected_btypes, 223 predefined->info.expected_btypes,
224 ACPI_NOT_PACKAGE_ELEMENT); 224 ACPI_NOT_PACKAGE_ELEMENT);
225 if (ACPI_FAILURE(status)) { 225 if (ACPI_FAILURE(status)) {
226 goto check_validation_status; 226 goto exit;
227 } 227 }
228 228
229 /* For returned Package objects, check the type of all sub-objects */ 229 /*
230 230 * For returned Package objects, check the type of all sub-objects.
231 if (return_object->common.type == ACPI_TYPE_PACKAGE) { 231 * Note: Package may have been newly created by call above.
232 */
233 if ((*return_object_ptr)->common.type == ACPI_TYPE_PACKAGE) {
232 status = acpi_ns_check_package(data, return_object_ptr); 234 status = acpi_ns_check_package(data, return_object_ptr);
235 if (ACPI_FAILURE(status)) {
236 goto exit;
237 }
233 } 238 }
234 239
235 /* 240 /*
236 * Perform additional, more complicated repairs on a per-name 241 * The return object was OK, or it was successfully repaired above.
237 * basis. 242 * Now make some additional checks such as verifying that package
243 * objects are sorted correctly (if required) or buffer objects have
244 * the correct data width (bytes vs. dwords). These repairs are
245 * performed on a per-name basis, i.e., the code is specific to
246 * particular predefined names.
238 */ 247 */
239 status = acpi_ns_complex_repairs(data, node, status, return_object_ptr); 248 status = acpi_ns_complex_repairs(data, node, status, return_object_ptr);
240 249
241check_validation_status: 250exit:
242 /* 251 /*
243 * If the object validation failed or if we successfully repaired one 252 * If the object validation failed or if we successfully repaired one
244 * or more objects, mark the parent node to suppress further warning 253 * or more objects, mark the parent node to suppress further warning
@@ -427,6 +436,13 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
427 data->pathname, package->ret_info.type, 436 data->pathname, package->ret_info.type,
428 return_object->package.count)); 437 return_object->package.count));
429 438
439 /*
440 * For variable-length Packages, we can safely remove all embedded
441 * and trailing NULL package elements
442 */
443 acpi_ns_remove_null_elements(data, package->ret_info.type,
444 return_object);
445
430 /* Extract package count and elements array */ 446 /* Extract package count and elements array */
431 447
432 elements = return_object->package.elements; 448 elements = return_object->package.elements;
@@ -461,11 +477,11 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
461 if (count < expected_count) { 477 if (count < expected_count) {
462 goto package_too_small; 478 goto package_too_small;
463 } else if (count > expected_count) { 479 } else if (count > expected_count) {
464 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, 480 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
465 data->node_flags, 481 "%s: Return Package is larger than needed - "
466 "Return Package is larger than needed - " 482 "found %u, expected %u\n",
467 "found %u, expected %u", count, 483 data->pathname, count,
468 expected_count)); 484 expected_count));
469 } 485 }
470 486
471 /* Validate all elements of the returned package */ 487 /* Validate all elements of the returned package */
@@ -680,53 +696,18 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
680 union acpi_operand_object *sub_package; 696 union acpi_operand_object *sub_package;
681 union acpi_operand_object **sub_elements; 697 union acpi_operand_object **sub_elements;
682 acpi_status status; 698 acpi_status status;
683 u8 non_trailing_null = FALSE;
684 u32 expected_count; 699 u32 expected_count;
685 u32 i; 700 u32 i;
686 u32 j; 701 u32 j;
687 702
688 /* Validate each sub-Package in the parent Package */ 703 /*
689 704 * Validate each sub-Package in the parent Package
705 *
706 * NOTE: assumes list of sub-packages contains no NULL elements.
707 * Any NULL elements should have been removed by earlier call
708 * to acpi_ns_remove_null_elements.
709 */
690 for (i = 0; i < count; i++) { 710 for (i = 0; i < count; i++) {
691 /*
692 * Handling for NULL package elements. For now, we will simply allow
693 * a parent package with trailing NULL elements. This can happen if
694 * the package was defined to be longer than the initializer list.
695 * This is legal as per the ACPI specification. It is often used
696 * to allow for dynamic initialization of a Package.
697 *
698 * A future enhancement may be to simply truncate the package to
699 * remove the trailing NULL elements.
700 */
701 if (!(*elements)) {
702 if (!non_trailing_null) {
703
704 /* Ensure the remaining elements are all NULL */
705
706 for (j = 1; j < (count - i + 1); j++) {
707 if (elements[j]) {
708 non_trailing_null = TRUE;
709 }
710 }
711
712 if (!non_trailing_null) {
713
714 /* Ignore the trailing NULL elements */
715
716 return (AE_OK);
717 }
718 }
719
720 /* There are trailing non-null elements, issue warning */
721
722 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
723 data->node_flags,
724 "Found NULL element at package index %u",
725 i));
726 elements++;
727 continue;
728 }
729
730 sub_package = *elements; 711 sub_package = *elements;
731 sub_elements = sub_package->package.elements; 712 sub_elements = sub_package->package.elements;
732 713
diff --git a/drivers/acpi/acpica/nsrepair.c b/drivers/acpi/acpica/nsrepair.c
index d563f1a564a7..4fd1bdb056b2 100644
--- a/drivers/acpi/acpica/nsrepair.c
+++ b/drivers/acpi/acpica/nsrepair.c
@@ -45,13 +45,52 @@
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h" 46#include "acnamesp.h"
47#include "acinterp.h" 47#include "acinterp.h"
48#include "acpredef.h"
49 48
50#define _COMPONENT ACPI_NAMESPACE 49#define _COMPONENT ACPI_NAMESPACE
51ACPI_MODULE_NAME("nsrepair") 50ACPI_MODULE_NAME("nsrepair")
52 51
53/******************************************************************************* 52/*******************************************************************************
54 * 53 *
54 * This module attempts to repair or convert objects returned by the
55 * predefined methods to an object type that is expected, as per the ACPI
56 * specification. The need for this code is dictated by the many machines that
57 * return incorrect types for the standard predefined methods. Performing these
58 * conversions here, in one place, eliminates the need for individual ACPI
59 * device drivers to do the same. Note: Most of these conversions are different
60 * than the internal object conversion routines used for implicit object
61 * conversion.
62 *
63 * The following conversions can be performed as necessary:
64 *
65 * Integer -> String
66 * Integer -> Buffer
67 * String -> Integer
68 * String -> Buffer
69 * Buffer -> Integer
70 * Buffer -> String
71 * Buffer -> Package of Integers
72 * Package -> Package of one Package
73 *
74 ******************************************************************************/
75/* Local prototypes */
76static acpi_status
77acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
78 union acpi_operand_object **return_object);
79
80static acpi_status
81acpi_ns_convert_to_string(union acpi_operand_object *original_object,
82 union acpi_operand_object **return_object);
83
84static acpi_status
85acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
86 union acpi_operand_object **return_object);
87
88static acpi_status
89acpi_ns_convert_to_package(union acpi_operand_object *original_object,
90 union acpi_operand_object **return_object);
91
92/*******************************************************************************
93 *
55 * FUNCTION: acpi_ns_repair_object 94 * FUNCTION: acpi_ns_repair_object
56 * 95 *
57 * PARAMETERS: Data - Pointer to validation data structure 96 * PARAMETERS: Data - Pointer to validation data structure
@@ -68,6 +107,7 @@ ACPI_MODULE_NAME("nsrepair")
68 * not expected. 107 * not expected.
69 * 108 *
70 ******************************************************************************/ 109 ******************************************************************************/
110
71acpi_status 111acpi_status
72acpi_ns_repair_object(struct acpi_predefined_data *data, 112acpi_ns_repair_object(struct acpi_predefined_data *data,
73 u32 expected_btypes, 113 u32 expected_btypes,
@@ -76,32 +116,206 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
76{ 116{
77 union acpi_operand_object *return_object = *return_object_ptr; 117 union acpi_operand_object *return_object = *return_object_ptr;
78 union acpi_operand_object *new_object; 118 union acpi_operand_object *new_object;
79 acpi_size length;
80 acpi_status status; 119 acpi_status status;
81 120
121 ACPI_FUNCTION_NAME(ns_repair_object);
122
82 /* 123 /*
83 * At this point, we know that the type of the returned object was not 124 * At this point, we know that the type of the returned object was not
84 * one of the expected types for this predefined name. Attempt to 125 * one of the expected types for this predefined name. Attempt to
85 * repair the object. Only a limited number of repairs are possible. 126 * repair the object by converting it to one of the expected object
127 * types for this predefined name.
86 */ 128 */
87 switch (return_object->common.type) { 129 if (expected_btypes & ACPI_RTYPE_INTEGER) {
130 status = acpi_ns_convert_to_integer(return_object, &new_object);
131 if (ACPI_SUCCESS(status)) {
132 goto object_repaired;
133 }
134 }
135 if (expected_btypes & ACPI_RTYPE_STRING) {
136 status = acpi_ns_convert_to_string(return_object, &new_object);
137 if (ACPI_SUCCESS(status)) {
138 goto object_repaired;
139 }
140 }
141 if (expected_btypes & ACPI_RTYPE_BUFFER) {
142 status = acpi_ns_convert_to_buffer(return_object, &new_object);
143 if (ACPI_SUCCESS(status)) {
144 goto object_repaired;
145 }
146 }
147 if (expected_btypes & ACPI_RTYPE_PACKAGE) {
148 status = acpi_ns_convert_to_package(return_object, &new_object);
149 if (ACPI_SUCCESS(status)) {
150 goto object_repaired;
151 }
152 }
153
154 /* We cannot repair this object */
155
156 return (AE_AML_OPERAND_TYPE);
157
158 object_repaired:
159
160 /* Object was successfully repaired */
161
162 /*
163 * If the original object is a package element, we need to:
164 * 1. Set the reference count of the new object to match the
165 * reference count of the old object.
166 * 2. Decrement the reference count of the original object.
167 */
168 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
169 new_object->common.reference_count =
170 return_object->common.reference_count;
171
172 if (return_object->common.reference_count > 1) {
173 return_object->common.reference_count--;
174 }
175
176 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
177 "%s: Converted %s to expected %s at index %u\n",
178 data->pathname,
179 acpi_ut_get_object_type_name(return_object),
180 acpi_ut_get_object_type_name(new_object),
181 package_index));
182 } else {
183 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
184 "%s: Converted %s to expected %s\n",
185 data->pathname,
186 acpi_ut_get_object_type_name(return_object),
187 acpi_ut_get_object_type_name(new_object)));
188 }
189
190 /* Delete old object, install the new return object */
191
192 acpi_ut_remove_reference(return_object);
193 *return_object_ptr = new_object;
194 data->flags |= ACPI_OBJECT_REPAIRED;
195 return (AE_OK);
196}
197
198/*******************************************************************************
199 *
200 * FUNCTION: acpi_ns_convert_to_integer
201 *
202 * PARAMETERS: original_object - Object to be converted
203 * return_object - Where the new converted object is returned
204 *
205 * RETURN: Status. AE_OK if conversion was successful.
206 *
207 * DESCRIPTION: Attempt to convert a String/Buffer object to an Integer.
208 *
209 ******************************************************************************/
210
211static acpi_status
212acpi_ns_convert_to_integer(union acpi_operand_object *original_object,
213 union acpi_operand_object **return_object)
214{
215 union acpi_operand_object *new_object;
216 acpi_status status;
217 u64 value = 0;
218 u32 i;
219
220 switch (original_object->common.type) {
221 case ACPI_TYPE_STRING:
222
223 /* String-to-Integer conversion */
224
225 status = acpi_ut_strtoul64(original_object->string.pointer,
226 ACPI_ANY_BASE, &value);
227 if (ACPI_FAILURE(status)) {
228 return (status);
229 }
230 break;
231
88 case ACPI_TYPE_BUFFER: 232 case ACPI_TYPE_BUFFER:
89 233
90 /* Does the method/object legally return a string? */ 234 /* Buffer-to-Integer conversion. Max buffer size is 64 bits. */
91 235
92 if (!(expected_btypes & ACPI_RTYPE_STRING)) { 236 if (original_object->buffer.length > 8) {
93 return (AE_AML_OPERAND_TYPE); 237 return (AE_AML_OPERAND_TYPE);
94 } 238 }
95 239
240 /* Extract each buffer byte to create the integer */
241
242 for (i = 0; i < original_object->buffer.length; i++) {
243 value |=
244 ((u64) original_object->buffer.
245 pointer[i] << (i * 8));
246 }
247 break;
248
249 default:
250 return (AE_AML_OPERAND_TYPE);
251 }
252
253 new_object = acpi_ut_create_integer_object(value);
254 if (!new_object) {
255 return (AE_NO_MEMORY);
256 }
257
258 *return_object = new_object;
259 return (AE_OK);
260}
261
262/*******************************************************************************
263 *
264 * FUNCTION: acpi_ns_convert_to_string
265 *
266 * PARAMETERS: original_object - Object to be converted
267 * return_object - Where the new converted object is returned
268 *
269 * RETURN: Status. AE_OK if conversion was successful.
270 *
271 * DESCRIPTION: Attempt to convert a Integer/Buffer object to a String.
272 *
273 ******************************************************************************/
274
275static acpi_status
276acpi_ns_convert_to_string(union acpi_operand_object *original_object,
277 union acpi_operand_object **return_object)
278{
279 union acpi_operand_object *new_object;
280 acpi_size length;
281 acpi_status status;
282
283 switch (original_object->common.type) {
284 case ACPI_TYPE_INTEGER:
285 /*
286 * Integer-to-String conversion. Commonly, convert
287 * an integer of value 0 to a NULL string. The last element of
288 * _BIF and _BIX packages occasionally need this fix.
289 */
290 if (original_object->integer.value == 0) {
291
292 /* Allocate a new NULL string object */
293
294 new_object = acpi_ut_create_string_object(0);
295 if (!new_object) {
296 return (AE_NO_MEMORY);
297 }
298 } else {
299 status =
300 acpi_ex_convert_to_string(original_object,
301 &new_object,
302 ACPI_IMPLICIT_CONVERT_HEX);
303 if (ACPI_FAILURE(status)) {
304 return (status);
305 }
306 }
307 break;
308
309 case ACPI_TYPE_BUFFER:
96 /* 310 /*
97 * Have a Buffer, expected a String, convert. Use a to_string 311 * Buffer-to-String conversion. Use a to_string
98 * conversion, no transform performed on the buffer data. The best 312 * conversion, no transform performed on the buffer data. The best
99 * example of this is the _BIF method, where the string data from 313 * example of this is the _BIF method, where the string data from
100 * the battery is often (incorrectly) returned as buffer object(s). 314 * the battery is often (incorrectly) returned as buffer object(s).
101 */ 315 */
102 length = 0; 316 length = 0;
103 while ((length < return_object->buffer.length) && 317 while ((length < original_object->buffer.length) &&
104 (return_object->buffer.pointer[length])) { 318 (original_object->buffer.pointer[length])) {
105 length++; 319 length++;
106 } 320 }
107 321
@@ -117,94 +331,176 @@ acpi_ns_repair_object(struct acpi_predefined_data *data,
117 * terminated at Length+1. 331 * terminated at Length+1.
118 */ 332 */
119 ACPI_MEMCPY(new_object->string.pointer, 333 ACPI_MEMCPY(new_object->string.pointer,
120 return_object->buffer.pointer, length); 334 original_object->buffer.pointer, length);
121 break; 335 break;
122 336
337 default:
338 return (AE_AML_OPERAND_TYPE);
339 }
340
341 *return_object = new_object;
342 return (AE_OK);
343}
344
345/*******************************************************************************
346 *
347 * FUNCTION: acpi_ns_convert_to_buffer
348 *
349 * PARAMETERS: original_object - Object to be converted
350 * return_object - Where the new converted object is returned
351 *
352 * RETURN: Status. AE_OK if conversion was successful.
353 *
354 * DESCRIPTION: Attempt to convert a Integer/String/Package object to a Buffer.
355 *
356 ******************************************************************************/
357
358static acpi_status
359acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
360 union acpi_operand_object **return_object)
361{
362 union acpi_operand_object *new_object;
363 acpi_status status;
364 union acpi_operand_object **elements;
365 u32 *dword_buffer;
366 u32 count;
367 u32 i;
368
369 switch (original_object->common.type) {
123 case ACPI_TYPE_INTEGER: 370 case ACPI_TYPE_INTEGER:
371 /*
372 * Integer-to-Buffer conversion.
373 * Convert the Integer to a packed-byte buffer. _MAT and other
374 * objects need this sometimes, if a read has been performed on a
375 * Field object that is less than or equal to the global integer
376 * size (32 or 64 bits).
377 */
378 status =
379 acpi_ex_convert_to_buffer(original_object, &new_object);
380 if (ACPI_FAILURE(status)) {
381 return (status);
382 }
383 break;
124 384
125 /* 1) Does the method/object legally return a buffer? */ 385 case ACPI_TYPE_STRING:
126 386
127 if (expected_btypes & ACPI_RTYPE_BUFFER) { 387 /* String-to-Buffer conversion. Simple data copy */
128 /* 388
129 * Convert the Integer to a packed-byte buffer. _MAT needs 389 new_object =
130 * this sometimes, if a read has been performed on a Field 390 acpi_ut_create_buffer_object(original_object->string.
131 * object that is less than or equal to the global integer 391 length);
132 * size (32 or 64 bits). 392 if (!new_object) {
133 */ 393 return (AE_NO_MEMORY);
134 status =
135 acpi_ex_convert_to_buffer(return_object,
136 &new_object);
137 if (ACPI_FAILURE(status)) {
138 return (status);
139 }
140 } 394 }
141 395
142 /* 2) Does the method/object legally return a string? */ 396 ACPI_MEMCPY(new_object->buffer.pointer,
397 original_object->string.pointer,
398 original_object->string.length);
399 break;
400
401 case ACPI_TYPE_PACKAGE:
402 /*
403 * This case is often seen for predefined names that must return a
404 * Buffer object with multiple DWORD integers within. For example,
405 * _FDE and _GTM. The Package can be converted to a Buffer.
406 */
407
408 /* All elements of the Package must be integers */
143 409
144 else if (expected_btypes & ACPI_RTYPE_STRING) { 410 elements = original_object->package.elements;
145 /* 411 count = original_object->package.count;
146 * The only supported Integer-to-String conversion is to convert 412
147 * an integer of value 0 to a NULL string. The last element of 413 for (i = 0; i < count; i++) {
148 * _BIF and _BIX packages occasionally need this fix. 414 if ((!*elements) ||
149 */ 415 ((*elements)->common.type != ACPI_TYPE_INTEGER)) {
150 if (return_object->integer.value != 0) {
151 return (AE_AML_OPERAND_TYPE); 416 return (AE_AML_OPERAND_TYPE);
152 } 417 }
418 elements++;
419 }
153 420
154 /* Allocate a new NULL string object */ 421 /* Create the new buffer object to replace the Package */
155 422
156 new_object = acpi_ut_create_string_object(0); 423 new_object = acpi_ut_create_buffer_object(ACPI_MUL_4(count));
157 if (!new_object) { 424 if (!new_object) {
158 return (AE_NO_MEMORY); 425 return (AE_NO_MEMORY);
159 }
160 } else {
161 return (AE_AML_OPERAND_TYPE);
162 } 426 }
163 break;
164 427
165 default: 428 /* Copy the package elements (integers) to the buffer as DWORDs */
166 429
167 /* We cannot repair this object */ 430 elements = original_object->package.elements;
431 dword_buffer = ACPI_CAST_PTR(u32, new_object->buffer.pointer);
432
433 for (i = 0; i < count; i++) {
434 *dword_buffer = (u32) (*elements)->integer.value;
435 dword_buffer++;
436 elements++;
437 }
438 break;
168 439
440 default:
169 return (AE_AML_OPERAND_TYPE); 441 return (AE_AML_OPERAND_TYPE);
170 } 442 }
171 443
172 /* Object was successfully repaired */ 444 *return_object = new_object;
445 return (AE_OK);
446}
173 447
174 /* 448/*******************************************************************************
175 * If the original object is a package element, we need to: 449 *
176 * 1. Set the reference count of the new object to match the 450 * FUNCTION: acpi_ns_convert_to_package
177 * reference count of the old object. 451 *
178 * 2. Decrement the reference count of the original object. 452 * PARAMETERS: original_object - Object to be converted
179 */ 453 * return_object - Where the new converted object is returned
180 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) { 454 *
181 new_object->common.reference_count = 455 * RETURN: Status. AE_OK if conversion was successful.
182 return_object->common.reference_count; 456 *
457 * DESCRIPTION: Attempt to convert a Buffer object to a Package. Each byte of
458 * the buffer is converted to a single integer package element.
459 *
460 ******************************************************************************/
183 461
184 if (return_object->common.reference_count > 1) { 462static acpi_status
185 return_object->common.reference_count--; 463acpi_ns_convert_to_package(union acpi_operand_object *original_object,
464 union acpi_operand_object **return_object)
465{
466 union acpi_operand_object *new_object;
467 union acpi_operand_object **elements;
468 u32 length;
469 u8 *buffer;
470
471 switch (original_object->common.type) {
472 case ACPI_TYPE_BUFFER:
473
474 /* Buffer-to-Package conversion */
475
476 length = original_object->buffer.length;
477 new_object = acpi_ut_create_package_object(length);
478 if (!new_object) {
479 return (AE_NO_MEMORY);
186 } 480 }
187 481
188 ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 482 /* Convert each buffer byte to an integer package element */
189 "Converted %s to expected %s at index %u",
190 acpi_ut_get_object_type_name
191 (return_object),
192 acpi_ut_get_object_type_name(new_object),
193 package_index));
194 } else {
195 ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
196 "Converted %s to expected %s",
197 acpi_ut_get_object_type_name
198 (return_object),
199 acpi_ut_get_object_type_name
200 (new_object)));
201 }
202 483
203 /* Delete old object, install the new return object */ 484 elements = new_object->package.elements;
485 buffer = original_object->buffer.pointer;
204 486
205 acpi_ut_remove_reference(return_object); 487 while (length--) {
206 *return_object_ptr = new_object; 488 *elements =
207 data->flags |= ACPI_OBJECT_REPAIRED; 489 acpi_ut_create_integer_object((u64) *buffer);
490 if (!*elements) {
491 acpi_ut_remove_reference(new_object);
492 return (AE_NO_MEMORY);
493 }
494 elements++;
495 buffer++;
496 }
497 break;
498
499 default:
500 return (AE_AML_OPERAND_TYPE);
501 }
502
503 *return_object = new_object;
208 return (AE_OK); 504 return (AE_OK);
209} 505}
210 506
@@ -238,6 +534,8 @@ acpi_ns_repair_package_list(struct acpi_predefined_data *data,
238{ 534{
239 union acpi_operand_object *pkg_obj_desc; 535 union acpi_operand_object *pkg_obj_desc;
240 536
537 ACPI_FUNCTION_NAME(ns_repair_package_list);
538
241 /* 539 /*
242 * Create the new outer package and populate it. The new package will 540 * Create the new outer package and populate it. The new package will
243 * have a single element, the lone subpackage. 541 * have a single element, the lone subpackage.
@@ -254,8 +552,9 @@ acpi_ns_repair_package_list(struct acpi_predefined_data *data,
254 *obj_desc_ptr = pkg_obj_desc; 552 *obj_desc_ptr = pkg_obj_desc;
255 data->flags |= ACPI_OBJECT_REPAIRED; 553 data->flags |= ACPI_OBJECT_REPAIRED;
256 554
257 ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags, 555 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
258 "Repaired Incorrectly formed Package")); 556 "%s: Repaired incorrectly formed Package\n",
557 data->pathname));
259 558
260 return (AE_OK); 559 return (AE_OK);
261} 560}
diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
index d07b68613818..f13691c1cca5 100644
--- a/drivers/acpi/acpica/nsrepair2.c
+++ b/drivers/acpi/acpica/nsrepair2.c
@@ -45,6 +45,7 @@
45#include <acpi/acpi.h> 45#include <acpi/acpi.h>
46#include "accommon.h" 46#include "accommon.h"
47#include "acnamesp.h" 47#include "acnamesp.h"
48#include "acpredef.h"
48 49
49#define _COMPONENT ACPI_NAMESPACE 50#define _COMPONENT ACPI_NAMESPACE
50ACPI_MODULE_NAME("nsrepair2") 51ACPI_MODULE_NAME("nsrepair2")
@@ -74,6 +75,10 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data,
74 union acpi_operand_object **return_object_ptr); 75 union acpi_operand_object **return_object_ptr);
75 76
76static acpi_status 77static acpi_status
78acpi_ns_repair_FDE(struct acpi_predefined_data *data,
79 union acpi_operand_object **return_object_ptr);
80
81static acpi_status
77acpi_ns_repair_PSS(struct acpi_predefined_data *data, 82acpi_ns_repair_PSS(struct acpi_predefined_data *data,
78 union acpi_operand_object **return_object_ptr); 83 union acpi_operand_object **return_object_ptr);
79 84
@@ -89,9 +94,6 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
89 u8 sort_direction, char *sort_key_name); 94 u8 sort_direction, char *sort_key_name);
90 95
91static acpi_status 96static acpi_status
92acpi_ns_remove_null_elements(union acpi_operand_object *package);
93
94static acpi_status
95acpi_ns_sort_list(union acpi_operand_object **elements, 97acpi_ns_sort_list(union acpi_operand_object **elements,
96 u32 count, u32 index, u8 sort_direction); 98 u32 count, u32 index, u8 sort_direction);
97 99
@@ -104,17 +106,27 @@ acpi_ns_sort_list(union acpi_operand_object **elements,
104 * This table contains the names of the predefined methods for which we can 106 * This table contains the names of the predefined methods for which we can
105 * perform more complex repairs. 107 * perform more complex repairs.
106 * 108 *
107 * _ALR: Sort the list ascending by ambient_illuminance if necessary 109 * As necessary:
108 * _PSS: Sort the list descending by Power if necessary 110 *
109 * _TSS: Sort the list descending by Power if necessary 111 * _ALR: Sort the list ascending by ambient_illuminance
112 * _FDE: Convert Buffer of BYTEs to a Buffer of DWORDs
113 * _GTM: Convert Buffer of BYTEs to a Buffer of DWORDs
114 * _PSS: Sort the list descending by Power
115 * _TSS: Sort the list descending by Power
110 */ 116 */
111static const struct acpi_repair_info acpi_ns_repairable_names[] = { 117static const struct acpi_repair_info acpi_ns_repairable_names[] = {
112 {"_ALR", acpi_ns_repair_ALR}, 118 {"_ALR", acpi_ns_repair_ALR},
119 {"_FDE", acpi_ns_repair_FDE},
120 {"_GTM", acpi_ns_repair_FDE}, /* _GTM has same repair as _FDE */
113 {"_PSS", acpi_ns_repair_PSS}, 121 {"_PSS", acpi_ns_repair_PSS},
114 {"_TSS", acpi_ns_repair_TSS}, 122 {"_TSS", acpi_ns_repair_TSS},
115 {{0, 0, 0, 0}, NULL} /* Table terminator */ 123 {{0, 0, 0, 0}, NULL} /* Table terminator */
116}; 124};
117 125
126#define ACPI_FDE_FIELD_COUNT 5
127#define ACPI_FDE_BYTE_BUFFER_SIZE 5
128#define ACPI_FDE_DWORD_BUFFER_SIZE (ACPI_FDE_FIELD_COUNT * sizeof (u32))
129
118/****************************************************************************** 130/******************************************************************************
119 * 131 *
120 * FUNCTION: acpi_ns_complex_repairs 132 * FUNCTION: acpi_ns_complex_repairs
@@ -215,6 +227,94 @@ acpi_ns_repair_ALR(struct acpi_predefined_data *data,
215 227
216/****************************************************************************** 228/******************************************************************************
217 * 229 *
230 * FUNCTION: acpi_ns_repair_FDE
231 *
232 * PARAMETERS: Data - Pointer to validation data structure
233 * return_object_ptr - Pointer to the object returned from the
234 * evaluation of a method or object
235 *
236 * RETURN: Status. AE_OK if object is OK or was repaired successfully
237 *
238 * DESCRIPTION: Repair for the _FDE and _GTM objects. The expected return
239 * value is a Buffer of 5 DWORDs. This function repairs a common
240 * problem where the return value is a Buffer of BYTEs, not
241 * DWORDs.
242 *
243 *****************************************************************************/
244
245static acpi_status
246acpi_ns_repair_FDE(struct acpi_predefined_data *data,
247 union acpi_operand_object **return_object_ptr)
248{
249 union acpi_operand_object *return_object = *return_object_ptr;
250 union acpi_operand_object *buffer_object;
251 u8 *byte_buffer;
252 u32 *dword_buffer;
253 u32 i;
254
255 ACPI_FUNCTION_NAME(ns_repair_FDE);
256
257 switch (return_object->common.type) {
258 case ACPI_TYPE_BUFFER:
259
260 /* This is the expected type. Length should be (at least) 5 DWORDs */
261
262 if (return_object->buffer.length >= ACPI_FDE_DWORD_BUFFER_SIZE) {
263 return (AE_OK);
264 }
265
266 /* We can only repair if we have exactly 5 BYTEs */
267
268 if (return_object->buffer.length != ACPI_FDE_BYTE_BUFFER_SIZE) {
269 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
270 data->node_flags,
271 "Incorrect return buffer length %u, expected %u",
272 return_object->buffer.length,
273 ACPI_FDE_DWORD_BUFFER_SIZE));
274
275 return (AE_AML_OPERAND_TYPE);
276 }
277
278 /* Create the new (larger) buffer object */
279
280 buffer_object =
281 acpi_ut_create_buffer_object(ACPI_FDE_DWORD_BUFFER_SIZE);
282 if (!buffer_object) {
283 return (AE_NO_MEMORY);
284 }
285
286 /* Expand each byte to a DWORD */
287
288 byte_buffer = return_object->buffer.pointer;
289 dword_buffer =
290 ACPI_CAST_PTR(u32, buffer_object->buffer.pointer);
291
292 for (i = 0; i < ACPI_FDE_FIELD_COUNT; i++) {
293 *dword_buffer = (u32) *byte_buffer;
294 dword_buffer++;
295 byte_buffer++;
296 }
297
298 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
299 "%s Expanded Byte Buffer to expected DWord Buffer\n",
300 data->pathname));
301 break;
302
303 default:
304 return (AE_AML_OPERAND_TYPE);
305 }
306
307 /* Delete the original return object, return the new buffer object */
308
309 acpi_ut_remove_reference(return_object);
310 *return_object_ptr = buffer_object;
311
312 data->flags |= ACPI_OBJECT_REPAIRED;
313 return (AE_OK);
314}
315
316/******************************************************************************
317 *
218 * FUNCTION: acpi_ns_repair_TSS 318 * FUNCTION: acpi_ns_repair_TSS
219 * 319 *
220 * PARAMETERS: Data - Pointer to validation data structure 320 * PARAMETERS: Data - Pointer to validation data structure
@@ -345,6 +445,8 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
345 u32 previous_value; 445 u32 previous_value;
346 acpi_status status; 446 acpi_status status;
347 447
448 ACPI_FUNCTION_NAME(ns_check_sorted_list);
449
348 /* The top-level object must be a package */ 450 /* The top-level object must be a package */
349 451
350 if (return_object->common.type != ACPI_TYPE_PACKAGE) { 452 if (return_object->common.type != ACPI_TYPE_PACKAGE) {
@@ -352,24 +454,10 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
352 } 454 }
353 455
354 /* 456 /*
355 * Detect any NULL package elements and remove them from the 457 * NOTE: assumes list of sub-packages contains no NULL elements.
356 * package. 458 * Any NULL elements should have been removed by earlier call
357 * 459 * to acpi_ns_remove_null_elements.
358 * TBD: We may want to do this for all predefined names that
359 * return a variable-length package of packages.
360 */ 460 */
361 status = acpi_ns_remove_null_elements(return_object);
362 if (status == AE_NULL_ENTRY) {
363 ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
364 "NULL elements removed from package"));
365
366 /* Exit if package is now zero length */
367
368 if (!return_object->package.count) {
369 return (AE_NULL_ENTRY);
370 }
371 }
372
373 outer_elements = return_object->package.elements; 461 outer_elements = return_object->package.elements;
374 outer_element_count = return_object->package.count; 462 outer_element_count = return_object->package.count;
375 if (!outer_element_count) { 463 if (!outer_element_count) {
@@ -422,10 +510,9 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
422 510
423 data->flags |= ACPI_OBJECT_REPAIRED; 511 data->flags |= ACPI_OBJECT_REPAIRED;
424 512
425 ACPI_INFO_PREDEFINED((AE_INFO, data->pathname, 513 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
426 data->node_flags, 514 "%s: Repaired unsorted list - now sorted by %s\n",
427 "Repaired unsorted list - now sorted by %s", 515 data->pathname, sort_key_name));
428 sort_key_name));
429 return (AE_OK); 516 return (AE_OK);
430 } 517 }
431 518
@@ -440,36 +527,63 @@ acpi_ns_check_sorted_list(struct acpi_predefined_data *data,
440 * 527 *
441 * FUNCTION: acpi_ns_remove_null_elements 528 * FUNCTION: acpi_ns_remove_null_elements
442 * 529 *
443 * PARAMETERS: obj_desc - A Package object 530 * PARAMETERS: Data - Pointer to validation data structure
531 * package_type - An acpi_return_package_types value
532 * obj_desc - A Package object
444 * 533 *
445 * RETURN: Status. AE_NULL_ENTRY means that one or more elements were 534 * RETURN: None.
446 * removed.
447 * 535 *
448 * DESCRIPTION: Remove all NULL package elements and update the package count. 536 * DESCRIPTION: Remove all NULL package elements from packages that contain
537 * a variable number of sub-packages.
449 * 538 *
450 *****************************************************************************/ 539 *****************************************************************************/
451 540
452static acpi_status 541void
453acpi_ns_remove_null_elements(union acpi_operand_object *obj_desc) 542acpi_ns_remove_null_elements(struct acpi_predefined_data *data,
543 u8 package_type,
544 union acpi_operand_object *obj_desc)
454{ 545{
455 union acpi_operand_object **source; 546 union acpi_operand_object **source;
456 union acpi_operand_object **dest; 547 union acpi_operand_object **dest;
457 acpi_status status = AE_OK;
458 u32 count; 548 u32 count;
459 u32 new_count; 549 u32 new_count;
460 u32 i; 550 u32 i;
461 551
552 ACPI_FUNCTION_NAME(ns_remove_null_elements);
553
554 /*
555 * PTYPE1 packages contain no subpackages.
556 * PTYPE2 packages contain a variable number of sub-packages. We can
557 * safely remove all NULL elements from the PTYPE2 packages.
558 */
559 switch (package_type) {
560 case ACPI_PTYPE1_FIXED:
561 case ACPI_PTYPE1_VAR:
562 case ACPI_PTYPE1_OPTION:
563 return;
564
565 case ACPI_PTYPE2:
566 case ACPI_PTYPE2_COUNT:
567 case ACPI_PTYPE2_PKG_COUNT:
568 case ACPI_PTYPE2_FIXED:
569 case ACPI_PTYPE2_MIN:
570 case ACPI_PTYPE2_REV_FIXED:
571 break;
572
573 default:
574 return;
575 }
576
462 count = obj_desc->package.count; 577 count = obj_desc->package.count;
463 new_count = count; 578 new_count = count;
464 579
465 source = obj_desc->package.elements; 580 source = obj_desc->package.elements;
466 dest = source; 581 dest = source;
467 582
468 /* Examine all elements of the package object */ 583 /* Examine all elements of the package object, remove nulls */
469 584
470 for (i = 0; i < count; i++) { 585 for (i = 0; i < count; i++) {
471 if (!*source) { 586 if (!*source) {
472 status = AE_NULL_ENTRY;
473 new_count--; 587 new_count--;
474 } else { 588 } else {
475 *dest = *source; 589 *dest = *source;
@@ -478,15 +592,18 @@ acpi_ns_remove_null_elements(union acpi_operand_object *obj_desc)
478 source++; 592 source++;
479 } 593 }
480 594
481 if (status == AE_NULL_ENTRY) { 595 /* Update parent package if any null elements were removed */
596
597 if (new_count < count) {
598 ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
599 "%s: Found and removed %u NULL elements\n",
600 data->pathname, (count - new_count)));
482 601
483 /* NULL terminate list and update the package count */ 602 /* NULL terminate list and update the package count */
484 603
485 *dest = NULL; 604 *dest = NULL;
486 obj_desc->package.count = new_count; 605 obj_desc->package.count = new_count;
487 } 606 }
488
489 return (status);
490} 607}
491 608
492/****************************************************************************** 609/******************************************************************************
diff --git a/drivers/acpi/acpica/nsutils.c b/drivers/acpi/acpica/nsutils.c
index ea55ab4f9849..47d91e668a1b 100644
--- a/drivers/acpi/acpica/nsutils.c
+++ b/drivers/acpi/acpica/nsutils.c
@@ -671,24 +671,25 @@ acpi_ns_externalize_name(u32 internal_name_length,
671 671
672/******************************************************************************* 672/*******************************************************************************
673 * 673 *
674 * FUNCTION: acpi_ns_map_handle_to_node 674 * FUNCTION: acpi_ns_validate_handle
675 * 675 *
676 * PARAMETERS: Handle - Handle to be converted to an Node 676 * PARAMETERS: Handle - Handle to be validated and typecast to a
677 * namespace node.
677 * 678 *
678 * RETURN: A Name table entry pointer 679 * RETURN: A pointer to a namespace node
679 * 680 *
680 * DESCRIPTION: Convert a namespace handle to a real Node 681 * DESCRIPTION: Convert a namespace handle to a namespace node. Handles special
682 * cases for the root node.
681 * 683 *
682 * Note: Real integer handles would allow for more verification 684 * NOTE: Real integer handles would allow for more verification
683 * and keep all pointers within this subsystem - however this introduces 685 * and keep all pointers within this subsystem - however this introduces
684 * more (and perhaps unnecessary) overhead. 686 * more overhead and has not been necessary to this point. Drivers
685 * 687 * holding handles are typically notified before a node becomes invalid
686 * The current implemenation is basically a placeholder until such time comes 688 * due to a table unload.
687 * that it is needed.
688 * 689 *
689 ******************************************************************************/ 690 ******************************************************************************/
690 691
691struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle) 692struct acpi_namespace_node *acpi_ns_validate_handle(acpi_handle handle)
692{ 693{
693 694
694 ACPI_FUNCTION_ENTRY(); 695 ACPI_FUNCTION_ENTRY();
@@ -710,42 +711,6 @@ struct acpi_namespace_node *acpi_ns_map_handle_to_node(acpi_handle handle)
710 711
711/******************************************************************************* 712/*******************************************************************************
712 * 713 *
713 * FUNCTION: acpi_ns_convert_entry_to_handle
714 *
715 * PARAMETERS: Node - Node to be converted to a Handle
716 *
717 * RETURN: A user handle
718 *
719 * DESCRIPTION: Convert a real Node to a namespace handle
720 *
721 ******************************************************************************/
722
723acpi_handle acpi_ns_convert_entry_to_handle(struct acpi_namespace_node *node)
724{
725
726 /*
727 * Simple implementation for now;
728 */
729 return ((acpi_handle) node);
730
731/* Example future implementation ---------------------
732
733 if (!Node)
734 {
735 return (NULL);
736 }
737
738 if (Node == acpi_gbl_root_node)
739 {
740 return (ACPI_ROOT_OBJECT);
741 }
742
743 return ((acpi_handle) Node);
744------------------------------------------------------*/
745}
746
747/*******************************************************************************
748 *
749 * FUNCTION: acpi_ns_terminate 714 * FUNCTION: acpi_ns_terminate
750 * 715 *
751 * PARAMETERS: none 716 * PARAMETERS: none
diff --git a/drivers/acpi/acpica/nsxfeval.c b/drivers/acpi/acpica/nsxfeval.c
index f2bd1da77001..f0c0892bc7e5 100644
--- a/drivers/acpi/acpica/nsxfeval.c
+++ b/drivers/acpi/acpica/nsxfeval.c
@@ -190,7 +190,7 @@ acpi_evaluate_object(acpi_handle handle,
190 190
191 /* Convert and validate the device handle */ 191 /* Convert and validate the device handle */
192 192
193 info->prefix_node = acpi_ns_map_handle_to_node(handle); 193 info->prefix_node = acpi_ns_validate_handle(handle);
194 if (!info->prefix_node) { 194 if (!info->prefix_node) {
195 status = AE_BAD_PARAMETER; 195 status = AE_BAD_PARAMETER;
196 goto cleanup; 196 goto cleanup;
@@ -552,7 +552,7 @@ acpi_ns_get_device_callback(acpi_handle obj_handle,
552 return (status); 552 return (status);
553 } 553 }
554 554
555 node = acpi_ns_map_handle_to_node(obj_handle); 555 node = acpi_ns_validate_handle(obj_handle);
556 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 556 status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
557 if (ACPI_FAILURE(status)) { 557 if (ACPI_FAILURE(status)) {
558 return (status); 558 return (status);
@@ -729,7 +729,7 @@ acpi_attach_data(acpi_handle obj_handle,
729 729
730 /* Convert and validate the handle */ 730 /* Convert and validate the handle */
731 731
732 node = acpi_ns_map_handle_to_node(obj_handle); 732 node = acpi_ns_validate_handle(obj_handle);
733 if (!node) { 733 if (!node) {
734 status = AE_BAD_PARAMETER; 734 status = AE_BAD_PARAMETER;
735 goto unlock_and_exit; 735 goto unlock_and_exit;
@@ -775,7 +775,7 @@ acpi_detach_data(acpi_handle obj_handle, acpi_object_handler handler)
775 775
776 /* Convert and validate the handle */ 776 /* Convert and validate the handle */
777 777
778 node = acpi_ns_map_handle_to_node(obj_handle); 778 node = acpi_ns_validate_handle(obj_handle);
779 if (!node) { 779 if (!node) {
780 status = AE_BAD_PARAMETER; 780 status = AE_BAD_PARAMETER;
781 goto unlock_and_exit; 781 goto unlock_and_exit;
@@ -822,7 +822,7 @@ acpi_get_data(acpi_handle obj_handle, acpi_object_handler handler, void **data)
822 822
823 /* Convert and validate the handle */ 823 /* Convert and validate the handle */
824 824
825 node = acpi_ns_map_handle_to_node(obj_handle); 825 node = acpi_ns_validate_handle(obj_handle);
826 if (!node) { 826 if (!node) {
827 status = AE_BAD_PARAMETER; 827 status = AE_BAD_PARAMETER;
828 goto unlock_and_exit; 828 goto unlock_and_exit;
diff --git a/drivers/acpi/acpica/nsxfname.c b/drivers/acpi/acpica/nsxfname.c
index ddc84af6336e..e611dd961b20 100644
--- a/drivers/acpi/acpica/nsxfname.c
+++ b/drivers/acpi/acpica/nsxfname.c
@@ -93,7 +93,7 @@ acpi_get_handle(acpi_handle parent,
93 /* Convert a parent handle to a prefix node */ 93 /* Convert a parent handle to a prefix node */
94 94
95 if (parent) { 95 if (parent) {
96 prefix_node = acpi_ns_map_handle_to_node(parent); 96 prefix_node = acpi_ns_validate_handle(parent);
97 if (!prefix_node) { 97 if (!prefix_node) {
98 return (AE_BAD_PARAMETER); 98 return (AE_BAD_PARAMETER);
99 } 99 }
@@ -114,7 +114,7 @@ acpi_get_handle(acpi_handle parent,
114 114
115 if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) { 115 if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
116 *ret_handle = 116 *ret_handle =
117 acpi_ns_convert_entry_to_handle(acpi_gbl_root_node); 117 ACPI_CAST_PTR(acpi_handle, acpi_gbl_root_node);
118 return (AE_OK); 118 return (AE_OK);
119 } 119 }
120 } else if (!prefix_node) { 120 } else if (!prefix_node) {
@@ -129,7 +129,7 @@ acpi_get_handle(acpi_handle parent,
129 status = 129 status =
130 acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node); 130 acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
131 if (ACPI_SUCCESS(status)) { 131 if (ACPI_SUCCESS(status)) {
132 *ret_handle = acpi_ns_convert_entry_to_handle(node); 132 *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
133 } 133 }
134 134
135 return (status); 135 return (status);
@@ -186,7 +186,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
186 return (status); 186 return (status);
187 } 187 }
188 188
189 node = acpi_ns_map_handle_to_node(handle); 189 node = acpi_ns_validate_handle(handle);
190 if (!node) { 190 if (!node) {
191 status = AE_BAD_PARAMETER; 191 status = AE_BAD_PARAMETER;
192 goto unlock_and_exit; 192 goto unlock_and_exit;
@@ -291,7 +291,7 @@ acpi_get_object_info(acpi_handle handle,
291 goto cleanup; 291 goto cleanup;
292 } 292 }
293 293
294 node = acpi_ns_map_handle_to_node(handle); 294 node = acpi_ns_validate_handle(handle);
295 if (!node) { 295 if (!node) {
296 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 296 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
297 return (AE_BAD_PARAMETER); 297 return (AE_BAD_PARAMETER);
diff --git a/drivers/acpi/acpica/nsxfobj.c b/drivers/acpi/acpica/nsxfobj.c
index 4071bad4458e..0cc6ba01a495 100644
--- a/drivers/acpi/acpica/nsxfobj.c
+++ b/drivers/acpi/acpica/nsxfobj.c
@@ -79,7 +79,7 @@ acpi_status acpi_get_id(acpi_handle handle, acpi_owner_id * ret_id)
79 79
80 /* Convert and validate the handle */ 80 /* Convert and validate the handle */
81 81
82 node = acpi_ns_map_handle_to_node(handle); 82 node = acpi_ns_validate_handle(handle);
83 if (!node) { 83 if (!node) {
84 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 84 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
85 return (AE_BAD_PARAMETER); 85 return (AE_BAD_PARAMETER);
@@ -132,7 +132,7 @@ acpi_status acpi_get_type(acpi_handle handle, acpi_object_type * ret_type)
132 132
133 /* Convert and validate the handle */ 133 /* Convert and validate the handle */
134 134
135 node = acpi_ns_map_handle_to_node(handle); 135 node = acpi_ns_validate_handle(handle);
136 if (!node) { 136 if (!node) {
137 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); 137 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
138 return (AE_BAD_PARAMETER); 138 return (AE_BAD_PARAMETER);
@@ -182,7 +182,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
182 182
183 /* Convert and validate the handle */ 183 /* Convert and validate the handle */
184 184
185 node = acpi_ns_map_handle_to_node(handle); 185 node = acpi_ns_validate_handle(handle);
186 if (!node) { 186 if (!node) {
187 status = AE_BAD_PARAMETER; 187 status = AE_BAD_PARAMETER;
188 goto unlock_and_exit; 188 goto unlock_and_exit;
@@ -191,7 +191,7 @@ acpi_status acpi_get_parent(acpi_handle handle, acpi_handle * ret_handle)
191 /* Get the parent entry */ 191 /* Get the parent entry */
192 192
193 parent_node = acpi_ns_get_parent_node(node); 193 parent_node = acpi_ns_get_parent_node(node);
194 *ret_handle = acpi_ns_convert_entry_to_handle(parent_node); 194 *ret_handle = ACPI_CAST_PTR(acpi_handle, parent_node);
195 195
196 /* Return exception if parent is null */ 196 /* Return exception if parent is null */
197 197
@@ -251,7 +251,7 @@ acpi_get_next_object(acpi_object_type type,
251 251
252 /* Start search at the beginning of the specified scope */ 252 /* Start search at the beginning of the specified scope */
253 253
254 parent_node = acpi_ns_map_handle_to_node(parent); 254 parent_node = acpi_ns_validate_handle(parent);
255 if (!parent_node) { 255 if (!parent_node) {
256 status = AE_BAD_PARAMETER; 256 status = AE_BAD_PARAMETER;
257 goto unlock_and_exit; 257 goto unlock_and_exit;
@@ -260,7 +260,7 @@ acpi_get_next_object(acpi_object_type type,
260 /* Non-null handle, ignore the parent */ 260 /* Non-null handle, ignore the parent */
261 /* Convert and validate the handle */ 261 /* Convert and validate the handle */
262 262
263 child_node = acpi_ns_map_handle_to_node(child); 263 child_node = acpi_ns_validate_handle(child);
264 if (!child_node) { 264 if (!child_node) {
265 status = AE_BAD_PARAMETER; 265 status = AE_BAD_PARAMETER;
266 goto unlock_and_exit; 266 goto unlock_and_exit;
@@ -276,7 +276,7 @@ acpi_get_next_object(acpi_object_type type,
276 } 276 }
277 277
278 if (ret_handle) { 278 if (ret_handle) {
279 *ret_handle = acpi_ns_convert_entry_to_handle(node); 279 *ret_handle = ACPI_CAST_PTR(acpi_handle, node);
280 } 280 }
281 281
282 unlock_and_exit: 282 unlock_and_exit:
diff --git a/drivers/acpi/acpica/psxface.c b/drivers/acpi/acpica/psxface.c
index 12934ad6da8e..d0c1b91eb8ca 100644
--- a/drivers/acpi/acpica/psxface.c
+++ b/drivers/acpi/acpica/psxface.c
@@ -287,7 +287,8 @@ acpi_status acpi_ps_execute_method(struct acpi_evaluate_info *info)
287 /* Invoke an internal method if necessary */ 287 /* Invoke an internal method if necessary */
288 288
289 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) { 289 if (info->obj_desc->method.method_flags & AML_METHOD_INTERNAL_ONLY) {
290 status = info->obj_desc->method.implementation(walk_state); 290 status =
291 info->obj_desc->method.extra.implementation(walk_state);
291 info->return_object = walk_state->return_desc; 292 info->return_object = walk_state->return_desc;
292 293
293 /* Cleanup states */ 294 /* Cleanup states */
diff --git a/drivers/acpi/acpica/rsxface.c b/drivers/acpi/acpica/rsxface.c
index 395212bcd19b..f27feb4772f6 100644
--- a/drivers/acpi/acpica/rsxface.c
+++ b/drivers/acpi/acpica/rsxface.c
@@ -104,7 +104,7 @@ acpi_rs_validate_parameters(acpi_handle device_handle,
104 return_ACPI_STATUS(AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
105 } 105 }
106 106
107 node = acpi_ns_map_handle_to_node(device_handle); 107 node = acpi_ns_validate_handle(device_handle);
108 if (!node) { 108 if (!node) {
109 return_ACPI_STATUS(AE_BAD_PARAMETER); 109 return_ACPI_STATUS(AE_BAD_PARAMETER);
110 } 110 }
diff --git a/drivers/acpi/acpica/utcopy.c b/drivers/acpi/acpica/utcopy.c
index 0f0c64bf8ac9..f857c5efb79f 100644
--- a/drivers/acpi/acpica/utcopy.c
+++ b/drivers/acpi/acpica/utcopy.c
@@ -323,11 +323,11 @@ acpi_ut_copy_ielement_to_eelement(u8 object_type,
323 * RETURN: Status 323 * RETURN: Status
324 * 324 *
325 * DESCRIPTION: This function is called to place a package object in a user 325 * DESCRIPTION: This function is called to place a package object in a user
326 * buffer. A package object by definition contains other objects. 326 * buffer. A package object by definition contains other objects.
327 * 327 *
328 * The buffer is assumed to have sufficient space for the object. 328 * The buffer is assumed to have sufficient space for the object.
329 * The caller must have verified the buffer length needed using the 329 * The caller must have verified the buffer length needed using
330 * acpi_ut_get_object_size function before calling this function. 330 * the acpi_ut_get_object_size function before calling this function.
331 * 331 *
332 ******************************************************************************/ 332 ******************************************************************************/
333 333
@@ -382,12 +382,12 @@ acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
382 * FUNCTION: acpi_ut_copy_iobject_to_eobject 382 * FUNCTION: acpi_ut_copy_iobject_to_eobject
383 * 383 *
384 * PARAMETERS: internal_object - The internal object to be converted 384 * PARAMETERS: internal_object - The internal object to be converted
385 * buffer_ptr - Where the object is returned 385 * ret_buffer - Where the object is returned
386 * 386 *
387 * RETURN: Status 387 * RETURN: Status
388 * 388 *
389 * DESCRIPTION: This function is called to build an API object to be returned to 389 * DESCRIPTION: This function is called to build an API object to be returned
390 * the caller. 390 * to the caller.
391 * 391 *
392 ******************************************************************************/ 392 ******************************************************************************/
393 393
@@ -626,7 +626,7 @@ acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
626 * PARAMETERS: external_object - The external object to be converted 626 * PARAMETERS: external_object - The external object to be converted
627 * internal_object - Where the internal object is returned 627 * internal_object - Where the internal object is returned
628 * 628 *
629 * RETURN: Status - the status of the call 629 * RETURN: Status
630 * 630 *
631 * DESCRIPTION: Converts an external object to an internal object. 631 * DESCRIPTION: Converts an external object to an internal object.
632 * 632 *
@@ -665,7 +665,7 @@ acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
665 * 665 *
666 * RETURN: Status 666 * RETURN: Status
667 * 667 *
668 * DESCRIPTION: Simple copy of one internal object to another. Reference count 668 * DESCRIPTION: Simple copy of one internal object to another. Reference count
669 * of the destination object is preserved. 669 * of the destination object is preserved.
670 * 670 *
671 ******************************************************************************/ 671 ******************************************************************************/
@@ -897,10 +897,11 @@ acpi_ut_copy_ielement_to_ielement(u8 object_type,
897 * 897 *
898 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage 898 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
899 * 899 *
900 * PARAMETERS: *source_obj - Pointer to the source package object 900 * PARAMETERS: source_obj - Pointer to the source package object
901 * *dest_obj - Where the internal object is returned 901 * dest_obj - Where the internal object is returned
902 * walk_state - Current Walk state descriptor
902 * 903 *
903 * RETURN: Status - the status of the call 904 * RETURN: Status
904 * 905 *
905 * DESCRIPTION: This function is called to copy an internal package object 906 * DESCRIPTION: This function is called to copy an internal package object
906 * into another internal package object. 907 * into another internal package object.
@@ -953,9 +954,9 @@ acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
953 * 954 *
954 * FUNCTION: acpi_ut_copy_iobject_to_iobject 955 * FUNCTION: acpi_ut_copy_iobject_to_iobject
955 * 956 *
956 * PARAMETERS: walk_state - Current walk state 957 * PARAMETERS: source_desc - The internal object to be copied
957 * source_desc - The internal object to be copied
958 * dest_desc - Where the copied object is returned 958 * dest_desc - Where the copied object is returned
959 * walk_state - Current walk state
959 * 960 *
960 * RETURN: Status 961 * RETURN: Status
961 * 962 *