aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.c
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-22 06:47:47 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-26 08:38:57 -0400
commit45fef5b88d1f2f47ecdefae6354372d440ca5c84 (patch)
treedb7f4741889a8adf72ce308ac7178b3a4f73319f /drivers/acpi/utils.c
parentd0103387bc21644d297cb61ee623c7114e395575 (diff)
ACPI: add dynamic_debug support
Commit 1a699476e258 ("ACPI / hotplug / PCI: Hotplug notifications from acpi_bus_notify()") added debug messages for a few common events. These debug messages are unconditionally enabled if CONFIG_DYNAMIC_DEBUG is defined, contrary to the documented meaning, making the ACPI system spew lots of unwanted noise on any kernel with dynamic debugging. The bug was introduced by commit fbfddae69657 ("ACPI: Add acpi_handle_<level>() interfaces"), which added the CONFIG_DYNAMIC_DEBUG dependency without respecting its meaning. Fix by adding real support for dynamic_debug. Fixes: fbfddae69657 ("ACPI: Add acpi_handle_<level>() interfaces") Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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