diff options
-rw-r--r-- | drivers/acpi/acpica/acmacros.h | 132 | ||||
-rw-r--r-- | include/acpi/acoutput.h | 32 |
2 files changed, 96 insertions, 68 deletions
diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index edfcbc8909ca..cd96135c96b4 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h | |||
@@ -392,29 +392,51 @@ | |||
392 | * Debug macros that are conditionally compiled | 392 | * Debug macros that are conditionally compiled |
393 | */ | 393 | */ |
394 | #ifdef ACPI_DEBUG_OUTPUT | 394 | #ifdef ACPI_DEBUG_OUTPUT |
395 | |||
395 | /* | 396 | /* |
396 | * Function entry tracing | 397 | * Function entry tracing |
398 | * | ||
399 | * The name of the function is emitted as a local variable that is | ||
400 | * intended to be used by both the entry trace and the exit trace. | ||
397 | */ | 401 | */ |
398 | #define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ | ||
399 | acpi_ut_trace(ACPI_DEBUG_PARAMETERS) | ||
400 | #define ACPI_FUNCTION_TRACE_PTR(a, b) ACPI_FUNCTION_NAME(a) \ | ||
401 | acpi_ut_trace_ptr(ACPI_DEBUG_PARAMETERS, (void *)b) | ||
402 | #define ACPI_FUNCTION_TRACE_U32(a, b) ACPI_FUNCTION_NAME(a) \ | ||
403 | acpi_ut_trace_u32(ACPI_DEBUG_PARAMETERS, (u32)b) | ||
404 | #define ACPI_FUNCTION_TRACE_STR(a, b) ACPI_FUNCTION_NAME(a) \ | ||
405 | acpi_ut_trace_str(ACPI_DEBUG_PARAMETERS, (char *)b) | ||
406 | 402 | ||
407 | #define ACPI_FUNCTION_ENTRY() acpi_ut_track_stack_ptr() | 403 | /* Helper macro */ |
404 | |||
405 | #define ACPI_TRACE_ENTRY(name, function, cast, param) \ | ||
406 | ACPI_FUNCTION_NAME (name) \ | ||
407 | function (ACPI_DEBUG_PARAMETERS, cast (param)) | ||
408 | |||
409 | /* The actual entry trace macros */ | ||
410 | |||
411 | #define ACPI_FUNCTION_TRACE(name) \ | ||
412 | ACPI_FUNCTION_NAME(name) \ | ||
413 | acpi_ut_trace (ACPI_DEBUG_PARAMETERS) | ||
414 | |||
415 | #define ACPI_FUNCTION_TRACE_PTR(name, pointer) \ | ||
416 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_ptr, (void *), pointer) | ||
417 | |||
418 | #define ACPI_FUNCTION_TRACE_U32(name, value) \ | ||
419 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_u32, (u32), value) | ||
420 | |||
421 | #define ACPI_FUNCTION_TRACE_STR(name, string) \ | ||
422 | ACPI_TRACE_ENTRY (name, acpi_ut_trace_str, (char *), string) | ||
423 | |||
424 | #define ACPI_FUNCTION_ENTRY() \ | ||
425 | acpi_ut_track_stack_ptr() | ||
408 | 426 | ||
409 | /* | 427 | /* |
410 | * Function exit tracing. | 428 | * Function exit tracing |
411 | * WARNING: These macros include a return statement. This is usually considered | 429 | * |
412 | * bad form, but having a separate exit macro is very ugly and difficult to maintain. | 430 | * These macros include a return statement. This is usually considered |
413 | * One of the FUNCTION_TRACE macros above must be used in conjunction with these macros | 431 | * bad form, but having a separate exit macro before the actual return |
414 | * so that "_AcpiFunctionName" is defined. | 432 | * is very ugly and difficult to maintain. |
433 | * | ||
434 | * One of the FUNCTION_TRACE macros above must be used in conjunction | ||
435 | * with these macros so that "_AcpiFunctionName" is defined. | ||
415 | * | 436 | * |
416 | * Note: the DO_WHILE0 macro is used to prevent some compilers from complaining | 437 | * Note: the DO_WHILE0 macro is used to prevent some compilers from |
417 | * about these constructs. | 438 | * complaining about these constructs. On other compilers the do...while |
439 | * adds some extra code, so this feature is optional. | ||
418 | */ | 440 | */ |
419 | #ifdef ACPI_USE_DO_WHILE_0 | 441 | #ifdef ACPI_USE_DO_WHILE_0 |
420 | #define ACPI_DO_WHILE0(a) do a while(0) | 442 | #define ACPI_DO_WHILE0(a) do a while(0) |
@@ -422,55 +444,35 @@ | |||
422 | #define ACPI_DO_WHILE0(a) a | 444 | #define ACPI_DO_WHILE0(a) a |
423 | #endif | 445 | #endif |
424 | 446 | ||
425 | #define return_VOID ACPI_DO_WHILE0 ({ \ | 447 | /* Exit trace helper macro */ |
426 | acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \ | 448 | |
427 | return;}) | 449 | #define ACPI_TRACE_EXIT(function, cast, param) \ |
428 | /* | 450 | ACPI_DO_WHILE0 ({ \ |
429 | * There are two versions of most of the return macros. The default version is | 451 | function (ACPI_DEBUG_PARAMETERS, cast (param)); \ |
430 | * safer, since it avoids side-effects by guaranteeing that the argument will | 452 | return ((param)); \ |
431 | * not be evaluated twice. | 453 | }) |
432 | * | 454 | |
433 | * A less-safe version of the macros is provided for optional use if the | 455 | /* The actual exit macros */ |
434 | * compiler uses excessive CPU stack (for example, this may happen in the | 456 | |
435 | * debug case if code optimzation is disabled.) | 457 | #define return_VOID \ |
436 | */ | 458 | ACPI_DO_WHILE0 ({ \ |
437 | #ifndef ACPI_SIMPLE_RETURN_MACROS | 459 | acpi_ut_exit (ACPI_DEBUG_PARAMETERS); \ |
438 | 460 | return; \ | |
439 | #define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ | 461 | }) |
440 | register acpi_status _s = (s); \ | 462 | |
441 | acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, _s); \ | 463 | #define return_ACPI_STATUS(status) \ |
442 | return (_s); }) | 464 | ACPI_TRACE_EXIT (acpi_ut_status_exit, (acpi_status), status) |
443 | #define return_PTR(s) ACPI_DO_WHILE0 ({ \ | 465 | |
444 | register void *_s = (void *) (s); \ | 466 | #define return_PTR(pointer) \ |
445 | acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) _s); \ | 467 | ACPI_TRACE_EXIT (acpi_ut_ptr_exit, (u8 *), pointer) |
446 | return (_s); }) | 468 | |
447 | #define return_VALUE(s) ACPI_DO_WHILE0 ({ \ | 469 | #define return_VALUE(value) \ |
448 | register u64 _s = (s); \ | 470 | ACPI_TRACE_EXIT (acpi_ut_value_exit, (u64), value) |
449 | acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, _s); \ | 471 | |
450 | return (_s); }) | 472 | /* These exit macros are superfluous and should be removed entirely */ |
451 | #define return_UINT8(s) ACPI_DO_WHILE0 ({ \ | 473 | |
452 | register u8 _s = (u8) (s); \ | 474 | #define return_UINT8 return_VALUE |
453 | acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \ | 475 | #define return_UINT32 return_VALUE |
454 | return (_s); }) | ||
455 | #define return_UINT32(s) ACPI_DO_WHILE0 ({ \ | ||
456 | register u32 _s = (u32) (s); \ | ||
457 | acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) _s); \ | ||
458 | return (_s); }) | ||
459 | #else /* Use original less-safe macros */ | ||
460 | |||
461 | #define return_ACPI_STATUS(s) ACPI_DO_WHILE0 ({ \ | ||
462 | acpi_ut_status_exit (ACPI_DEBUG_PARAMETERS, (s)); \ | ||
463 | return((s)); }) | ||
464 | #define return_PTR(s) ACPI_DO_WHILE0 ({ \ | ||
465 | acpi_ut_ptr_exit (ACPI_DEBUG_PARAMETERS, (u8 *) (s)); \ | ||
466 | return((s)); }) | ||
467 | #define return_VALUE(s) ACPI_DO_WHILE0 ({ \ | ||
468 | acpi_ut_value_exit (ACPI_DEBUG_PARAMETERS, (u64) (s)); \ | ||
469 | return((s)); }) | ||
470 | #define return_UINT8(s) return_VALUE(s) | ||
471 | #define return_UINT32(s) return_VALUE(s) | ||
472 | |||
473 | #endif /* ACPI_SIMPLE_RETURN_MACROS */ | ||
474 | 476 | ||
475 | /* Conditional execution */ | 477 | /* Conditional execution */ |
476 | 478 | ||
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h index 38e1be094655..be014bf7efe5 100644 --- a/include/acpi/acoutput.h +++ b/include/acpi/acoutput.h | |||
@@ -263,16 +263,42 @@ | |||
263 | * Common parameters used for debug output functions: | 263 | * Common parameters used for debug output functions: |
264 | * line number, function name, module(file) name, component ID | 264 | * line number, function name, module(file) name, component ID |
265 | */ | 265 | */ |
266 | #define ACPI_DEBUG_PARAMETERS __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT | 266 | #define ACPI_DEBUG_PARAMETERS \ |
267 | __LINE__, ACPI_GET_FUNCTION_NAME, _acpi_module_name, _COMPONENT | ||
267 | 268 | ||
268 | /* | 269 | /* |
269 | * Master debug print macros | 270 | * Master debug print macros |
270 | * Print message if and only if: | 271 | * Print message if and only if: |
271 | * 1) Debug print for the current component is enabled | 272 | * 1) Debug print for the current component is enabled |
272 | * 2) Debug error level or trace level for the print statement is enabled | 273 | * 2) Debug error level or trace level for the print statement is enabled |
274 | * | ||
275 | * November 2012: Moved the runtime check for whether to actually emit the | ||
276 | * debug message outside of the print function itself. This improves overall | ||
277 | * performance at a relatively small code cost. Implementation involves the | ||
278 | * use of variadic macros supported by C99. | ||
273 | */ | 279 | */ |
274 | #define ACPI_DEBUG_PRINT(plist) acpi_debug_print plist | 280 | |
275 | #define ACPI_DEBUG_PRINT_RAW(plist) acpi_debug_print_raw plist | 281 | /* DEBUG_PRINT functions */ |
282 | |||
283 | #define ACPI_DEBUG_PRINT(plist) ACPI_ACTUAL_DEBUG plist | ||
284 | #define ACPI_DEBUG_PRINT_RAW(plist) ACPI_ACTUAL_DEBUG_RAW plist | ||
285 | |||
286 | /* Helper macros for DEBUG_PRINT */ | ||
287 | |||
288 | #define ACPI_IS_DEBUG_ENABLED(level, component) \ | ||
289 | (level & acpi_dbg_level) && (component & acpi_dbg_layer) | ||
290 | |||
291 | #define ACPI_DEBUG(function, level, line, filename, modulename, component, ...) \ | ||
292 | if (ACPI_IS_DEBUG_ENABLED (level, component)) \ | ||
293 | { \ | ||
294 | function (level, line, filename, modulename, component, __VA_ARGS__); \ | ||
295 | } | ||
296 | |||
297 | #define ACPI_ACTUAL_DEBUG(level, line, filename, modulename, component, ...) \ | ||
298 | ACPI_DEBUG (acpi_debug_print, level, line, filename, modulename, component, __VA_ARGS__) | ||
299 | |||
300 | #define ACPI_ACTUAL_DEBUG_RAW(level, line, filename, modulename, component, ...) \ | ||
301 | ACPI_DEBUG (acpi_debug_print_raw, level, line, filename, modulename, component, __VA_ARGS__) | ||
276 | 302 | ||
277 | #else | 303 | #else |
278 | /* | 304 | /* |