Use dentry_path() to create full path to inode object
[pohmelfs.git] / drivers / acpi / acpica / utxferror.c
blob52b568af18199570446431a81638814b3cc6c99a
1 /*******************************************************************************
3 * Module Name: utxferror - Various error/warning output functions
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2012, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <linux/export.h>
45 #include <acpi/acpi.h>
46 #include "accommon.h"
47 #include "acnamesp.h"
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME("utxferror")
53 * This module is used for the in-kernel ACPICA as well as the ACPICA
54 * tools/applications.
56 * For the i_aSL compiler case, the output is redirected to stderr so that
57 * any of the various ACPI errors and warnings do not appear in the output
58 * files, for either the compiler or disassembler portions of the tool.
60 #ifdef ACPI_ASL_COMPILER
61 #include <stdio.h>
62 extern FILE *acpi_gbl_output_file;
64 #define ACPI_MSG_REDIRECT_BEGIN \
65 FILE *output_file = acpi_gbl_output_file; \
66 acpi_os_redirect_output (stderr);
68 #define ACPI_MSG_REDIRECT_END \
69 acpi_os_redirect_output (output_file);
71 #else
73 * non-i_aSL case - no redirection, nothing to do
75 #define ACPI_MSG_REDIRECT_BEGIN
76 #define ACPI_MSG_REDIRECT_END
77 #endif
79 * Common message prefixes
81 #define ACPI_MSG_ERROR "ACPI Error: "
82 #define ACPI_MSG_EXCEPTION "ACPI Exception: "
83 #define ACPI_MSG_WARNING "ACPI Warning: "
84 #define ACPI_MSG_INFO "ACPI: "
86 * Common message suffix
88 #define ACPI_MSG_SUFFIX \
89 acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
90 /*******************************************************************************
92 * FUNCTION: acpi_error
94 * PARAMETERS: module_name - Caller's module name (for error output)
95 * line_number - Caller's line number (for error output)
96 * Format - Printf format string + additional args
98 * RETURN: None
100 * DESCRIPTION: Print "ACPI Error" message with module/line/version info
102 ******************************************************************************/
103 void ACPI_INTERNAL_VAR_XFACE
104 acpi_error(const char *module_name, u32 line_number, const char *format, ...)
106 va_list arg_list;
108 ACPI_MSG_REDIRECT_BEGIN;
109 acpi_os_printf(ACPI_MSG_ERROR);
111 va_start(arg_list, format);
112 acpi_os_vprintf(format, arg_list);
113 ACPI_MSG_SUFFIX;
114 va_end(arg_list);
116 ACPI_MSG_REDIRECT_END;
119 ACPI_EXPORT_SYMBOL(acpi_error)
121 /*******************************************************************************
123 * FUNCTION: acpi_exception
125 * PARAMETERS: module_name - Caller's module name (for error output)
126 * line_number - Caller's line number (for error output)
127 * Status - Status to be formatted
128 * Format - Printf format string + additional args
130 * RETURN: None
132 * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
133 * and decoded acpi_status.
135 ******************************************************************************/
136 void ACPI_INTERNAL_VAR_XFACE
137 acpi_exception(const char *module_name,
138 u32 line_number, acpi_status status, const char *format, ...)
140 va_list arg_list;
142 ACPI_MSG_REDIRECT_BEGIN;
143 acpi_os_printf(ACPI_MSG_EXCEPTION "%s, ",
144 acpi_format_exception(status));
146 va_start(arg_list, format);
147 acpi_os_vprintf(format, arg_list);
148 ACPI_MSG_SUFFIX;
149 va_end(arg_list);
151 ACPI_MSG_REDIRECT_END;
154 ACPI_EXPORT_SYMBOL(acpi_exception)
156 /*******************************************************************************
158 * FUNCTION: acpi_warning
160 * PARAMETERS: module_name - Caller's module name (for error output)
161 * line_number - Caller's line number (for error output)
162 * Format - Printf format string + additional args
164 * RETURN: None
166 * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
168 ******************************************************************************/
169 void ACPI_INTERNAL_VAR_XFACE
170 acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
172 va_list arg_list;
174 ACPI_MSG_REDIRECT_BEGIN;
175 acpi_os_printf(ACPI_MSG_WARNING);
177 va_start(arg_list, format);
178 acpi_os_vprintf(format, arg_list);
179 ACPI_MSG_SUFFIX;
180 va_end(arg_list);
182 ACPI_MSG_REDIRECT_END;
185 ACPI_EXPORT_SYMBOL(acpi_warning)
187 /*******************************************************************************
189 * FUNCTION: acpi_info
191 * PARAMETERS: module_name - Caller's module name (for error output)
192 * line_number - Caller's line number (for error output)
193 * Format - Printf format string + additional args
195 * RETURN: None
197 * DESCRIPTION: Print generic "ACPI:" information message. There is no
198 * module/line/version info in order to keep the message simple.
200 * TBD: module_name and line_number args are not needed, should be removed.
202 ******************************************************************************/
203 void ACPI_INTERNAL_VAR_XFACE
204 acpi_info(const char *module_name, u32 line_number, const char *format, ...)
206 va_list arg_list;
208 ACPI_MSG_REDIRECT_BEGIN;
209 acpi_os_printf(ACPI_MSG_INFO);
211 va_start(arg_list, format);
212 acpi_os_vprintf(format, arg_list);
213 acpi_os_printf("\n");
214 va_end(arg_list);
216 ACPI_MSG_REDIRECT_END;
219 ACPI_EXPORT_SYMBOL(acpi_info)
222 * The remainder of this module contains internal error functions that may
223 * be configured out.
225 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
226 /*******************************************************************************
228 * FUNCTION: acpi_ut_predefined_warning
230 * PARAMETERS: module_name - Caller's module name (for error output)
231 * line_number - Caller's line number (for error output)
232 * Pathname - Full pathname to the node
233 * node_flags - From Namespace node for the method/object
234 * Format - Printf format string + additional args
236 * RETURN: None
238 * DESCRIPTION: Warnings for the predefined validation module. Messages are
239 * only emitted the first time a problem with a particular
240 * method/object is detected. This prevents a flood of error
241 * messages for methods that are repeatedly evaluated.
243 ******************************************************************************/
244 void ACPI_INTERNAL_VAR_XFACE
245 acpi_ut_predefined_warning(const char *module_name,
246 u32 line_number,
247 char *pathname,
248 u8 node_flags, const char *format, ...)
250 va_list arg_list;
253 * Warning messages for this method/object will be disabled after the
254 * first time a validation fails or an object is successfully repaired.
256 if (node_flags & ANOBJ_EVALUATED) {
257 return;
260 acpi_os_printf(ACPI_MSG_WARNING "For %s: ", pathname);
262 va_start(arg_list, format);
263 acpi_os_vprintf(format, arg_list);
264 ACPI_MSG_SUFFIX;
265 va_end(arg_list);
268 /*******************************************************************************
270 * FUNCTION: acpi_ut_predefined_info
272 * PARAMETERS: module_name - Caller's module name (for error output)
273 * line_number - Caller's line number (for error output)
274 * Pathname - Full pathname to the node
275 * node_flags - From Namespace node for the method/object
276 * Format - Printf format string + additional args
278 * RETURN: None
280 * DESCRIPTION: Info messages for the predefined validation module. Messages
281 * are only emitted the first time a problem with a particular
282 * method/object is detected. This prevents a flood of
283 * messages for methods that are repeatedly evaluated.
285 ******************************************************************************/
287 void ACPI_INTERNAL_VAR_XFACE
288 acpi_ut_predefined_info(const char *module_name,
289 u32 line_number,
290 char *pathname, u8 node_flags, const char *format, ...)
292 va_list arg_list;
295 * Warning messages for this method/object will be disabled after the
296 * first time a validation fails or an object is successfully repaired.
298 if (node_flags & ANOBJ_EVALUATED) {
299 return;
302 acpi_os_printf(ACPI_MSG_INFO "For %s: ", pathname);
304 va_start(arg_list, format);
305 acpi_os_vprintf(format, arg_list);
306 ACPI_MSG_SUFFIX;
307 va_end(arg_list);
310 /*******************************************************************************
312 * FUNCTION: acpi_ut_namespace_error
314 * PARAMETERS: module_name - Caller's module name (for error output)
315 * line_number - Caller's line number (for error output)
316 * internal_name - Name or path of the namespace node
317 * lookup_status - Exception code from NS lookup
319 * RETURN: None
321 * DESCRIPTION: Print error message with the full pathname for the NS node.
323 ******************************************************************************/
325 void
326 acpi_ut_namespace_error(const char *module_name,
327 u32 line_number,
328 const char *internal_name, acpi_status lookup_status)
330 acpi_status status;
331 u32 bad_name;
332 char *name = NULL;
334 ACPI_MSG_REDIRECT_BEGIN;
335 acpi_os_printf(ACPI_MSG_ERROR);
337 if (lookup_status == AE_BAD_CHARACTER) {
339 /* There is a non-ascii character in the name */
341 ACPI_MOVE_32_TO_32(&bad_name,
342 ACPI_CAST_PTR(u32, internal_name));
343 acpi_os_printf("[0x%4.4X] (NON-ASCII)", bad_name);
344 } else {
345 /* Convert path to external format */
347 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
348 internal_name, NULL, &name);
350 /* Print target name */
352 if (ACPI_SUCCESS(status)) {
353 acpi_os_printf("[%s]", name);
354 } else {
355 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
358 if (name) {
359 ACPI_FREE(name);
363 acpi_os_printf(" Namespace lookup failure, %s",
364 acpi_format_exception(lookup_status));
366 ACPI_MSG_SUFFIX;
367 ACPI_MSG_REDIRECT_END;
370 /*******************************************************************************
372 * FUNCTION: acpi_ut_method_error
374 * PARAMETERS: module_name - Caller's module name (for error output)
375 * line_number - Caller's line number (for error output)
376 * Message - Error message to use on failure
377 * prefix_node - Prefix relative to the path
378 * Path - Path to the node (optional)
379 * method_status - Execution status
381 * RETURN: None
383 * DESCRIPTION: Print error message with the full pathname for the method.
385 ******************************************************************************/
387 void
388 acpi_ut_method_error(const char *module_name,
389 u32 line_number,
390 const char *message,
391 struct acpi_namespace_node *prefix_node,
392 const char *path, acpi_status method_status)
394 acpi_status status;
395 struct acpi_namespace_node *node = prefix_node;
397 ACPI_MSG_REDIRECT_BEGIN;
398 acpi_os_printf(ACPI_MSG_ERROR);
400 if (path) {
401 status =
402 acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
403 &node);
404 if (ACPI_FAILURE(status)) {
405 acpi_os_printf("[Could not get node by pathname]");
409 acpi_ns_print_node_pathname(node, message);
410 acpi_os_printf(", %s", acpi_format_exception(method_status));
412 ACPI_MSG_SUFFIX;
413 ACPI_MSG_REDIRECT_END;
416 #endif /* ACPI_NO_ERROR_MESSAGES */