aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/acpi_pad.c3
-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
-rw-r--r--drivers/acpi/battery.c2
-rw-r--r--drivers/acpi/bus.c148
-rw-r--r--drivers/acpi/button.c7
-rw-r--r--drivers/acpi/debug.c84
-rw-r--r--drivers/acpi/dock.c261
-rw-r--r--drivers/acpi/fan.c2
-rw-r--r--drivers/acpi/numa.c21
-rw-r--r--drivers/acpi/osl.c2
-rw-r--r--drivers/acpi/pci_root.c76
-rw-r--r--drivers/acpi/processor_core.c10
-rw-r--r--drivers/acpi/processor_idle.c11
-rw-r--r--drivers/acpi/processor_perflib.c50
-rw-r--r--drivers/acpi/thermal.c7
38 files changed, 1136 insertions, 560 deletions
diff --git a/drivers/acpi/acpi_pad.c b/drivers/acpi/acpi_pad.c
index 0d2cdb86158b..97991ac6f5fc 100644
--- a/drivers/acpi/acpi_pad.c
+++ b/drivers/acpi/acpi_pad.c
@@ -100,7 +100,8 @@ static void round_robin_cpu(unsigned int tsk_index)
100 struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits); 100 struct cpumask *pad_busy_cpus = to_cpumask(pad_busy_cpus_bits);
101 cpumask_var_t tmp; 101 cpumask_var_t tmp;
102 int cpu; 102 int cpu;
103 unsigned long min_weight = -1, preferred_cpu; 103 unsigned long min_weight = -1;
104 unsigned long uninitialized_var(preferred_cpu);
104 105
105 if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) 106 if (!alloc_cpumask_var(&tmp, GFP_KERNEL))
106 return; 107 return;
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 *
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 3f4602b8f287..cada73ffdfa7 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -831,7 +831,7 @@ static void acpi_battery_notify(struct acpi_device *device, u32 event)
831 dev_name(&device->dev), event, 831 dev_name(&device->dev), event,
832 acpi_battery_present(battery)); 832 acpi_battery_present(battery));
833#ifdef CONFIG_ACPI_SYSFS_POWER 833#ifdef CONFIG_ACPI_SYSFS_POWER
834 /* acpi_batter_update could remove power_supply object */ 834 /* acpi_battery_update could remove power_supply object */
835 if (battery->bat.dev) 835 if (battery->bat.dev)
836 kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE); 836 kobject_uevent(&battery->bat.dev->kobj, KOBJ_CHANGE);
837#endif 837#endif
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 741191524353..65f7e335f122 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -344,6 +344,152 @@ bool acpi_bus_can_wakeup(acpi_handle handle)
344 344
345EXPORT_SYMBOL(acpi_bus_can_wakeup); 345EXPORT_SYMBOL(acpi_bus_can_wakeup);
346 346
347static void acpi_print_osc_error(acpi_handle handle,
348 struct acpi_osc_context *context, char *error)
349{
350 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER};
351 int i;
352
353 if (ACPI_FAILURE(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer)))
354 printk(KERN_DEBUG "%s\n", error);
355 else {
356 printk(KERN_DEBUG "%s:%s\n", (char *)buffer.pointer, error);
357 kfree(buffer.pointer);
358 }
359 printk(KERN_DEBUG"_OSC request data:");
360 for (i = 0; i < context->cap.length; i += sizeof(u32))
361 printk("%x ", *((u32 *)(context->cap.pointer + i)));
362 printk("\n");
363}
364
365static u8 hex_val(unsigned char c)
366{
367 return isdigit(c) ? c - '0' : toupper(c) - 'A' + 10;
368}
369
370static acpi_status acpi_str_to_uuid(char *str, u8 *uuid)
371{
372 int i;
373 static int opc_map_to_uuid[16] = {6, 4, 2, 0, 11, 9, 16, 14, 19, 21,
374 24, 26, 28, 30, 32, 34};
375
376 if (strlen(str) != 36)
377 return AE_BAD_PARAMETER;
378 for (i = 0; i < 36; i++) {
379 if (i == 8 || i == 13 || i == 18 || i == 23) {
380 if (str[i] != '-')
381 return AE_BAD_PARAMETER;
382 } else if (!isxdigit(str[i]))
383 return AE_BAD_PARAMETER;
384 }
385 for (i = 0; i < 16; i++) {
386 uuid[i] = hex_val(str[opc_map_to_uuid[i]]) << 4;
387 uuid[i] |= hex_val(str[opc_map_to_uuid[i] + 1]);
388 }
389 return AE_OK;
390}
391
392acpi_status acpi_run_osc(acpi_handle handle, struct acpi_osc_context *context)
393{
394 acpi_status status;
395 struct acpi_object_list input;
396 union acpi_object in_params[4];
397 union acpi_object *out_obj;
398 u8 uuid[16];
399 u32 errors;
400
401 if (!context)
402 return AE_ERROR;
403 if (ACPI_FAILURE(acpi_str_to_uuid(context->uuid_str, uuid)))
404 return AE_ERROR;
405 context->ret.length = ACPI_ALLOCATE_BUFFER;
406 context->ret.pointer = NULL;
407
408 /* Setting up input parameters */
409 input.count = 4;
410 input.pointer = in_params;
411 in_params[0].type = ACPI_TYPE_BUFFER;
412 in_params[0].buffer.length = 16;
413 in_params[0].buffer.pointer = uuid;
414 in_params[1].type = ACPI_TYPE_INTEGER;
415 in_params[1].integer.value = context->rev;
416 in_params[2].type = ACPI_TYPE_INTEGER;
417 in_params[2].integer.value = context->cap.length/sizeof(u32);
418 in_params[3].type = ACPI_TYPE_BUFFER;
419 in_params[3].buffer.length = context->cap.length;
420 in_params[3].buffer.pointer = context->cap.pointer;
421
422 status = acpi_evaluate_object(handle, "_OSC", &input, &context->ret);
423 if (ACPI_FAILURE(status))
424 return status;
425
426 /* return buffer should have the same length as cap buffer */
427 if (context->ret.length != context->cap.length)
428 return AE_NULL_OBJECT;
429
430 out_obj = context->ret.pointer;
431 if (out_obj->type != ACPI_TYPE_BUFFER) {
432 acpi_print_osc_error(handle, context,
433 "_OSC evaluation returned wrong type");
434 status = AE_TYPE;
435 goto out_kfree;
436 }
437 /* Need to ignore the bit0 in result code */
438 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
439 if (errors) {
440 if (errors & OSC_REQUEST_ERROR)
441 acpi_print_osc_error(handle, context,
442 "_OSC request failed");
443 if (errors & OSC_INVALID_UUID_ERROR)
444 acpi_print_osc_error(handle, context,
445 "_OSC invalid UUID");
446 if (errors & OSC_INVALID_REVISION_ERROR)
447 acpi_print_osc_error(handle, context,
448 "_OSC invalid revision");
449 if (errors & OSC_CAPABILITIES_MASK_ERROR) {
450 if (((u32 *)context->cap.pointer)[OSC_QUERY_TYPE]
451 & OSC_QUERY_ENABLE)
452 goto out_success;
453 status = AE_SUPPORT;
454 goto out_kfree;
455 }
456 status = AE_ERROR;
457 goto out_kfree;
458 }
459out_success:
460 return AE_OK;
461
462out_kfree:
463 kfree(context->ret.pointer);
464 context->ret.pointer = NULL;
465 return status;
466}
467EXPORT_SYMBOL(acpi_run_osc);
468
469static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
470static void acpi_bus_osc_support(void)
471{
472 u32 capbuf[2];
473 struct acpi_osc_context context = {
474 .uuid_str = sb_uuid_str,
475 .rev = 1,
476 .cap.length = 8,
477 .cap.pointer = capbuf,
478 };
479 acpi_handle handle;
480
481 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
482 capbuf[OSC_SUPPORT_TYPE] = OSC_SB_PR3_SUPPORT; /* _PR3 is in use */
483#ifdef CONFIG_ACPI_PROCESSOR_AGGREGATOR
484 capbuf[OSC_SUPPORT_TYPE] |= OSC_SB_PAD_SUPPORT;
485#endif
486 if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
487 return;
488 if (ACPI_SUCCESS(acpi_run_osc(handle, &context)))
489 kfree(context.ret.pointer);
490 /* do we need to check the returned cap? Sounds no */
491}
492
347/* -------------------------------------------------------------------------- 493/* --------------------------------------------------------------------------
348 Event Management 494 Event Management
349 -------------------------------------------------------------------------- */ 495 -------------------------------------------------------------------------- */
@@ -734,6 +880,8 @@ static int __init acpi_bus_init(void)
734 status = acpi_ec_ecdt_probe(); 880 status = acpi_ec_ecdt_probe();
735 /* Ignore result. Not having an ECDT is not fatal. */ 881 /* Ignore result. Not having an ECDT is not fatal. */
736 882
883 acpi_bus_osc_support();
884
737 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION); 885 status = acpi_initialize_objects(ACPI_FULL_INITIALIZATION);
738 if (ACPI_FAILURE(status)) { 886 if (ACPI_FAILURE(status)) {
739 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n"); 887 printk(KERN_ERR PREFIX "Unable to initialize ACPI objects\n");
diff --git a/drivers/acpi/button.c b/drivers/acpi/button.c
index 0c9c6a9a002c..8a95e8329df7 100644
--- a/drivers/acpi/button.c
+++ b/drivers/acpi/button.c
@@ -282,6 +282,13 @@ static int acpi_lid_send_state(struct acpi_device *device)
282 if (ret == NOTIFY_DONE) 282 if (ret == NOTIFY_DONE)
283 ret = blocking_notifier_call_chain(&acpi_lid_notifier, state, 283 ret = blocking_notifier_call_chain(&acpi_lid_notifier, state,
284 device); 284 device);
285 if (ret == NOTIFY_DONE || ret == NOTIFY_OK) {
286 /*
287 * It is also regarded as success if the notifier_chain
288 * returns NOTIFY_OK or NOTIFY_DONE.
289 */
290 ret = 0;
291 }
285 return ret; 292 return ret;
286} 293}
287 294
diff --git a/drivers/acpi/debug.c b/drivers/acpi/debug.c
index 8a690c3b8e23..cc421b7ae166 100644
--- a/drivers/acpi/debug.c
+++ b/drivers/acpi/debug.c
@@ -8,6 +8,7 @@
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/kernel.h> 9#include <linux/kernel.h>
10#include <linux/moduleparam.h> 10#include <linux/moduleparam.h>
11#include <linux/debugfs.h>
11#include <asm/uaccess.h> 12#include <asm/uaccess.h>
12#include <acpi/acpi_drivers.h> 13#include <acpi/acpi_drivers.h>
13 14
@@ -196,6 +197,80 @@ module_param_call(trace_state, param_set_trace_state, param_get_trace_state,
196 NULL, 0644); 197 NULL, 0644);
197 198
198/* -------------------------------------------------------------------------- 199/* --------------------------------------------------------------------------
200 DebugFS Interface
201 -------------------------------------------------------------------------- */
202
203static ssize_t cm_write(struct file *file, const char __user *user_buf,
204 size_t count, loff_t *ppos)
205{
206 static char *buf;
207 static int uncopied_bytes;
208 struct acpi_table_header table;
209 acpi_status status;
210
211 if (!(*ppos)) {
212 /* parse the table header to get the table length */
213 if (count <= sizeof(struct acpi_table_header))
214 return -EINVAL;
215 if (copy_from_user(&table, user_buf,
216 sizeof(struct acpi_table_header)))
217 return -EFAULT;
218 uncopied_bytes = table.length;
219 buf = kzalloc(uncopied_bytes, GFP_KERNEL);
220 if (!buf)
221 return -ENOMEM;
222 }
223
224 if (uncopied_bytes < count) {
225 kfree(buf);
226 return -EINVAL;
227 }
228
229 if (copy_from_user(buf + (*ppos), user_buf, count)) {
230 kfree(buf);
231 return -EFAULT;
232 }
233
234 uncopied_bytes -= count;
235 *ppos += count;
236
237 if (!uncopied_bytes) {
238 status = acpi_install_method(buf);
239 kfree(buf);
240 if (ACPI_FAILURE(status))
241 return -EINVAL;
242 add_taint(TAINT_OVERRIDDEN_ACPI_TABLE);
243 }
244
245 return count;
246}
247
248static const struct file_operations cm_fops = {
249 .write = cm_write,
250};
251
252static int acpi_debugfs_init(void)
253{
254 struct dentry *acpi_dir, *cm_dentry;
255
256 acpi_dir = debugfs_create_dir("acpi", NULL);
257 if (!acpi_dir)
258 goto err;
259
260 cm_dentry = debugfs_create_file("custom_method", S_IWUGO,
261 acpi_dir, NULL, &cm_fops);
262 if (!cm_dentry)
263 goto err;
264
265 return 0;
266
267err:
268 if (acpi_dir)
269 debugfs_remove(acpi_dir);
270 return -EINVAL;
271}
272
273/* --------------------------------------------------------------------------
199 FS Interface (/proc) 274 FS Interface (/proc)
200 -------------------------------------------------------------------------- */ 275 -------------------------------------------------------------------------- */
201#ifdef CONFIG_ACPI_PROCFS 276#ifdef CONFIG_ACPI_PROCFS
@@ -286,7 +361,7 @@ static const struct file_operations acpi_system_debug_proc_fops = {
286}; 361};
287#endif 362#endif
288 363
289int __init acpi_debug_init(void) 364int __init acpi_procfs_init(void)
290{ 365{
291#ifdef CONFIG_ACPI_PROCFS 366#ifdef CONFIG_ACPI_PROCFS
292 struct proc_dir_entry *entry; 367 struct proc_dir_entry *entry;
@@ -321,3 +396,10 @@ int __init acpi_debug_init(void)
321 return 0; 396 return 0;
322#endif 397#endif
323} 398}
399
400int __init acpi_debug_init(void)
401{
402 acpi_debugfs_init();
403 acpi_procfs_init();
404 return 0;
405}
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 30be3c148f7e..bbc2c1315c47 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -50,7 +50,6 @@ MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
50 " before undocking"); 50 " before undocking");
51 51
52static struct atomic_notifier_head dock_notifier_list; 52static struct atomic_notifier_head dock_notifier_list;
53static char dock_device_name[] = "dock";
54 53
55static const struct acpi_device_id dock_device_ids[] = { 54static const struct acpi_device_id dock_device_ids[] = {
56 {"LNXDOCK", 0}, 55 {"LNXDOCK", 0},
@@ -93,40 +92,30 @@ struct dock_dependent_device {
93 * Dock Dependent device functions * 92 * Dock Dependent device functions *
94 *****************************************************************************/ 93 *****************************************************************************/
95/** 94/**
96 * alloc_dock_dependent_device - allocate and init a dependent device 95 * add_dock_dependent_device - associate a device with the dock station
97 * @handle: the acpi_handle of the dependent device 96 * @ds: The dock station
97 * @handle: handle of the dependent device
98 * 98 *
99 * Allocate memory for a dependent device structure for a device referenced 99 * Add the dependent device to the dock's dependent device list.
100 * by the acpi handle
101 */ 100 */
102static struct dock_dependent_device * 101static int
103alloc_dock_dependent_device(acpi_handle handle) 102add_dock_dependent_device(struct dock_station *ds, acpi_handle handle)
104{ 103{
105 struct dock_dependent_device *dd; 104 struct dock_dependent_device *dd;
106 105
107 dd = kzalloc(sizeof(*dd), GFP_KERNEL); 106 dd = kzalloc(sizeof(*dd), GFP_KERNEL);
108 if (dd) { 107 if (!dd)
109 dd->handle = handle; 108 return -ENOMEM;
110 INIT_LIST_HEAD(&dd->list); 109
111 INIT_LIST_HEAD(&dd->hotplug_list); 110 dd->handle = handle;
112 } 111 INIT_LIST_HEAD(&dd->list);
113 return dd; 112 INIT_LIST_HEAD(&dd->hotplug_list);
114}
115 113
116/**
117 * add_dock_dependent_device - associate a device with the dock station
118 * @ds: The dock station
119 * @dd: The dependent device
120 *
121 * Add the dependent device to the dock's dependent device list.
122 */
123static void
124add_dock_dependent_device(struct dock_station *ds,
125 struct dock_dependent_device *dd)
126{
127 spin_lock(&ds->dd_lock); 114 spin_lock(&ds->dd_lock);
128 list_add_tail(&dd->list, &ds->dependent_devices); 115 list_add_tail(&dd->list, &ds->dependent_devices);
129 spin_unlock(&ds->dd_lock); 116 spin_unlock(&ds->dd_lock);
117
118 return 0;
130} 119}
131 120
132/** 121/**
@@ -249,6 +238,7 @@ static int is_battery(acpi_handle handle)
249static int is_ejectable_bay(acpi_handle handle) 238static int is_ejectable_bay(acpi_handle handle)
250{ 239{
251 acpi_handle phandle; 240 acpi_handle phandle;
241
252 if (!is_ejectable(handle)) 242 if (!is_ejectable(handle))
253 return 0; 243 return 0;
254 if (is_battery(handle) || is_ata(handle)) 244 if (is_battery(handle) || is_ata(handle))
@@ -275,14 +265,13 @@ int is_dock_device(acpi_handle handle)
275 265
276 if (is_dock(handle)) 266 if (is_dock(handle))
277 return 1; 267 return 1;
278 list_for_each_entry(dock_station, &dock_stations, sibling) { 268
269 list_for_each_entry(dock_station, &dock_stations, sibling)
279 if (find_dock_dependent_device(dock_station, handle)) 270 if (find_dock_dependent_device(dock_station, handle))
280 return 1; 271 return 1;
281 }
282 272
283 return 0; 273 return 0;
284} 274}
285
286EXPORT_SYMBOL_GPL(is_dock_device); 275EXPORT_SYMBOL_GPL(is_dock_device);
287 276
288/** 277/**
@@ -305,8 +294,6 @@ static int dock_present(struct dock_station *ds)
305 return 0; 294 return 0;
306} 295}
307 296
308
309
310/** 297/**
311 * dock_create_acpi_device - add new devices to acpi 298 * dock_create_acpi_device - add new devices to acpi
312 * @handle - handle of the device to add 299 * @handle - handle of the device to add
@@ -320,7 +307,7 @@ static int dock_present(struct dock_station *ds)
320 */ 307 */
321static struct acpi_device * dock_create_acpi_device(acpi_handle handle) 308static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
322{ 309{
323 struct acpi_device *device = NULL; 310 struct acpi_device *device;
324 struct acpi_device *parent_device; 311 struct acpi_device *parent_device;
325 acpi_handle parent; 312 acpi_handle parent;
326 int ret; 313 int ret;
@@ -337,8 +324,7 @@ static struct acpi_device * dock_create_acpi_device(acpi_handle handle)
337 ret = acpi_bus_add(&device, parent_device, handle, 324 ret = acpi_bus_add(&device, parent_device, handle,
338 ACPI_BUS_TYPE_DEVICE); 325 ACPI_BUS_TYPE_DEVICE);
339 if (ret) { 326 if (ret) {
340 pr_debug("error adding bus, %x\n", 327 pr_debug("error adding bus, %x\n", -ret);
341 -ret);
342 return NULL; 328 return NULL;
343 } 329 }
344 } 330 }
@@ -364,7 +350,6 @@ static void dock_remove_acpi_device(acpi_handle handle)
364 } 350 }
365} 351}
366 352
367
368/** 353/**
369 * hotplug_dock_devices - insert or remove devices on the dock station 354 * hotplug_dock_devices - insert or remove devices on the dock station
370 * @ds: the dock station 355 * @ds: the dock station
@@ -384,10 +369,9 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
384 /* 369 /*
385 * First call driver specific hotplug functions 370 * First call driver specific hotplug functions
386 */ 371 */
387 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) { 372 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list)
388 if (dd->ops && dd->ops->handler) 373 if (dd->ops && dd->ops->handler)
389 dd->ops->handler(dd->handle, event, dd->context); 374 dd->ops->handler(dd->handle, event, dd->context);
390 }
391 375
392 /* 376 /*
393 * Now make sure that an acpi_device is created for each 377 * Now make sure that an acpi_device is created for each
@@ -426,6 +410,7 @@ static void dock_event(struct dock_station *ds, u32 event, int num)
426 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list) 410 list_for_each_entry(dd, &ds->hotplug_devices, hotplug_list)
427 if (dd->ops && dd->ops->uevent) 411 if (dd->ops && dd->ops->uevent)
428 dd->ops->uevent(dd->handle, event, dd->context); 412 dd->ops->uevent(dd->handle, event, dd->context);
413
429 if (num != DOCK_EVENT) 414 if (num != DOCK_EVENT)
430 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); 415 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
431} 416}
@@ -456,8 +441,8 @@ static void eject_dock(struct dock_station *ds)
456 arg.type = ACPI_TYPE_INTEGER; 441 arg.type = ACPI_TYPE_INTEGER;
457 arg.integer.value = 1; 442 arg.integer.value = 1;
458 443
459 if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0", 444 status = acpi_evaluate_object(ds->handle, "_EJ0", &arg_list, NULL);
460 &arg_list, NULL))) 445 if (ACPI_FAILURE(status))
461 pr_debug("Failed to evaluate _EJ0!\n"); 446 pr_debug("Failed to evaluate _EJ0!\n");
462} 447}
463 448
@@ -577,7 +562,6 @@ int register_dock_notifier(struct notifier_block *nb)
577 562
578 return atomic_notifier_chain_register(&dock_notifier_list, nb); 563 return atomic_notifier_chain_register(&dock_notifier_list, nb);
579} 564}
580
581EXPORT_SYMBOL_GPL(register_dock_notifier); 565EXPORT_SYMBOL_GPL(register_dock_notifier);
582 566
583/** 567/**
@@ -591,7 +575,6 @@ void unregister_dock_notifier(struct notifier_block *nb)
591 575
592 atomic_notifier_chain_unregister(&dock_notifier_list, nb); 576 atomic_notifier_chain_unregister(&dock_notifier_list, nb);
593} 577}
594
595EXPORT_SYMBOL_GPL(unregister_dock_notifier); 578EXPORT_SYMBOL_GPL(unregister_dock_notifier);
596 579
597/** 580/**
@@ -636,7 +619,6 @@ register_hotplug_dock_device(acpi_handle handle, struct acpi_dock_ops *ops,
636 619
637 return ret; 620 return ret;
638} 621}
639
640EXPORT_SYMBOL_GPL(register_hotplug_dock_device); 622EXPORT_SYMBOL_GPL(register_hotplug_dock_device);
641 623
642/** 624/**
@@ -657,7 +639,6 @@ void unregister_hotplug_dock_device(acpi_handle handle)
657 dock_del_hotplug_device(dock_station, dd); 639 dock_del_hotplug_device(dock_station, dd);
658 } 640 }
659} 641}
660
661EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device); 642EXPORT_SYMBOL_GPL(unregister_hotplug_dock_device);
662 643
663/** 644/**
@@ -772,7 +753,7 @@ struct dock_data {
772 753
773static void acpi_dock_deferred_cb(void *context) 754static void acpi_dock_deferred_cb(void *context)
774{ 755{
775 struct dock_data *data = (struct dock_data *)context; 756 struct dock_data *data = context;
776 757
777 dock_notify(data->handle, data->event, data->ds); 758 dock_notify(data->handle, data->event, data->ds);
778 kfree(data); 759 kfree(data);
@@ -782,23 +763,22 @@ static int acpi_dock_notifier_call(struct notifier_block *this,
782 unsigned long event, void *data) 763 unsigned long event, void *data)
783{ 764{
784 struct dock_station *dock_station; 765 struct dock_station *dock_station;
785 acpi_handle handle = (acpi_handle)data; 766 acpi_handle handle = data;
786 767
787 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK 768 if (event != ACPI_NOTIFY_BUS_CHECK && event != ACPI_NOTIFY_DEVICE_CHECK
788 && event != ACPI_NOTIFY_EJECT_REQUEST) 769 && event != ACPI_NOTIFY_EJECT_REQUEST)
789 return 0; 770 return 0;
790 list_for_each_entry(dock_station, &dock_stations, sibling) { 771 list_for_each_entry(dock_station, &dock_stations, sibling) {
791 if (dock_station->handle == handle) { 772 if (dock_station->handle == handle) {
792 struct dock_data *dock_data; 773 struct dock_data *dd;
793 774
794 dock_data = kmalloc(sizeof(*dock_data), GFP_KERNEL); 775 dd = kmalloc(sizeof(*dd), GFP_KERNEL);
795 if (!dock_data) 776 if (!dd)
796 return 0; 777 return 0;
797 dock_data->handle = handle; 778 dd->handle = handle;
798 dock_data->event = event; 779 dd->event = event;
799 dock_data->ds = dock_station; 780 dd->ds = dock_station;
800 acpi_os_hotplug_execute(acpi_dock_deferred_cb, 781 acpi_os_hotplug_execute(acpi_dock_deferred_cb, dd);
801 dock_data);
802 return 0 ; 782 return 0 ;
803 } 783 }
804 } 784 }
@@ -826,7 +806,6 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
826 acpi_status status; 806 acpi_status status;
827 acpi_handle tmp, parent; 807 acpi_handle tmp, parent;
828 struct dock_station *ds = context; 808 struct dock_station *ds = context;
829 struct dock_dependent_device *dd;
830 809
831 status = acpi_bus_get_ejd(handle, &tmp); 810 status = acpi_bus_get_ejd(handle, &tmp);
832 if (ACPI_FAILURE(status)) { 811 if (ACPI_FAILURE(status)) {
@@ -840,11 +819,9 @@ find_dock_devices(acpi_handle handle, u32 lvl, void *context, void **rv)
840 goto fdd_out; 819 goto fdd_out;
841 } 820 }
842 821
843 if (tmp == ds->handle) { 822 if (tmp == ds->handle)
844 dd = alloc_dock_dependent_device(handle); 823 add_dock_dependent_device(ds, handle);
845 if (dd) 824
846 add_dock_dependent_device(ds, dd);
847 }
848fdd_out: 825fdd_out:
849 return AE_OK; 826 return AE_OK;
850} 827}
@@ -857,8 +834,7 @@ static ssize_t show_docked(struct device *dev,
857{ 834{
858 struct acpi_device *tmp; 835 struct acpi_device *tmp;
859 836
860 struct dock_station *dock_station = *((struct dock_station **) 837 struct dock_station *dock_station = dev->platform_data;
861 dev->platform_data);
862 838
863 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp))) 839 if (ACPI_SUCCESS(acpi_bus_get_device(dock_station->handle, &tmp)))
864 return snprintf(buf, PAGE_SIZE, "1\n"); 840 return snprintf(buf, PAGE_SIZE, "1\n");
@@ -872,8 +848,7 @@ static DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
872static ssize_t show_flags(struct device *dev, 848static ssize_t show_flags(struct device *dev,
873 struct device_attribute *attr, char *buf) 849 struct device_attribute *attr, char *buf)
874{ 850{
875 struct dock_station *dock_station = *((struct dock_station **) 851 struct dock_station *dock_station = dev->platform_data;
876 dev->platform_data);
877 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags); 852 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
878 853
879} 854}
@@ -886,8 +861,7 @@ static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
886 const char *buf, size_t count) 861 const char *buf, size_t count)
887{ 862{
888 int ret; 863 int ret;
889 struct dock_station *dock_station = *((struct dock_station **) 864 struct dock_station *dock_station = dev->platform_data;
890 dev->platform_data);
891 865
892 if (!count) 866 if (!count)
893 return -EINVAL; 867 return -EINVAL;
@@ -905,8 +879,7 @@ static ssize_t show_dock_uid(struct device *dev,
905 struct device_attribute *attr, char *buf) 879 struct device_attribute *attr, char *buf)
906{ 880{
907 unsigned long long lbuf; 881 unsigned long long lbuf;
908 struct dock_station *dock_station = *((struct dock_station **) 882 struct dock_station *dock_station = dev->platform_data;
909 dev->platform_data);
910 acpi_status status = acpi_evaluate_integer(dock_station->handle, 883 acpi_status status = acpi_evaluate_integer(dock_station->handle,
911 "_UID", NULL, &lbuf); 884 "_UID", NULL, &lbuf);
912 if (ACPI_FAILURE(status)) 885 if (ACPI_FAILURE(status))
@@ -919,8 +892,7 @@ static DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
919static ssize_t show_dock_type(struct device *dev, 892static ssize_t show_dock_type(struct device *dev,
920 struct device_attribute *attr, char *buf) 893 struct device_attribute *attr, char *buf)
921{ 894{
922 struct dock_station *dock_station = *((struct dock_station **) 895 struct dock_station *dock_station = dev->platform_data;
923 dev->platform_data);
924 char *type; 896 char *type;
925 897
926 if (dock_station->flags & DOCK_IS_DOCK) 898 if (dock_station->flags & DOCK_IS_DOCK)
@@ -936,6 +908,19 @@ static ssize_t show_dock_type(struct device *dev,
936} 908}
937static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL); 909static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
938 910
911static struct attribute *dock_attributes[] = {
912 &dev_attr_docked.attr,
913 &dev_attr_flags.attr,
914 &dev_attr_undock.attr,
915 &dev_attr_uid.attr,
916 &dev_attr_type.attr,
917 NULL
918};
919
920static struct attribute_group dock_attribute_group = {
921 .attrs = dock_attributes
922};
923
939/** 924/**
940 * dock_add - add a new dock station 925 * dock_add - add a new dock station
941 * @handle: the dock station handle 926 * @handle: the dock station handle
@@ -945,39 +930,30 @@ static DEVICE_ATTR(type, S_IRUGO, show_dock_type, NULL);
945 */ 930 */
946static int dock_add(acpi_handle handle) 931static int dock_add(acpi_handle handle)
947{ 932{
948 int ret; 933 int ret, id;
949 struct dock_dependent_device *dd; 934 struct dock_station ds, *dock_station;
950 struct dock_station *dock_station; 935 struct platform_device *dd;
951 struct platform_device *dock_device; 936
937 id = dock_station_count;
938 dd = platform_device_register_data(NULL, "dock", id, &ds, sizeof(ds));
939 if (IS_ERR(dd))
940 return PTR_ERR(dd);
941
942 dock_station = dd->dev.platform_data;
952 943
953 /* allocate & initialize the dock_station private data */
954 dock_station = kzalloc(sizeof(*dock_station), GFP_KERNEL);
955 if (!dock_station)
956 return -ENOMEM;
957 dock_station->handle = handle; 944 dock_station->handle = handle;
945 dock_station->dock_device = dd;
958 dock_station->last_dock_time = jiffies - HZ; 946 dock_station->last_dock_time = jiffies - HZ;
959 INIT_LIST_HEAD(&dock_station->dependent_devices); 947
960 INIT_LIST_HEAD(&dock_station->hotplug_devices);
961 INIT_LIST_HEAD(&dock_station->sibling);
962 spin_lock_init(&dock_station->dd_lock);
963 mutex_init(&dock_station->hp_lock); 948 mutex_init(&dock_station->hp_lock);
949 spin_lock_init(&dock_station->dd_lock);
950 INIT_LIST_HEAD(&dock_station->sibling);
951 INIT_LIST_HEAD(&dock_station->hotplug_devices);
964 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); 952 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
965 953 INIT_LIST_HEAD(&dock_station->dependent_devices);
966 /* initialize platform device stuff */
967 dock_station->dock_device =
968 platform_device_register_simple(dock_device_name,
969 dock_station_count, NULL, 0);
970 dock_device = dock_station->dock_device;
971 if (IS_ERR(dock_device)) {
972 kfree(dock_station);
973 dock_station = NULL;
974 return PTR_ERR(dock_device);
975 }
976 platform_device_add_data(dock_device, &dock_station,
977 sizeof(struct dock_station *));
978 954
979 /* we want the dock device to send uevents */ 955 /* we want the dock device to send uevents */
980 dev_set_uevent_suppress(&dock_device->dev, 0); 956 dev_set_uevent_suppress(&dd->dev, 0);
981 957
982 if (is_dock(handle)) 958 if (is_dock(handle))
983 dock_station->flags |= DOCK_IS_DOCK; 959 dock_station->flags |= DOCK_IS_DOCK;
@@ -986,47 +962,9 @@ static int dock_add(acpi_handle handle)
986 if (is_battery(handle)) 962 if (is_battery(handle))
987 dock_station->flags |= DOCK_IS_BAT; 963 dock_station->flags |= DOCK_IS_BAT;
988 964
989 ret = device_create_file(&dock_device->dev, &dev_attr_docked); 965 ret = sysfs_create_group(&dd->dev.kobj, &dock_attribute_group);
990 if (ret) {
991 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
992 platform_device_unregister(dock_device);
993 kfree(dock_station);
994 dock_station = NULL;
995 return ret;
996 }
997 ret = device_create_file(&dock_device->dev, &dev_attr_undock);
998 if (ret) {
999 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1000 device_remove_file(&dock_device->dev, &dev_attr_docked);
1001 platform_device_unregister(dock_device);
1002 kfree(dock_station);
1003 dock_station = NULL;
1004 return ret;
1005 }
1006 ret = device_create_file(&dock_device->dev, &dev_attr_uid);
1007 if (ret) {
1008 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1009 device_remove_file(&dock_device->dev, &dev_attr_docked);
1010 device_remove_file(&dock_device->dev, &dev_attr_undock);
1011 platform_device_unregister(dock_device);
1012 kfree(dock_station);
1013 dock_station = NULL;
1014 return ret;
1015 }
1016 ret = device_create_file(&dock_device->dev, &dev_attr_flags);
1017 if (ret) {
1018 printk(KERN_ERR "Error %d adding sysfs file\n", ret);
1019 device_remove_file(&dock_device->dev, &dev_attr_docked);
1020 device_remove_file(&dock_device->dev, &dev_attr_undock);
1021 device_remove_file(&dock_device->dev, &dev_attr_uid);
1022 platform_device_unregister(dock_device);
1023 kfree(dock_station);
1024 dock_station = NULL;
1025 return ret;
1026 }
1027 ret = device_create_file(&dock_device->dev, &dev_attr_type);
1028 if (ret) 966 if (ret)
1029 printk(KERN_ERR"Error %d adding sysfs file\n", ret); 967 goto err_unregister;
1030 968
1031 /* Find dependent devices */ 969 /* Find dependent devices */
1032 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, 970 acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
@@ -1034,58 +972,43 @@ static int dock_add(acpi_handle handle)
1034 dock_station, NULL); 972 dock_station, NULL);
1035 973
1036 /* add the dock station as a device dependent on itself */ 974 /* add the dock station as a device dependent on itself */
1037 dd = alloc_dock_dependent_device(handle); 975 ret = add_dock_dependent_device(dock_station, handle);
1038 if (!dd) { 976 if (ret)
1039 kfree(dock_station); 977 goto err_rmgroup;
1040 dock_station = NULL;
1041 ret = -ENOMEM;
1042 goto dock_add_err_unregister;
1043 }
1044 add_dock_dependent_device(dock_station, dd);
1045 978
1046 dock_station_count++; 979 dock_station_count++;
1047 list_add(&dock_station->sibling, &dock_stations); 980 list_add(&dock_station->sibling, &dock_stations);
1048 return 0; 981 return 0;
1049 982
1050dock_add_err_unregister: 983err_rmgroup:
1051 device_remove_file(&dock_device->dev, &dev_attr_type); 984 sysfs_remove_group(&dd->dev.kobj, &dock_attribute_group);
1052 device_remove_file(&dock_device->dev, &dev_attr_docked); 985err_unregister:
1053 device_remove_file(&dock_device->dev, &dev_attr_undock); 986 platform_device_unregister(dd);
1054 device_remove_file(&dock_device->dev, &dev_attr_uid); 987 printk(KERN_ERR "%s encountered error %d\n", __func__, ret);
1055 device_remove_file(&dock_device->dev, &dev_attr_flags);
1056 platform_device_unregister(dock_device);
1057 kfree(dock_station);
1058 dock_station = NULL;
1059 return ret; 988 return ret;
1060} 989}
1061 990
1062/** 991/**
1063 * dock_remove - free up resources related to the dock station 992 * dock_remove - free up resources related to the dock station
1064 */ 993 */
1065static int dock_remove(struct dock_station *dock_station) 994static int dock_remove(struct dock_station *ds)
1066{ 995{
1067 struct dock_dependent_device *dd, *tmp; 996 struct dock_dependent_device *dd, *tmp;
1068 struct platform_device *dock_device = dock_station->dock_device; 997 struct platform_device *dock_device = ds->dock_device;
1069 998
1070 if (!dock_station_count) 999 if (!dock_station_count)
1071 return 0; 1000 return 0;
1072 1001
1073 /* remove dependent devices */ 1002 /* remove dependent devices */
1074 list_for_each_entry_safe(dd, tmp, &dock_station->dependent_devices, 1003 list_for_each_entry_safe(dd, tmp, &ds->dependent_devices, list)
1075 list) 1004 kfree(dd);
1076 kfree(dd); 1005
1006 list_del(&ds->sibling);
1077 1007
1078 /* cleanup sysfs */ 1008 /* cleanup sysfs */
1079 device_remove_file(&dock_device->dev, &dev_attr_type); 1009 sysfs_remove_group(&dock_device->dev.kobj, &dock_attribute_group);
1080 device_remove_file(&dock_device->dev, &dev_attr_docked);
1081 device_remove_file(&dock_device->dev, &dev_attr_undock);
1082 device_remove_file(&dock_device->dev, &dev_attr_uid);
1083 device_remove_file(&dock_device->dev, &dev_attr_flags);
1084 platform_device_unregister(dock_device); 1010 platform_device_unregister(dock_device);
1085 1011
1086 /* free dock station memory */
1087 kfree(dock_station);
1088 dock_station = NULL;
1089 return 0; 1012 return 0;
1090} 1013}
1091 1014
@@ -1103,11 +1026,10 @@ find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
1103{ 1026{
1104 acpi_status status = AE_OK; 1027 acpi_status status = AE_OK;
1105 1028
1106 if (is_dock(handle)) { 1029 if (is_dock(handle))
1107 if (dock_add(handle) >= 0) { 1030 if (dock_add(handle) >= 0)
1108 status = AE_CTRL_TERMINATE; 1031 status = AE_CTRL_TERMINATE;
1109 } 1032
1110 }
1111 return status; 1033 return status;
1112} 1034}
1113 1035
@@ -1145,8 +1067,7 @@ static int __init dock_init(void)
1145 1067
1146static void __exit dock_exit(void) 1068static void __exit dock_exit(void)
1147{ 1069{
1148 struct dock_station *dock_station; 1070 struct dock_station *tmp, *dock_station;
1149 struct dock_station *tmp;
1150 1071
1151 unregister_acpi_bus_notifier(&dock_acpi_notifier); 1072 unregister_acpi_bus_notifier(&dock_acpi_notifier);
1152 list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling) 1073 list_for_each_entry_safe(dock_station, tmp, &dock_stations, sibling)
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index f419849a0d3f..acf2ab249842 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -267,7 +267,7 @@ static int acpi_fan_add(struct acpi_device *device)
267 goto end; 267 goto end;
268 } 268 }
269 269
270 dev_info(&device->dev, "registered as cooling_device%d\n", cdev->id); 270 dev_dbg(&device->dev, "registered as cooling_device%d\n", cdev->id);
271 271
272 device->driver_data = cdev; 272 device->driver_data = cdev;
273 result = sysfs_create_link(&device->dev.kobj, 273 result = sysfs_create_link(&device->dev.kobj,
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 2be2fb66204e..7ad48dfc12db 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -28,6 +28,7 @@
28#include <linux/types.h> 28#include <linux/types.h>
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/acpi.h> 30#include <linux/acpi.h>
31#include <linux/numa.h>
31#include <acpi/acpi_bus.h> 32#include <acpi/acpi_bus.h>
32 33
33#define PREFIX "ACPI: " 34#define PREFIX "ACPI: "
@@ -40,14 +41,14 @@ static nodemask_t nodes_found_map = NODE_MASK_NONE;
40 41
41/* maps to convert between proximity domain and logical node ID */ 42/* maps to convert between proximity domain and logical node ID */
42static int pxm_to_node_map[MAX_PXM_DOMAINS] 43static int pxm_to_node_map[MAX_PXM_DOMAINS]
43 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL }; 44 = { [0 ... MAX_PXM_DOMAINS - 1] = NUMA_NO_NODE };
44static int node_to_pxm_map[MAX_NUMNODES] 45static int node_to_pxm_map[MAX_NUMNODES]
45 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; 46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
46 47
47int pxm_to_node(int pxm) 48int pxm_to_node(int pxm)
48{ 49{
49 if (pxm < 0) 50 if (pxm < 0)
50 return NID_INVAL; 51 return NUMA_NO_NODE;
51 return pxm_to_node_map[pxm]; 52 return pxm_to_node_map[pxm];
52} 53}
53 54
@@ -68,9 +69,9 @@ int acpi_map_pxm_to_node(int pxm)
68{ 69{
69 int node = pxm_to_node_map[pxm]; 70 int node = pxm_to_node_map[pxm];
70 71
71 if (node < 0){ 72 if (node < 0) {
72 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES) 73 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
73 return NID_INVAL; 74 return NUMA_NO_NODE;
74 node = first_unset_node(nodes_found_map); 75 node = first_unset_node(nodes_found_map);
75 __acpi_map_pxm_to_node(pxm, node); 76 __acpi_map_pxm_to_node(pxm, node);
76 node_set(node, nodes_found_map); 77 node_set(node, nodes_found_map);
@@ -79,16 +80,6 @@ int acpi_map_pxm_to_node(int pxm)
79 return node; 80 return node;
80} 81}
81 82
82#if 0
83void __cpuinit acpi_unmap_pxm_to_node(int node)
84{
85 int pxm = node_to_pxm_map[node];
86 pxm_to_node_map[pxm] = NID_INVAL;
87 node_to_pxm_map[node] = PXM_INVAL;
88 node_clear(node, nodes_found_map);
89}
90#endif /* 0 */
91
92static void __init 83static void __init
93acpi_table_print_srat_entry(struct acpi_subtable_header *header) 84acpi_table_print_srat_entry(struct acpi_subtable_header *header)
94{ 85{
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 7c1c59ea9ec6..02e8464e480f 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -1118,7 +1118,7 @@ __setup("acpi_enforce_resources=", acpi_enforce_resources_setup);
1118 1118
1119/* Check for resource conflicts between ACPI OperationRegions and native 1119/* Check for resource conflicts between ACPI OperationRegions and native
1120 * drivers */ 1120 * drivers */
1121int acpi_check_resource_conflict(struct resource *res) 1121int acpi_check_resource_conflict(const struct resource *res)
1122{ 1122{
1123 struct acpi_res_list *res_list_elem; 1123 struct acpi_res_list *res_list_elem;
1124 int ioport; 1124 int ioport;
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
index 1af808171d46..101cce3681d1 100644
--- a/drivers/acpi/pci_root.c
+++ b/drivers/acpi/pci_root.c
@@ -202,72 +202,24 @@ static void acpi_pci_bridge_scan(struct acpi_device *device)
202 } 202 }
203} 203}
204 204
205static u8 OSC_UUID[16] = {0x5B, 0x4D, 0xDB, 0x33, 0xF7, 0x1F, 0x1C, 0x40, 205static u8 pci_osc_uuid_str[] = "33DB4D5B-1FF7-401C-9657-7441C03DD766";
206 0x96, 0x57, 0x74, 0x41, 0xC0, 0x3D, 0xD7, 0x66};
207 206
208static acpi_status acpi_pci_run_osc(acpi_handle handle, 207static acpi_status acpi_pci_run_osc(acpi_handle handle,
209 const u32 *capbuf, u32 *retval) 208 const u32 *capbuf, u32 *retval)
210{ 209{
210 struct acpi_osc_context context = {
211 .uuid_str = pci_osc_uuid_str,
212 .rev = 1,
213 .cap.length = 12,
214 .cap.pointer = (void *)capbuf,
215 };
211 acpi_status status; 216 acpi_status status;
212 struct acpi_object_list input;
213 union acpi_object in_params[4];
214 struct acpi_buffer output = {ACPI_ALLOCATE_BUFFER, NULL};
215 union acpi_object *out_obj;
216 u32 errors;
217
218 /* Setting up input parameters */
219 input.count = 4;
220 input.pointer = in_params;
221 in_params[0].type = ACPI_TYPE_BUFFER;
222 in_params[0].buffer.length = 16;
223 in_params[0].buffer.pointer = OSC_UUID;
224 in_params[1].type = ACPI_TYPE_INTEGER;
225 in_params[1].integer.value = 1;
226 in_params[2].type = ACPI_TYPE_INTEGER;
227 in_params[2].integer.value = 3;
228 in_params[3].type = ACPI_TYPE_BUFFER;
229 in_params[3].buffer.length = 12;
230 in_params[3].buffer.pointer = (u8 *)capbuf;
231
232 status = acpi_evaluate_object(handle, "_OSC", &input, &output);
233 if (ACPI_FAILURE(status))
234 return status;
235 217
236 if (!output.length) 218 status = acpi_run_osc(handle, &context);
237 return AE_NULL_OBJECT; 219 if (ACPI_SUCCESS(status)) {
238 220 *retval = *((u32 *)(context.ret.pointer + 8));
239 out_obj = output.pointer; 221 kfree(context.ret.pointer);
240 if (out_obj->type != ACPI_TYPE_BUFFER) {
241 printk(KERN_DEBUG "_OSC evaluation returned wrong type\n");
242 status = AE_TYPE;
243 goto out_kfree;
244 }
245 /* Need to ignore the bit0 in result code */
246 errors = *((u32 *)out_obj->buffer.pointer) & ~(1 << 0);
247 if (errors) {
248 if (errors & OSC_REQUEST_ERROR)
249 printk(KERN_DEBUG "_OSC request failed\n");
250 if (errors & OSC_INVALID_UUID_ERROR)
251 printk(KERN_DEBUG "_OSC invalid UUID\n");
252 if (errors & OSC_INVALID_REVISION_ERROR)
253 printk(KERN_DEBUG "_OSC invalid revision\n");
254 if (errors & OSC_CAPABILITIES_MASK_ERROR) {
255 if (capbuf[OSC_QUERY_TYPE] & OSC_QUERY_ENABLE)
256 goto out_success;
257 printk(KERN_DEBUG
258 "Firmware did not grant requested _OSC control\n");
259 status = AE_SUPPORT;
260 goto out_kfree;
261 }
262 status = AE_ERROR;
263 goto out_kfree;
264 } 222 }
265out_success:
266 *retval = *((u32 *)(out_obj->buffer.pointer + 8));
267 status = AE_OK;
268
269out_kfree:
270 kfree(output.pointer);
271 return status; 223 return status;
272} 224}
273 225
@@ -277,10 +229,10 @@ static acpi_status acpi_pci_query_osc(struct acpi_pci_root *root, u32 flags)
277 u32 support_set, result, capbuf[3]; 229 u32 support_set, result, capbuf[3];
278 230
279 /* do _OSC query for all possible controls */ 231 /* do _OSC query for all possible controls */
280 support_set = root->osc_support_set | (flags & OSC_SUPPORT_MASKS); 232 support_set = root->osc_support_set | (flags & OSC_PCI_SUPPORT_MASKS);
281 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE; 233 capbuf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
282 capbuf[OSC_SUPPORT_TYPE] = support_set; 234 capbuf[OSC_SUPPORT_TYPE] = support_set;
283 capbuf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS; 235 capbuf[OSC_CONTROL_TYPE] = OSC_PCI_CONTROL_MASKS;
284 236
285 status = acpi_pci_run_osc(root->device->handle, capbuf, &result); 237 status = acpi_pci_run_osc(root->device->handle, capbuf, &result);
286 if (ACPI_SUCCESS(status)) { 238 if (ACPI_SUCCESS(status)) {
@@ -427,7 +379,7 @@ acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 flags)
427 if (ACPI_FAILURE(status)) 379 if (ACPI_FAILURE(status))
428 return status; 380 return status;
429 381
430 control_req = (flags & OSC_CONTROL_MASKS); 382 control_req = (flags & OSC_PCI_CONTROL_MASKS);
431 if (!control_req) 383 if (!control_req)
432 return AE_TYPE; 384 return AE_TYPE;
433 385
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index cb4283f5a79d..41731236f9a1 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -353,7 +353,7 @@ static int acpi_processor_info_open_fs(struct inode *inode, struct file *file)
353 PDE(inode)->data); 353 PDE(inode)->data);
354} 354}
355 355
356static int acpi_processor_add_fs(struct acpi_device *device) 356static int __cpuinit acpi_processor_add_fs(struct acpi_device *device)
357{ 357{
358 struct proc_dir_entry *entry = NULL; 358 struct proc_dir_entry *entry = NULL;
359 359
@@ -722,7 +722,7 @@ static void acpi_processor_notify(struct acpi_device *device, u32 event)
722 switch (event) { 722 switch (event) {
723 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: 723 case ACPI_PROCESSOR_NOTIFY_PERFORMANCE:
724 saved = pr->performance_platform_limit; 724 saved = pr->performance_platform_limit;
725 acpi_processor_ppc_has_changed(pr); 725 acpi_processor_ppc_has_changed(pr, 1);
726 if (saved == pr->performance_platform_limit) 726 if (saved == pr->performance_platform_limit)
727 break; 727 break;
728 acpi_bus_generate_proc_event(device, event, 728 acpi_bus_generate_proc_event(device, event,
@@ -758,7 +758,7 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
758 struct acpi_processor *pr = per_cpu(processors, cpu); 758 struct acpi_processor *pr = per_cpu(processors, cpu);
759 759
760 if (action == CPU_ONLINE && pr) { 760 if (action == CPU_ONLINE && pr) {
761 acpi_processor_ppc_has_changed(pr); 761 acpi_processor_ppc_has_changed(pr, 0);
762 acpi_processor_cst_has_changed(pr); 762 acpi_processor_cst_has_changed(pr);
763 acpi_processor_tstate_has_changed(pr); 763 acpi_processor_tstate_has_changed(pr);
764 } 764 }
@@ -830,7 +830,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
830 arch_acpi_processor_cleanup_pdc(pr); 830 arch_acpi_processor_cleanup_pdc(pr);
831 831
832#ifdef CONFIG_CPU_FREQ 832#ifdef CONFIG_CPU_FREQ
833 acpi_processor_ppc_has_changed(pr); 833 acpi_processor_ppc_has_changed(pr, 0);
834#endif 834#endif
835 acpi_processor_get_throttling_info(pr); 835 acpi_processor_get_throttling_info(pr);
836 acpi_processor_get_limit_info(pr); 836 acpi_processor_get_limit_info(pr);
@@ -845,7 +845,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
845 goto err_power_exit; 845 goto err_power_exit;
846 } 846 }
847 847
848 dev_info(&device->dev, "registered as cooling_device%d\n", 848 dev_dbg(&device->dev, "registered as cooling_device%d\n",
849 pr->cdev->id); 849 pr->cdev->id);
850 850
851 result = sysfs_create_link(&device->dev.kobj, 851 result = sysfs_create_link(&device->dev.kobj,
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index bbd066e7f854..d1676b1754d9 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -164,7 +164,7 @@ static void lapic_timer_check_state(int state, struct acpi_processor *pr,
164 pr->power.timer_broadcast_on_state = state; 164 pr->power.timer_broadcast_on_state = state;
165} 165}
166 166
167static void lapic_timer_propagate_broadcast(void *arg) 167static void __lapic_timer_propagate_broadcast(void *arg)
168{ 168{
169 struct acpi_processor *pr = (struct acpi_processor *) arg; 169 struct acpi_processor *pr = (struct acpi_processor *) arg;
170 unsigned long reason; 170 unsigned long reason;
@@ -175,6 +175,12 @@ static void lapic_timer_propagate_broadcast(void *arg)
175 clockevents_notify(reason, &pr->id); 175 clockevents_notify(reason, &pr->id);
176} 176}
177 177
178static void lapic_timer_propagate_broadcast(struct acpi_processor *pr)
179{
180 smp_call_function_single(pr->id, __lapic_timer_propagate_broadcast,
181 (void *)pr, 1);
182}
183
178/* Power(C) State timer broadcast control */ 184/* Power(C) State timer broadcast control */
179static void lapic_timer_state_broadcast(struct acpi_processor *pr, 185static void lapic_timer_state_broadcast(struct acpi_processor *pr,
180 struct acpi_processor_cx *cx, 186 struct acpi_processor_cx *cx,
@@ -638,8 +644,7 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
638 working++; 644 working++;
639 } 645 }
640 646
641 smp_call_function_single(pr->id, lapic_timer_propagate_broadcast, 647 lapic_timer_propagate_broadcast(pr);
642 pr, 1);
643 648
644 return (working); 649 return (working);
645} 650}
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c
index 01e366d2b6fb..2cabadcc4d8c 100644
--- a/drivers/acpi/processor_perflib.c
+++ b/drivers/acpi/processor_perflib.c
@@ -152,15 +152,59 @@ static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
152 return 0; 152 return 0;
153} 153}
154 154
155int acpi_processor_ppc_has_changed(struct acpi_processor *pr) 155#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
156/*
157 * acpi_processor_ppc_ost: Notify firmware the _PPC evaluation status
158 * @handle: ACPI processor handle
159 * @status: the status code of _PPC evaluation
160 * 0: success. OSPM is now using the performance state specificed.
161 * 1: failure. OSPM has not changed the number of P-states in use
162 */
163static void acpi_processor_ppc_ost(acpi_handle handle, int status)
164{
165 union acpi_object params[2] = {
166 {.type = ACPI_TYPE_INTEGER,},
167 {.type = ACPI_TYPE_INTEGER,},
168 };
169 struct acpi_object_list arg_list = {2, params};
170 acpi_handle temp;
171
172 params[0].integer.value = ACPI_PROCESSOR_NOTIFY_PERFORMANCE;
173 params[1].integer.value = status;
174
175 /* when there is no _OST , skip it */
176 if (ACPI_FAILURE(acpi_get_handle(handle, "_OST", &temp)))
177 return;
178
179 acpi_evaluate_object(handle, "_OST", &arg_list, NULL);
180 return;
181}
182
183int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag)
156{ 184{
157 int ret; 185 int ret;
158 186
159 if (ignore_ppc) 187 if (ignore_ppc) {
188 /*
189 * Only when it is notification event, the _OST object
190 * will be evaluated. Otherwise it is skipped.
191 */
192 if (event_flag)
193 acpi_processor_ppc_ost(pr->handle, 1);
160 return 0; 194 return 0;
195 }
161 196
162 ret = acpi_processor_get_platform_limit(pr); 197 ret = acpi_processor_get_platform_limit(pr);
163 198 /*
199 * Only when it is notification event, the _OST object
200 * will be evaluated. Otherwise it is skipped.
201 */
202 if (event_flag) {
203 if (ret < 0)
204 acpi_processor_ppc_ost(pr->handle, 1);
205 else
206 acpi_processor_ppc_ost(pr->handle, 0);
207 }
164 if (ret < 0) 208 if (ret < 0)
165 return (ret); 209 return (ret);
166 else 210 else
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 65f67815902a..9073ada88835 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -1052,6 +1052,13 @@ static int acpi_thermal_trip_seq_show(struct seq_file *seq, void *offset)
1052 acpi_device_bid(device)); 1052 acpi_device_bid(device));
1053 } 1053 }
1054 seq_puts(seq, "\n"); 1054 seq_puts(seq, "\n");
1055 } else {
1056 seq_printf(seq, "passive (forced):");
1057 if (tz->thermal_zone->forced_passive)
1058 seq_printf(seq, " %i C\n",
1059 tz->thermal_zone->forced_passive / 1000);
1060 else
1061 seq_printf(seq, "<not set>\n");
1055 } 1062 }
1056 1063
1057 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 1064 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {