aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utils.c
diff options
context:
space:
mode:
authorToshi Kani <toshi.kani@hp.com>2012-11-20 20:36:28 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2012-11-21 17:20:22 -0500
commitfbfddae696572e57a441252abbd65f7220e06030 (patch)
treecdd75792b688eb816e32b55b499479de45d5d4c5 /drivers/acpi/utils.c
parentb59bc2fbb4bb67e486c40cdb6a306c06acbaec06 (diff)
ACPI: Add acpi_handle_<level>() interfaces
This patch introduces acpi_handle_<level>(), where <level> is a kernel message level such as err/warn/info, to support improved logging messages for ACPI, esp. hot-plug operations. acpi_handle_<level>() appends "ACPI" prefix and ACPI object path to the messages. This improves diagnosis of hotplug operations since an error message in a log file identifies an object that caused an issue. This interface acquires the global namespace mutex to obtain an object path. In interrupt context, it shows the object path as <n/a>. acpi_handle_<level>() takes acpi_handle as an argument, which is passed to ACPI hotplug notify handlers from the ACPICA. Therefore, it is always available unlike other kernel objects, such as device. For example: acpi_handle_err(handle, "Device don't exist, dropping EJECT\n"); logs an error message like this at KERN_ERR. ACPI: \_SB_.SCK4.CPU4: Device don't exist, dropping EJECT ACPI hot-plug drivers can use acpi_handle_<level>() when they need to identify a target ACPI object path in their messages, such as error cases. The usage model is similar to dev_<level>(). acpi_handle_<level>() can be used when a device is not created or is invalid during hot-plug operations. ACPI object path is also consistent on the platform, unlike device name that gets incremented over hotplug operations. ACPI drivers should use dev_<level>() when a device object is valid. Device name provides more user friendly information, and avoids acquiring the global ACPI namespace mutex. ACPI drivers also continue to use pr_<level>() when they do not need to specify device information, such as boot-up messages. Note: ACPI_[WARNING|INFO|ERROR]() are intended for the ACPICA and are not associated with the kernel message level. Signed-off-by: Toshi Kani <toshi.kani@hp.com> Tested-by: Vijay Mohan Pandarathil <vijaymohan.pandarathil@hp.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/utils.c')
-rw-r--r--drivers/acpi/utils.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c
index 462f7e300363..744371304313 100644
--- a/drivers/acpi/utils.c
+++ b/drivers/acpi/utils.c
@@ -28,6 +28,8 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/hardirq.h>
32#include <linux/acpi.h>
31#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
32#include <acpi/acpi_drivers.h> 34#include <acpi/acpi_drivers.h>
33 35
@@ -457,3 +459,39 @@ acpi_evaluate_hotplug_ost(acpi_handle handle, u32 source_event,
457#endif 459#endif
458} 460}
459EXPORT_SYMBOL(acpi_evaluate_hotplug_ost); 461EXPORT_SYMBOL(acpi_evaluate_hotplug_ost);
462
463/**
464 * acpi_handle_printk: Print message with ACPI prefix and object path
465 *
466 * This function is called through acpi_handle_<level> macros and prints
467 * a message with ACPI prefix and object path. This function acquires
468 * the global namespace mutex to obtain an object path. In interrupt
469 * context, it shows the object path as <n/a>.
470 */
471void
472acpi_handle_printk(const char *level, acpi_handle handle, const char *fmt, ...)
473{
474 struct va_format vaf;
475 va_list args;
476 struct acpi_buffer buffer = {
477 .length = ACPI_ALLOCATE_BUFFER,
478 .pointer = NULL
479 };
480 const char *path;
481
482 va_start(args, fmt);
483 vaf.fmt = fmt;
484 vaf.va = &args;
485
486 if (in_interrupt() ||
487 acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer) != AE_OK)
488 path = "<n/a>";
489 else
490 path = buffer.pointer;
491
492 printk("%sACPI: %s: %pV", level, path, &vaf);
493
494 va_end(args);
495 kfree(buffer.pointer);
496}
497EXPORT_SYMBOL(acpi_handle_printk);