aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2009-06-24 01:38:02 -0400
committerLen Brown <len.brown@intel.com>2009-08-27 10:17:20 -0400
commit0444e8f6d72d6e38f92d48884bc90bbc6c22fd5a (patch)
tree63f94d886d8e50c449dd8a6b46f3df3c326bf05a
parentcf02cd47d4747abf8ff0617e15fc05a00202e6d5 (diff)
ACPICA: Fix: Predefined object repair executed only once
This fixes a problem where the code that attempts to repair/convert an object of incorrect type is only executed on the first time the predefined method is called. The mechanism that disables warnings on subsequent calls was interfering with the repair mechanism. ACPICA BZ 781. http://acpica.org/bugzilla/show_bug.cgi?id=781 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/acpica/aclocal.h13
-rw-r--r--drivers/acpi/acpica/acmacros.h2
-rw-r--r--drivers/acpi/acpica/acutils.h6
-rw-r--r--drivers/acpi/acpica/nspredef.c369
-rw-r--r--drivers/acpi/acpica/utmisc.c57
5 files changed, 277 insertions, 170 deletions
diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
index ee986edfa0da..ff6689eba917 100644
--- a/drivers/acpi/acpica/aclocal.h
+++ b/drivers/acpi/acpica/aclocal.h
@@ -369,6 +369,19 @@ union acpi_predefined_info {
369 struct acpi_package_info3 ret_info3; 369 struct acpi_package_info3 ret_info3;
370}; 370};
371 371
372/* Data block used during object validation */
373
374struct acpi_predefined_data {
375 char *pathname;
376 const union acpi_predefined_info *predefined;
377 u32 flags;
378 u8 node_flags;
379};
380
381/* Defines for Flags field above */
382
383#define ACPI_OBJECT_REPAIRED 1
384
372/* 385/*
373 * Bitmapped return value types 386 * Bitmapped return value types
374 * Note: the actual data types must be contiguous, a loop in nspredef.c 387 * Note: the actual data types must be contiguous, a loop in nspredef.c
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h
index 91ac7d7b4402..3acd9c6760ea 100644
--- a/drivers/acpi/acpica/acmacros.h
+++ b/drivers/acpi/acpica/acmacros.h
@@ -340,6 +340,7 @@
340 */ 340 */
341#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e); 341#define ACPI_ERROR_NAMESPACE(s, e) acpi_ns_report_error (AE_INFO, s, e);
342#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e); 342#define ACPI_ERROR_METHOD(s, n, p, e) acpi_ns_report_method_error (AE_INFO, s, n, p, e);
343#define ACPI_WARN_PREDEFINED(plist) acpi_ut_predefined_warning plist
343 344
344#else 345#else
345 346
@@ -347,6 +348,7 @@
347 348
348#define ACPI_ERROR_NAMESPACE(s, e) 349#define ACPI_ERROR_NAMESPACE(s, e)
349#define ACPI_ERROR_METHOD(s, n, p, e) 350#define ACPI_ERROR_METHOD(s, n, p, e)
351#define ACPI_WARN_PREDEFINED(plist)
350#endif /* ACPI_NO_ERROR_MESSAGES */ 352#endif /* ACPI_NO_ERROR_MESSAGES */
351 353
352/* 354/*
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index b0add85de308..863a264b829e 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -475,6 +475,12 @@ u8 acpi_ut_valid_acpi_char(char character, u32 position);
475acpi_status 475acpi_status
476acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer); 476acpi_ut_strtoul64(char *string, u32 base, acpi_integer * ret_integer);
477 477
478void ACPI_INTERNAL_VAR_XFACE
479acpi_ut_predefined_warning(const char *module_name,
480 u32 line_number,
481 char *pathname,
482 u8 node_flags, const char *format, ...);
483
478/* Values for Base above (16=Hex, 10=Decimal) */ 484/* Values for Base above (16=Hex, 10=Decimal) */
479 485
480#define ACPI_ANY_BASE 0 486#define ACPI_ANY_BASE 0
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index abbb855e1b9a..1dc1a4737aa9 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -72,31 +72,33 @@ ACPI_MODULE_NAME("nspredef")
72 ******************************************************************************/ 72 ******************************************************************************/
73/* Local prototypes */ 73/* Local prototypes */
74static acpi_status 74static acpi_status
75acpi_ns_check_package(char *pathname, 75acpi_ns_check_package(struct acpi_predefined_data *data,
76 union acpi_operand_object **return_object_ptr, 76 union acpi_operand_object **return_object_ptr);
77 const union acpi_predefined_info *predefined);
78 77
79static acpi_status 78static acpi_status
80acpi_ns_check_package_elements(char *pathname, 79acpi_ns_check_package_elements(struct acpi_predefined_data *data,
81 union acpi_operand_object **elements, 80 union acpi_operand_object **elements,
82 u8 type1, 81 u8 type1,
83 u32 count1, 82 u32 count1,
84 u8 type2, u32 count2, u32 start_index); 83 u8 type2, u32 count2, u32 start_index);
85 84
86static acpi_status 85static acpi_status
87acpi_ns_check_object_type(char *pathname, 86acpi_ns_check_object_type(struct acpi_predefined_data *data,
88 union acpi_operand_object **return_object_ptr, 87 union acpi_operand_object **return_object_ptr,
89 u32 expected_btypes, u32 package_index); 88 u32 expected_btypes, u32 package_index);
90 89
91static acpi_status 90static acpi_status
92acpi_ns_check_reference(char *pathname, 91acpi_ns_check_reference(struct acpi_predefined_data *data,
93 union acpi_operand_object *return_object); 92 union acpi_operand_object *return_object);
94 93
95static acpi_status 94static acpi_status
96acpi_ns_repair_object(u32 expected_btypes, 95acpi_ns_repair_object(struct acpi_predefined_data *data,
96 u32 expected_btypes,
97 u32 package_index, 97 u32 package_index,
98 union acpi_operand_object **return_object_ptr); 98 union acpi_operand_object **return_object_ptr);
99 99
100static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes);
101
100/* 102/*
101 * Names for the types that can be returned by the predefined objects. 103 * Names for the types that can be returned by the predefined objects.
102 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs 104 * Used for warning messages. Must be in the same order as the ACPI_RTYPEs
@@ -109,13 +111,21 @@ static const char *acpi_rtype_names[] = {
109 "/Reference", 111 "/Reference",
110}; 112};
111 113
112#define ACPI_NOT_PACKAGE ACPI_UINT32_MAX 114/* Object is not a package element */
115
116#define ACPI_NOT_PACKAGE_ELEMENT ACPI_UINT32_MAX
117
118/* Always emit warning message, not dependent on node flags */
119
120#define ACPI_WARN_ALWAYS 0
113 121
114/******************************************************************************* 122/*******************************************************************************
115 * 123 *
116 * FUNCTION: acpi_ns_check_predefined_names 124 * FUNCTION: acpi_ns_check_predefined_names
117 * 125 *
118 * PARAMETERS: Node - Namespace node for the method/object 126 * PARAMETERS: Node - Namespace node for the method/object
127 * user_param_count - Number of parameters actually passed
128 * return_status - Status from the object evaluation
119 * return_object_ptr - Pointer to the object returned from the 129 * return_object_ptr - Pointer to the object returned from the
120 * evaluation of a method or object 130 * evaluation of a method or object
121 * 131 *
@@ -135,12 +145,13 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
135 acpi_status status = AE_OK; 145 acpi_status status = AE_OK;
136 const union acpi_predefined_info *predefined; 146 const union acpi_predefined_info *predefined;
137 char *pathname; 147 char *pathname;
148 struct acpi_predefined_data *data;
138 149
139 /* Match the name for this method/object against the predefined list */ 150 /* Match the name for this method/object against the predefined list */
140 151
141 predefined = acpi_ns_check_for_predefined_name(node); 152 predefined = acpi_ns_check_for_predefined_name(node);
142 153
143 /* Get the full pathname to the object, for use in error messages */ 154 /* Get the full pathname to the object, for use in warning messages */
144 155
145 pathname = acpi_ns_get_external_pathname(node); 156 pathname = acpi_ns_get_external_pathname(node);
146 if (!pathname) { 157 if (!pathname) {
@@ -158,28 +169,17 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
158 /* If not a predefined name, we cannot validate the return object */ 169 /* If not a predefined name, we cannot validate the return object */
159 170
160 if (!predefined) { 171 if (!predefined) {
161 goto exit; 172 goto cleanup;
162 }
163
164 /* If the method failed, we cannot validate the return object */
165
166 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
167 goto exit;
168 } 173 }
169 174
170 /* 175 /*
171 * Only validate the return value on the first successful evaluation of 176 * If the method failed or did not actually return an object, we cannot
172 * the method. This ensures that any warnings will only be emitted during 177 * validate the return object
173 * the very first evaluation of the method/object.
174 */ 178 */
175 if (node->flags & ANOBJ_EVALUATED) { 179 if ((return_status != AE_OK) && (return_status != AE_CTRL_RETURN_VALUE)) {
176 goto exit; 180 goto cleanup;
177 } 181 }
178 182
179 /* Mark the node as having been successfully evaluated */
180
181 node->flags |= ANOBJ_EVALUATED;
182
183 /* 183 /*
184 * If there is no return value, check if we require a return value for 184 * If there is no return value, check if we require a return value for
185 * this predefined name. Either one return value is expected, or none, 185 * this predefined name. Either one return value is expected, or none,
@@ -190,46 +190,63 @@ acpi_ns_check_predefined_names(struct acpi_namespace_node *node,
190 if (!return_object) { 190 if (!return_object) {
191 if ((predefined->info.expected_btypes) && 191 if ((predefined->info.expected_btypes) &&
192 (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) { 192 (!(predefined->info.expected_btypes & ACPI_RTYPE_NONE))) {
193 ACPI_ERROR((AE_INFO, 193 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
194 "%s: Missing expected return value", 194 ACPI_WARN_ALWAYS,
195 pathname)); 195 "Missing expected return value"));
196 196
197 status = AE_AML_NO_RETURN_VALUE; 197 status = AE_AML_NO_RETURN_VALUE;
198 } 198 }
199 goto exit; 199 goto cleanup;
200 } 200 }
201 201
202 /* 202 /*
203 * We have a return value, but if one wasn't expected, just exit, this is 203 * We have a return value, but if one wasn't expected, just exit, this is
204 * not a problem 204 * not a problem. For example, if the "Implicit Return" feature is
205 * 205 * enabled, methods will always return a value.
206 * For example, if the "Implicit Return" feature is enabled, methods will
207 * always return a value
208 */ 206 */
209 if (!predefined->info.expected_btypes) { 207 if (!predefined->info.expected_btypes) {
210 goto exit; 208 goto cleanup;
209 }
210
211 /* Create the parameter data block for object validation */
212
213 data = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_predefined_data));
214 if (!data) {
215 goto cleanup;
211 } 216 }
217 data->predefined = predefined;
218 data->node_flags = node->flags;
219 data->pathname = pathname;
212 220
213 /* 221 /*
214 * Check that the type of the return object is what is expected for 222 * Check that the type of the return object is what is expected for
215 * this predefined name 223 * this predefined name
216 */ 224 */
217 status = acpi_ns_check_object_type(pathname, return_object_ptr, 225 status = acpi_ns_check_object_type(data, return_object_ptr,
218 predefined->info.expected_btypes, 226 predefined->info.expected_btypes,
219 ACPI_NOT_PACKAGE); 227 ACPI_NOT_PACKAGE_ELEMENT);
220 if (ACPI_FAILURE(status)) { 228 if (ACPI_FAILURE(status)) {
221 goto exit; 229 goto check_validation_status;
222 } 230 }
223 231
224 /* For returned Package objects, check the type of all sub-objects */ 232 /* For returned Package objects, check the type of all sub-objects */
225 233
226 if (return_object->common.type == ACPI_TYPE_PACKAGE) { 234 if (return_object->common.type == ACPI_TYPE_PACKAGE) {
227 status = 235 status = acpi_ns_check_package(data, return_object_ptr);
228 acpi_ns_check_package(pathname, return_object_ptr,
229 predefined);
230 } 236 }
231 237
232 exit: 238check_validation_status:
239 /*
240 * If the object validation failed or if we successfully repaired one
241 * or more objects, mark the parent node to suppress further warning
242 * messages during the next evaluation of the same method/object.
243 */
244 if (ACPI_FAILURE(status) || (data->flags & ACPI_OBJECT_REPAIRED)) {
245 node->flags |= ANOBJ_EVALUATED;
246 }
247 ACPI_FREE(data);
248
249cleanup:
233 ACPI_FREE(pathname); 250 ACPI_FREE(pathname);
234 return (status); 251 return (status);
235} 252}
@@ -268,64 +285,58 @@ acpi_ns_check_parameter_count(char *pathname,
268 param_count = node->object->method.param_count; 285 param_count = node->object->method.param_count;
269 } 286 }
270 287
271 /* Argument count check for non-predefined methods/objects */
272
273 if (!predefined) { 288 if (!predefined) {
274 /* 289 /*
290 * Check the parameter count for non-predefined methods/objects.
291 *
275 * Warning if too few or too many arguments have been passed by the 292 * Warning if too few or too many arguments have been passed by the
276 * caller. An incorrect number of arguments may not cause the method 293 * caller. An incorrect number of arguments may not cause the method
277 * to fail. However, the method will fail if there are too few 294 * to fail. However, the method will fail if there are too few
278 * arguments and the method attempts to use one of the missing ones. 295 * arguments and the method attempts to use one of the missing ones.
279 */ 296 */
280 if (user_param_count < param_count) { 297 if (user_param_count < param_count) {
281 ACPI_WARNING((AE_INFO, 298 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
282 "%s: Insufficient arguments - needs %d, found %d", 299 ACPI_WARN_ALWAYS,
283 pathname, param_count, user_param_count)); 300 "Insufficient arguments - needs %u, found %u",
301 param_count, user_param_count));
284 } else if (user_param_count > param_count) { 302 } else if (user_param_count > param_count) {
285 ACPI_WARNING((AE_INFO, 303 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
286 "%s: Excess arguments - needs %d, found %d", 304 ACPI_WARN_ALWAYS,
287 pathname, param_count, user_param_count)); 305 "Excess arguments - needs %u, found %u",
306 param_count, user_param_count));
288 } 307 }
289 return; 308 return;
290 } 309 }
291 310
292 /* Allow two different legal argument counts (_SCP, etc.) */ 311 /*
293 312 * Validate the user-supplied parameter count.
313 * Allow two different legal argument counts (_SCP, etc.)
314 */
294 required_params_current = predefined->info.param_count & 0x0F; 315 required_params_current = predefined->info.param_count & 0x0F;
295 required_params_old = predefined->info.param_count >> 4; 316 required_params_old = predefined->info.param_count >> 4;
296 317
297 if (user_param_count != ACPI_UINT32_MAX) { 318 if (user_param_count != ACPI_UINT32_MAX) {
298
299 /* Validate the user-supplied parameter count */
300
301 if ((user_param_count != required_params_current) && 319 if ((user_param_count != required_params_current) &&
302 (user_param_count != required_params_old)) { 320 (user_param_count != required_params_old)) {
303 ACPI_WARNING((AE_INFO, 321 ACPI_WARN_PREDEFINED((AE_INFO, pathname,
304 "%s: Parameter count mismatch - " 322 ACPI_WARN_ALWAYS,
305 "caller passed %d, ACPI requires %d", 323 "Parameter count mismatch - "
306 pathname, user_param_count, 324 "caller passed %u, ACPI requires %u",
307 required_params_current)); 325 user_param_count,
326 required_params_current));
308 } 327 }
309 } 328 }
310 329
311 /* 330 /*
312 * Only validate the argument count on the first successful evaluation of
313 * the method. This ensures that any warnings will only be emitted during
314 * the very first evaluation of the method/object.
315 */
316 if (node->flags & ANOBJ_EVALUATED) {
317 return;
318 }
319
320 /*
321 * Check that the ASL-defined parameter count is what is expected for 331 * Check that the ASL-defined parameter count is what is expected for
322 * this predefined name. 332 * this predefined name (parameter count as defined by the ACPI
333 * specification)
323 */ 334 */
324 if ((param_count != required_params_current) && 335 if ((param_count != required_params_current) &&
325 (param_count != required_params_old)) { 336 (param_count != required_params_old)) {
326 ACPI_WARNING((AE_INFO, 337 ACPI_WARN_PREDEFINED((AE_INFO, pathname, node->flags,
327 "%s: Parameter count mismatch - ASL declared %d, ACPI requires %d", 338 "Parameter count mismatch - ASL declared %u, ACPI requires %u",
328 pathname, param_count, required_params_current)); 339 param_count, required_params_current));
329 } 340 }
330} 341}
331 342
@@ -358,9 +369,6 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
358 this_name = predefined_names; 369 this_name = predefined_names;
359 while (this_name->info.name[0]) { 370 while (this_name->info.name[0]) {
360 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) { 371 if (ACPI_COMPARE_NAME(node->name.ascii, this_name->info.name)) {
361
362 /* Return pointer to this table entry */
363
364 return (this_name); 372 return (this_name);
365 } 373 }
366 374
@@ -375,17 +383,16 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
375 this_name++; 383 this_name++;
376 } 384 }
377 385
378 return (NULL); 386 return (NULL); /* Not found */
379} 387}
380 388
381/******************************************************************************* 389/*******************************************************************************
382 * 390 *
383 * FUNCTION: acpi_ns_check_package 391 * FUNCTION: acpi_ns_check_package
384 * 392 *
385 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 393 * PARAMETERS: Data - Pointer to validation data structure
386 * return_object_ptr - Pointer to the object returned from the 394 * return_object_ptr - Pointer to the object returned from the
387 * evaluation of a method or object 395 * evaluation of a method or object
388 * Predefined - Pointer to entry in predefined name table
389 * 396 *
390 * RETURN: Status 397 * RETURN: Status
391 * 398 *
@@ -395,9 +402,8 @@ const union acpi_predefined_info *acpi_ns_check_for_predefined_name(struct
395 ******************************************************************************/ 402 ******************************************************************************/
396 403
397static acpi_status 404static acpi_status
398acpi_ns_check_package(char *pathname, 405acpi_ns_check_package(struct acpi_predefined_data *data,
399 union acpi_operand_object **return_object_ptr, 406 union acpi_operand_object **return_object_ptr)
400 const union acpi_predefined_info *predefined)
401{ 407{
402 union acpi_operand_object *return_object = *return_object_ptr; 408 union acpi_operand_object *return_object = *return_object_ptr;
403 const union acpi_predefined_info *package; 409 const union acpi_predefined_info *package;
@@ -414,11 +420,11 @@ acpi_ns_check_package(char *pathname,
414 420
415 /* The package info for this name is in the next table entry */ 421 /* The package info for this name is in the next table entry */
416 422
417 package = predefined + 1; 423 package = data->predefined + 1;
418 424
419 ACPI_DEBUG_PRINT((ACPI_DB_NAMES, 425 ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
420 "%s Validating return Package of Type %X, Count %X\n", 426 "%s Validating return Package of Type %X, Count %X\n",
421 pathname, package->ret_info.type, 427 data->pathname, package->ret_info.type,
422 return_object->package.count)); 428 return_object->package.count));
423 429
424 /* Extract package count and elements array */ 430 /* Extract package count and elements array */
@@ -429,9 +435,8 @@ acpi_ns_check_package(char *pathname,
429 /* The package must have at least one element, else invalid */ 435 /* The package must have at least one element, else invalid */
430 436
431 if (!count) { 437 if (!count) {
432 ACPI_WARNING((AE_INFO, 438 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
433 "%s: Return Package has no elements (empty)", 439 "Return Package has no elements (empty)"));
434 pathname));
435 440
436 return (AE_AML_OPERAND_VALUE); 441 return (AE_AML_OPERAND_VALUE);
437 } 442 }
@@ -456,15 +461,16 @@ acpi_ns_check_package(char *pathname,
456 if (count < expected_count) { 461 if (count < expected_count) {
457 goto package_too_small; 462 goto package_too_small;
458 } else if (count > expected_count) { 463 } else if (count > expected_count) {
459 ACPI_WARNING((AE_INFO, 464 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
460 "%s: Return Package is larger than needed - " 465 data->node_flags,
461 "found %u, expected %u", pathname, count, 466 "Return Package is larger than needed - "
462 expected_count)); 467 "found %u, expected %u", count,
468 expected_count));
463 } 469 }
464 470
465 /* Validate all elements of the returned package */ 471 /* Validate all elements of the returned package */
466 472
467 status = acpi_ns_check_package_elements(pathname, elements, 473 status = acpi_ns_check_package_elements(data, elements,
468 package->ret_info. 474 package->ret_info.
469 object_type1, 475 object_type1,
470 package->ret_info. 476 package->ret_info.
@@ -485,7 +491,7 @@ acpi_ns_check_package(char *pathname,
485 * elements must be of the same type 491 * elements must be of the same type
486 */ 492 */
487 for (i = 0; i < count; i++) { 493 for (i = 0; i < count; i++) {
488 status = acpi_ns_check_object_type(pathname, elements, 494 status = acpi_ns_check_object_type(data, elements,
489 package->ret_info. 495 package->ret_info.
490 object_type1, i); 496 object_type1, i);
491 if (ACPI_FAILURE(status)) { 497 if (ACPI_FAILURE(status)) {
@@ -517,8 +523,7 @@ acpi_ns_check_package(char *pathname,
517 /* These are the required package elements (0, 1, or 2) */ 523 /* These are the required package elements (0, 1, or 2) */
518 524
519 status = 525 status =
520 acpi_ns_check_object_type(pathname, 526 acpi_ns_check_object_type(data, elements,
521 elements,
522 package-> 527 package->
523 ret_info3. 528 ret_info3.
524 object_type[i], 529 object_type[i],
@@ -530,8 +535,7 @@ acpi_ns_check_package(char *pathname,
530 /* These are the optional package elements */ 535 /* These are the optional package elements */
531 536
532 status = 537 status =
533 acpi_ns_check_object_type(pathname, 538 acpi_ns_check_object_type(data, elements,
534 elements,
535 package-> 539 package->
536 ret_info3. 540 ret_info3.
537 tail_object_type, 541 tail_object_type,
@@ -548,7 +552,7 @@ acpi_ns_check_package(char *pathname,
548 552
549 /* First element is the (Integer) count of sub-packages to follow */ 553 /* First element is the (Integer) count of sub-packages to follow */
550 554
551 status = acpi_ns_check_object_type(pathname, elements, 555 status = acpi_ns_check_object_type(data, elements,
552 ACPI_RTYPE_INTEGER, 0); 556 ACPI_RTYPE_INTEGER, 0);
553 if (ACPI_FAILURE(status)) { 557 if (ACPI_FAILURE(status)) {
554 return (status); 558 return (status);
@@ -585,9 +589,9 @@ acpi_ns_check_package(char *pathname,
585 589
586 /* Each sub-object must be of type Package */ 590 /* Each sub-object must be of type Package */
587 591
588 status = 592 status = acpi_ns_check_object_type(data, &sub_package,
589 acpi_ns_check_object_type(pathname, &sub_package, 593 ACPI_RTYPE_PACKAGE,
590 ACPI_RTYPE_PACKAGE, i); 594 i);
591 if (ACPI_FAILURE(status)) { 595 if (ACPI_FAILURE(status)) {
592 return (status); 596 return (status);
593 } 597 }
@@ -610,7 +614,7 @@ acpi_ns_check_package(char *pathname,
610 } 614 }
611 615
612 status = 616 status =
613 acpi_ns_check_package_elements(pathname, 617 acpi_ns_check_package_elements(data,
614 sub_elements, 618 sub_elements,
615 package-> 619 package->
616 ret_info. 620 ret_info.
@@ -643,7 +647,7 @@ acpi_ns_check_package(char *pathname,
643 647
644 for (j = 0; j < expected_count; j++) { 648 for (j = 0; j < expected_count; j++) {
645 status = 649 status =
646 acpi_ns_check_object_type(pathname, 650 acpi_ns_check_object_type(data,
647 &sub_elements[j], 651 &sub_elements[j],
648 package->ret_info2.object_type[j], j); 652 package->ret_info2.object_type[j], j);
649 if (ACPI_FAILURE(status)) { 653 if (ACPI_FAILURE(status)) {
@@ -665,7 +669,7 @@ acpi_ns_check_package(char *pathname,
665 /* Check the type of each sub-package element */ 669 /* Check the type of each sub-package element */
666 670
667 status = 671 status =
668 acpi_ns_check_package_elements(pathname, 672 acpi_ns_check_package_elements(data,
669 sub_elements, 673 sub_elements,
670 package-> 674 package->
671 ret_info. 675 ret_info.
@@ -684,7 +688,7 @@ acpi_ns_check_package(char *pathname,
684 /* First element is the (Integer) count of elements to follow */ 688 /* First element is the (Integer) count of elements to follow */
685 689
686 status = 690 status =
687 acpi_ns_check_object_type(pathname, 691 acpi_ns_check_object_type(data,
688 sub_elements, 692 sub_elements,
689 ACPI_RTYPE_INTEGER, 693 ACPI_RTYPE_INTEGER,
690 0); 694 0);
@@ -704,7 +708,7 @@ acpi_ns_check_package(char *pathname,
704 /* Check the type of each sub-package element */ 708 /* Check the type of each sub-package element */
705 709
706 status = 710 status =
707 acpi_ns_check_package_elements(pathname, 711 acpi_ns_check_package_elements(data,
708 (sub_elements 712 (sub_elements
709 + 1), 713 + 1),
710 package-> 714 package->
@@ -730,9 +734,9 @@ acpi_ns_check_package(char *pathname,
730 734
731 /* Should not get here if predefined info table is correct */ 735 /* Should not get here if predefined info table is correct */
732 736
733 ACPI_WARNING((AE_INFO, 737 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
734 "%s: Invalid internal return type in table entry: %X", 738 "Invalid internal return type in table entry: %X",
735 pathname, package->ret_info.type)); 739 package->ret_info.type));
736 740
737 return (AE_AML_INTERNAL); 741 return (AE_AML_INTERNAL);
738 } 742 }
@@ -743,9 +747,9 @@ acpi_ns_check_package(char *pathname,
743 747
744 /* Error exit for the case with an incorrect package count */ 748 /* Error exit for the case with an incorrect package count */
745 749
746 ACPI_WARNING((AE_INFO, "%s: Return Package is too small - " 750 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
747 "found %u, expected %u", pathname, count, 751 "Return Package is too small - found %u, expected %u",
748 expected_count)); 752 count, expected_count));
749 753
750 return (AE_AML_OPERAND_VALUE); 754 return (AE_AML_OPERAND_VALUE);
751} 755}
@@ -754,7 +758,7 @@ acpi_ns_check_package(char *pathname,
754 * 758 *
755 * FUNCTION: acpi_ns_check_package_elements 759 * FUNCTION: acpi_ns_check_package_elements
756 * 760 *
757 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 761 * PARAMETERS: Data - Pointer to validation data structure
758 * Elements - Pointer to the package elements array 762 * Elements - Pointer to the package elements array
759 * Type1 - Object type for first group 763 * Type1 - Object type for first group
760 * Count1 - Count for first group 764 * Count1 - Count for first group
@@ -770,7 +774,7 @@ acpi_ns_check_package(char *pathname,
770 ******************************************************************************/ 774 ******************************************************************************/
771 775
772static acpi_status 776static acpi_status
773acpi_ns_check_package_elements(char *pathname, 777acpi_ns_check_package_elements(struct acpi_predefined_data *data,
774 union acpi_operand_object **elements, 778 union acpi_operand_object **elements,
775 u8 type1, 779 u8 type1,
776 u32 count1, 780 u32 count1,
@@ -786,7 +790,7 @@ acpi_ns_check_package_elements(char *pathname,
786 * The second group can have a count of zero. 790 * The second group can have a count of zero.
787 */ 791 */
788 for (i = 0; i < count1; i++) { 792 for (i = 0; i < count1; i++) {
789 status = acpi_ns_check_object_type(pathname, this_element, 793 status = acpi_ns_check_object_type(data, this_element,
790 type1, i + start_index); 794 type1, i + start_index);
791 if (ACPI_FAILURE(status)) { 795 if (ACPI_FAILURE(status)) {
792 return (status); 796 return (status);
@@ -795,7 +799,7 @@ acpi_ns_check_package_elements(char *pathname,
795 } 799 }
796 800
797 for (i = 0; i < count2; i++) { 801 for (i = 0; i < count2; i++) {
798 status = acpi_ns_check_object_type(pathname, this_element, 802 status = acpi_ns_check_object_type(data, this_element,
799 type2, 803 type2,
800 (i + count1 + start_index)); 804 (i + count1 + start_index));
801 if (ACPI_FAILURE(status)) { 805 if (ACPI_FAILURE(status)) {
@@ -811,12 +815,13 @@ acpi_ns_check_package_elements(char *pathname,
811 * 815 *
812 * FUNCTION: acpi_ns_check_object_type 816 * FUNCTION: acpi_ns_check_object_type
813 * 817 *
814 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 818 * PARAMETERS: Data - Pointer to validation data structure
815 * return_object_ptr - Pointer to the object returned from the 819 * return_object_ptr - Pointer to the object returned from the
816 * evaluation of a method or object 820 * evaluation of a method or object
817 * expected_btypes - Bitmap of expected return type(s) 821 * expected_btypes - Bitmap of expected return type(s)
818 * package_index - Index of object within parent package (if 822 * package_index - Index of object within parent package (if
819 * applicable - ACPI_NOT_PACKAGE otherwise) 823 * applicable - ACPI_NOT_PACKAGE_ELEMENT
824 * otherwise)
820 * 825 *
821 * RETURN: Status 826 * RETURN: Status
822 * 827 *
@@ -826,7 +831,7 @@ acpi_ns_check_package_elements(char *pathname,
826 ******************************************************************************/ 831 ******************************************************************************/
827 832
828static acpi_status 833static acpi_status
829acpi_ns_check_object_type(char *pathname, 834acpi_ns_check_object_type(struct acpi_predefined_data *data,
830 union acpi_operand_object **return_object_ptr, 835 union acpi_operand_object **return_object_ptr,
831 u32 expected_btypes, u32 package_index) 836 u32 expected_btypes, u32 package_index)
832{ 837{
@@ -834,9 +839,6 @@ acpi_ns_check_object_type(char *pathname,
834 acpi_status status = AE_OK; 839 acpi_status status = AE_OK;
835 u32 return_btype; 840 u32 return_btype;
836 char type_buffer[48]; /* Room for 5 types */ 841 char type_buffer[48]; /* Room for 5 types */
837 u32 this_rtype;
838 u32 i;
839 u32 j;
840 842
841 /* 843 /*
842 * If we get a NULL return_object here, it is a NULL package element, 844 * If we get a NULL return_object here, it is a NULL package element,
@@ -849,10 +851,11 @@ acpi_ns_check_object_type(char *pathname,
849 /* A Namespace node should not get here, but make sure */ 851 /* A Namespace node should not get here, but make sure */
850 852
851 if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) { 853 if (ACPI_GET_DESCRIPTOR_TYPE(return_object) == ACPI_DESC_TYPE_NAMED) {
852 ACPI_WARNING((AE_INFO, 854 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
853 "%s: Invalid return type - Found a Namespace node [%4.4s] type %s", 855 "Invalid return type - Found a Namespace node [%4.4s] type %s",
854 pathname, return_object->node.name.ascii, 856 return_object->node.name.ascii,
855 acpi_ut_get_type_name(return_object->node.type))); 857 acpi_ut_get_type_name(return_object->node.
858 type)));
856 return (AE_AML_OPERAND_TYPE); 859 return (AE_AML_OPERAND_TYPE);
857 } 860 }
858 861
@@ -897,10 +900,11 @@ acpi_ns_check_object_type(char *pathname,
897 900
898 /* Type mismatch -- attempt repair of the returned object */ 901 /* Type mismatch -- attempt repair of the returned object */
899 902
900 status = acpi_ns_repair_object(expected_btypes, package_index, 903 status = acpi_ns_repair_object(data, expected_btypes,
904 package_index,
901 return_object_ptr); 905 return_object_ptr);
902 if (ACPI_SUCCESS(status)) { 906 if (ACPI_SUCCESS(status)) {
903 return (status); 907 return (AE_OK); /* Repair was successful */
904 } 908 }
905 goto type_error_exit; 909 goto type_error_exit;
906 } 910 }
@@ -908,7 +912,7 @@ acpi_ns_check_object_type(char *pathname,
908 /* For reference objects, check that the reference type is correct */ 912 /* For reference objects, check that the reference type is correct */
909 913
910 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) { 914 if (return_object->common.type == ACPI_TYPE_LOCAL_REFERENCE) {
911 status = acpi_ns_check_reference(pathname, return_object); 915 status = acpi_ns_check_reference(data, return_object);
912 } 916 }
913 917
914 return (status); 918 return (status);
@@ -917,33 +921,19 @@ acpi_ns_check_object_type(char *pathname,
917 921
918 /* Create a string with all expected types for this predefined object */ 922 /* Create a string with all expected types for this predefined object */
919 923
920 j = 1; 924 acpi_ns_get_expected_types(type_buffer, expected_btypes);
921 type_buffer[0] = 0;
922 this_rtype = ACPI_RTYPE_INTEGER;
923
924 for (i = 0; i < ACPI_NUM_RTYPES; i++) {
925
926 /* If one of the expected types, concatenate the name of this type */
927
928 if (expected_btypes & this_rtype) {
929 ACPI_STRCAT(type_buffer, &acpi_rtype_names[i][j]);
930 j = 0; /* Use name separator from now on */
931 }
932 this_rtype <<= 1; /* Next Rtype */
933 }
934 925
935 if (package_index == ACPI_NOT_PACKAGE) { 926 if (package_index == ACPI_NOT_PACKAGE_ELEMENT) {
936 ACPI_WARNING((AE_INFO, 927 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
937 "%s: Return type mismatch - found %s, expected %s", 928 "Return type mismatch - found %s, expected %s",
938 pathname, 929 acpi_ut_get_object_type_name
939 acpi_ut_get_object_type_name(return_object), 930 (return_object), type_buffer));
940 type_buffer));
941 } else { 931 } else {
942 ACPI_WARNING((AE_INFO, 932 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
943 "%s: Return Package type mismatch at index %u - " 933 "Return Package type mismatch at index %u - "
944 "found %s, expected %s", pathname, package_index, 934 "found %s, expected %s", package_index,
945 acpi_ut_get_object_type_name(return_object), 935 acpi_ut_get_object_type_name
946 type_buffer)); 936 (return_object), type_buffer));
947 } 937 }
948 938
949 return (AE_AML_OPERAND_TYPE); 939 return (AE_AML_OPERAND_TYPE);
@@ -953,7 +943,7 @@ acpi_ns_check_object_type(char *pathname,
953 * 943 *
954 * FUNCTION: acpi_ns_check_reference 944 * FUNCTION: acpi_ns_check_reference
955 * 945 *
956 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 946 * PARAMETERS: Data - Pointer to validation data structure
957 * return_object - Object returned from the evaluation of a 947 * return_object - Object returned from the evaluation of a
958 * method or object 948 * method or object
959 * 949 *
@@ -966,7 +956,7 @@ acpi_ns_check_object_type(char *pathname,
966 ******************************************************************************/ 956 ******************************************************************************/
967 957
968static acpi_status 958static acpi_status
969acpi_ns_check_reference(char *pathname, 959acpi_ns_check_reference(struct acpi_predefined_data *data,
970 union acpi_operand_object *return_object) 960 union acpi_operand_object *return_object)
971{ 961{
972 962
@@ -979,11 +969,10 @@ acpi_ns_check_reference(char *pathname,
979 return (AE_OK); 969 return (AE_OK);
980 } 970 }
981 971
982 ACPI_WARNING((AE_INFO, 972 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname, data->node_flags,
983 "%s: Return type mismatch - " 973 "Return type mismatch - unexpected reference object type [%s] %2.2X",
984 "unexpected reference object type [%s] %2.2X", 974 acpi_ut_get_reference_name(return_object),
985 pathname, acpi_ut_get_reference_name(return_object), 975 return_object->reference.class));
986 return_object->reference.class));
987 976
988 return (AE_AML_OPERAND_TYPE); 977 return (AE_AML_OPERAND_TYPE);
989} 978}
@@ -992,8 +981,11 @@ acpi_ns_check_reference(char *pathname,
992 * 981 *
993 * FUNCTION: acpi_ns_repair_object 982 * FUNCTION: acpi_ns_repair_object
994 * 983 *
995 * PARAMETERS: Pathname - Full pathname to the node (for error msgs) 984 * PARAMETERS: Data - Pointer to validation data structure
996 * package_index - Used to determine if target is in a package 985 * expected_btypes - Object types expected
986 * package_index - Index of object within parent package (if
987 * applicable - ACPI_NOT_PACKAGE_ELEMENT
988 * otherwise)
997 * return_object_ptr - Pointer to the object returned from the 989 * return_object_ptr - Pointer to the object returned from the
998 * evaluation of a method or object 990 * evaluation of a method or object
999 * 991 *
@@ -1005,7 +997,8 @@ acpi_ns_check_reference(char *pathname,
1005 ******************************************************************************/ 997 ******************************************************************************/
1006 998
1007static acpi_status 999static acpi_status
1008acpi_ns_repair_object(u32 expected_btypes, 1000acpi_ns_repair_object(struct acpi_predefined_data *data,
1001 u32 expected_btypes,
1009 u32 package_index, 1002 u32 package_index,
1010 union acpi_operand_object **return_object_ptr) 1003 union acpi_operand_object **return_object_ptr)
1011{ 1004{
@@ -1016,6 +1009,8 @@ acpi_ns_repair_object(u32 expected_btypes,
1016 switch (return_object->common.type) { 1009 switch (return_object->common.type) {
1017 case ACPI_TYPE_BUFFER: 1010 case ACPI_TYPE_BUFFER:
1018 1011
1012 /* Does the method/object legally return a string? */
1013
1019 if (!(expected_btypes & ACPI_RTYPE_STRING)) { 1014 if (!(expected_btypes & ACPI_RTYPE_STRING)) {
1020 return (AE_AML_OPERAND_TYPE); 1015 return (AE_AML_OPERAND_TYPE);
1021 } 1016 }
@@ -1052,19 +1047,29 @@ acpi_ns_repair_object(u32 expected_btypes,
1052 * reference count of the old object. 1047 * reference count of the old object.
1053 * 2. Decrement the reference count of the original object. 1048 * 2. Decrement the reference count of the original object.
1054 */ 1049 */
1055 if (package_index != ACPI_NOT_PACKAGE) { 1050 if (package_index != ACPI_NOT_PACKAGE_ELEMENT) {
1056 new_object->common.reference_count = 1051 new_object->common.reference_count =
1057 return_object->common.reference_count; 1052 return_object->common.reference_count;
1058 1053
1059 if (return_object->common.reference_count > 1) { 1054 if (return_object->common.reference_count > 1) {
1060 return_object->common.reference_count--; 1055 return_object->common.reference_count--;
1061 } 1056 }
1057
1058 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
1059 data->node_flags,
1060 "Converted Buffer to expected String at index %u",
1061 package_index));
1062 } else {
1063 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
1064 data->node_flags,
1065 "Converted Buffer to expected String"));
1062 } 1066 }
1063 1067
1064 /* Delete old object, install the new return object */ 1068 /* Delete old object, install the new return object */
1065 1069
1066 acpi_ut_remove_reference(return_object); 1070 acpi_ut_remove_reference(return_object);
1067 *return_object_ptr = new_object; 1071 *return_object_ptr = new_object;
1072 data->flags |= ACPI_OBJECT_REPAIRED;
1068 return (AE_OK); 1073 return (AE_OK);
1069 1074
1070 default: 1075 default:
@@ -1073,3 +1078,39 @@ acpi_ns_repair_object(u32 expected_btypes,
1073 1078
1074 return (AE_AML_OPERAND_TYPE); 1079 return (AE_AML_OPERAND_TYPE);
1075} 1080}
1081
1082/*******************************************************************************
1083 *
1084 * FUNCTION: acpi_ns_get_expected_types
1085 *
1086 * PARAMETERS: Buffer - Pointer to where the string is returned
1087 * expected_btypes - Bitmap of expected return type(s)
1088 *
1089 * RETURN: Buffer is populated with type names.
1090 *
1091 * DESCRIPTION: Translate the expected types bitmap into a string of ascii
1092 * names of expected types, for use in warning messages.
1093 *
1094 ******************************************************************************/
1095
1096static void acpi_ns_get_expected_types(char *buffer, u32 expected_btypes)
1097{
1098 u32 this_rtype;
1099 u32 i;
1100 u32 j;
1101
1102 j = 1;
1103 buffer[0] = 0;
1104 this_rtype = ACPI_RTYPE_INTEGER;
1105
1106 for (i = 0; i < ACPI_NUM_RTYPES; i++) {
1107
1108 /* If one of the expected types, concatenate the name of this type */
1109
1110 if (expected_btypes & this_rtype) {
1111 ACPI_STRCAT(buffer, &acpi_rtype_names[i][j]);
1112 j = 0; /* Use name separator from now on */
1113 }
1114 this_rtype <<= 1; /* Next Rtype */
1115 }
1116}
diff --git a/drivers/acpi/acpica/utmisc.c b/drivers/acpi/acpica/utmisc.c
index 9cd65334ca75..5bd29606dc61 100644
--- a/drivers/acpi/acpica/utmisc.c
+++ b/drivers/acpi/acpica/utmisc.c
@@ -50,6 +50,11 @@
50#define _COMPONENT ACPI_UTILITIES 50#define _COMPONENT ACPI_UTILITIES
51ACPI_MODULE_NAME("utmisc") 51ACPI_MODULE_NAME("utmisc")
52 52
53/*
54 * Common suffix for messages
55 */
56#define ACPI_COMMON_MSG_SUFFIX \
57 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, line_number)
53/******************************************************************************* 58/*******************************************************************************
54 * 59 *
55 * FUNCTION: acpi_ut_validate_exception 60 * FUNCTION: acpi_ut_validate_exception
@@ -1065,8 +1070,7 @@ acpi_error(const char *module_name, u32 line_number, const char *format, ...)
1065 1070
1066 va_start(args, format); 1071 va_start(args, format);
1067 acpi_os_vprintf(format, args); 1072 acpi_os_vprintf(format, args);
1068 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, 1073 ACPI_COMMON_MSG_SUFFIX;
1069 line_number);
1070 va_end(args); 1074 va_end(args);
1071} 1075}
1072 1076
@@ -1080,8 +1084,7 @@ acpi_exception(const char *module_name,
1080 1084
1081 va_start(args, format); 1085 va_start(args, format);
1082 acpi_os_vprintf(format, args); 1086 acpi_os_vprintf(format, args);
1083 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, 1087 ACPI_COMMON_MSG_SUFFIX;
1084 line_number);
1085 va_end(args); 1088 va_end(args);
1086} 1089}
1087 1090
@@ -1094,8 +1097,7 @@ acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
1094 1097
1095 va_start(args, format); 1098 va_start(args, format);
1096 acpi_os_vprintf(format, args); 1099 acpi_os_vprintf(format, args);
1097 acpi_os_printf(" %8.8X %s-%u\n", ACPI_CA_VERSION, module_name, 1100 ACPI_COMMON_MSG_SUFFIX;
1098 line_number);
1099 va_end(args); 1101 va_end(args);
1100} 1102}
1101 1103
@@ -1116,3 +1118,46 @@ ACPI_EXPORT_SYMBOL(acpi_error)
1116ACPI_EXPORT_SYMBOL(acpi_exception) 1118ACPI_EXPORT_SYMBOL(acpi_exception)
1117ACPI_EXPORT_SYMBOL(acpi_warning) 1119ACPI_EXPORT_SYMBOL(acpi_warning)
1118ACPI_EXPORT_SYMBOL(acpi_info) 1120ACPI_EXPORT_SYMBOL(acpi_info)
1121
1122/*******************************************************************************
1123 *
1124 * FUNCTION: acpi_ut_predefined_warning
1125 *
1126 * PARAMETERS: module_name - Caller's module name (for error output)
1127 * line_number - Caller's line number (for error output)
1128 * Pathname - Full pathname to the node
1129 * node_flags - From Namespace node for the method/object
1130 * Format - Printf format string + additional args
1131 *
1132 * RETURN: None
1133 *
1134 * DESCRIPTION: Warnings for the predefined validation module. Messages are
1135 * only emitted the first time a problem with a particular
1136 * method/object is detected. This prevents a flood of error
1137 * messages for methods that are repeatedly evaluated.
1138 *
1139******************************************************************************/
1140
1141void ACPI_INTERNAL_VAR_XFACE
1142acpi_ut_predefined_warning(const char *module_name,
1143 u32 line_number,
1144 char *pathname,
1145 u8 node_flags, const char *format, ...)
1146{
1147 va_list args;
1148
1149 /*
1150 * Warning messages for this method/object will be disabled after the
1151 * first time a validation fails or an object is successfully repaired.
1152 */
1153 if (node_flags & ANOBJ_EVALUATED) {
1154 return;
1155 }
1156
1157 acpi_os_printf("ACPI Warning for %s: ", pathname);
1158
1159 va_start(args, format);
1160 acpi_os_vprintf(format, args);
1161 ACPI_COMMON_MSG_SUFFIX;
1162 va_end(args);
1163}