aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r--drivers/acpi/utils.c64
1 files changed, 52 insertions, 12 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index bba526148583..07c8c5a5ee95 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -30,6 +30,7 @@
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/hardirq.h> 31#include <linux/hardirq.h>
32#include <linux/acpi.h> 32#include <linux/acpi.h>
33#include <linux/dynamic_debug.h>
33 34
34#include "internal.h" 35#include "internal.h"
35 36
@@ -457,6 +458,24 @@ acpi_evaluate_ost(acpi_handle handle, u32 source_event, u32 status_code,
457EXPORT_SYMBOL(acpi_evaluate_ost); 458EXPORT_SYMBOL(acpi_evaluate_ost);
458 459
459/** 460/**
461 * acpi_handle_path: Return the object path of handle
462 *
463 * Caller must free the returned buffer
464 */
465static char *acpi_handle_path(acpi_handle handle)
466{
467 struct acpi_buffer buffer = {
468 .length = ACPI_ALLOCATE_BUFFER,
469 .pointer = NULL
470 };
471
472 if (in_interrupt() ||
473 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK)
474 return NULL;
475 return buffer.pointer;
476}
477
478/**
460 * acpi_handle_printk: Print message with ACPI prefix and object path 479 * acpi_handle_printk: Print message with ACPI prefix and object path
461 * 480 *
462 * This function is called through acpi_handle_<level> macros and prints 481 * This function is called through acpi_handle_<level> macros and prints
@@ -469,29 +488,50 @@ acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
469{ 488{
470 struct va_format vaf; 489 struct va_format vaf;
471 va_list args; 490 va_list args;
472 struct acpi_buffer buffer = {
473 .length = ACPI_ALLOCATE_BUFFER,
474 .pointer = NULL
475 };
476 const char *path; 491 const char *path;
477 492
478 va_start(args, fmt); 493 va_start(args, fmt);
479 vaf.fmt = fmt; 494 vaf.fmt = fmt;
480 vaf.va = &args; 495 vaf.va = &args;
481 496
482 if (in_interrupt() || 497 path = acpi_handle_path(handle);
483 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK) 498 printk("%sACPI: %s: %pV", level, path ? path : "<n/a>" , &vaf);
484 path = "<n/a>";
485 else
486 path = buffer.pointer;
487
488 printk("%sACPI: %s: %pV", level, path, &vaf);
489 499
490 va_end(args); 500 va_end(args);
491 kfree(buffer.pointer); 501 kfree(path);
492} 502}
493EXPORT_SYMBOL(acpi_handle_printk); 503EXPORT_SYMBOL(acpi_handle_printk);
494 504
505#if defined(CONFIG_DYNAMIC_DEBUG)
506/**
507 * __acpi_handle_debug: pr_debug with ACPI prefix and object path
508 *
509 * This function is called through acpi_handle_debug macro and debug
510 * prints a message with ACPI prefix and object path. This function
511 * acquires the global namespace mutex to obtain an object path. In
512 * interrupt context, it shows the object path as <n/a>.
513 */
514void
515__acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle,
516 const char *fmt, ...)
517{
518 struct va_format vaf;
519 va_list args;
520 const char *path;
521
522 va_start(args, fmt);
523 vaf.fmt = fmt;
524 vaf.va = &args;
525
526 path = acpi_handle_path(handle);
527 __dynamic_pr_debug(descriptor, "ACPI: %s: %pV", path ? path : "<n/a>", &vaf);
528
529 va_end(args);
530 kfree(path);
531}
532EXPORT_SYMBOL(__acpi_handle_debug);
533#endif
534
495/** 535/**
496 * acpi_has_method: Check whether @handle has a method named @name 536 * acpi_has_method: Check whether @handle has a method named @name
497 * @handle: ACPI device handle 537 * @handle: ACPI device handle