Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux-2.6/libata-dev.git] / drivers / acpi / acpica / utxferror.c
blob976b6c734fce961b44a94773a4e8357b02727735
1 /*******************************************************************************
3 * Module Name: utxferror - Various error/warning output functions
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, 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 iASL 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-iASL 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: "
85 #define ACPI_MSG_BIOS_ERROR "ACPI BIOS Bug: Error: "
86 #define ACPI_MSG_BIOS_WARNING "ACPI BIOS Bug: Warning: "
88 * Common message suffix
90 #define ACPI_MSG_SUFFIX \
91 acpi_os_printf (" (%8.8X/%s-%u)\n", ACPI_CA_VERSION, module_name, line_number)
92 /*******************************************************************************
94 * FUNCTION: acpi_error
96 * PARAMETERS: module_name - Caller's module name (for error output)
97 * line_number - Caller's line number (for error output)
98 * format - Printf format string + additional args
100 * RETURN: None
102 * DESCRIPTION: Print "ACPI Error" message with module/line/version info
104 ******************************************************************************/
105 void ACPI_INTERNAL_VAR_XFACE
106 acpi_error(const char *module_name, u32 line_number, const char *format, ...)
108 va_list arg_list;
110 ACPI_MSG_REDIRECT_BEGIN;
111 acpi_os_printf(ACPI_MSG_ERROR);
113 va_start(arg_list, format);
114 acpi_os_vprintf(format, arg_list);
115 ACPI_MSG_SUFFIX;
116 va_end(arg_list);
118 ACPI_MSG_REDIRECT_END;
121 ACPI_EXPORT_SYMBOL(acpi_error)
123 /*******************************************************************************
125 * FUNCTION: acpi_exception
127 * PARAMETERS: module_name - Caller's module name (for error output)
128 * line_number - Caller's line number (for error output)
129 * status - Status to be formatted
130 * format - Printf format string + additional args
132 * RETURN: None
134 * DESCRIPTION: Print "ACPI Exception" message with module/line/version info
135 * and decoded acpi_status.
137 ******************************************************************************/
138 void ACPI_INTERNAL_VAR_XFACE
139 acpi_exception(const char *module_name,
140 u32 line_number, acpi_status status, const char *format, ...)
142 va_list arg_list;
144 ACPI_MSG_REDIRECT_BEGIN;
145 acpi_os_printf(ACPI_MSG_EXCEPTION "%s, ",
146 acpi_format_exception(status));
148 va_start(arg_list, format);
149 acpi_os_vprintf(format, arg_list);
150 ACPI_MSG_SUFFIX;
151 va_end(arg_list);
153 ACPI_MSG_REDIRECT_END;
156 ACPI_EXPORT_SYMBOL(acpi_exception)
158 /*******************************************************************************
160 * FUNCTION: acpi_warning
162 * PARAMETERS: module_name - Caller's module name (for error output)
163 * line_number - Caller's line number (for error output)
164 * format - Printf format string + additional args
166 * RETURN: None
168 * DESCRIPTION: Print "ACPI Warning" message with module/line/version info
170 ******************************************************************************/
171 void ACPI_INTERNAL_VAR_XFACE
172 acpi_warning(const char *module_name, u32 line_number, const char *format, ...)
174 va_list arg_list;
176 ACPI_MSG_REDIRECT_BEGIN;
177 acpi_os_printf(ACPI_MSG_WARNING);
179 va_start(arg_list, format);
180 acpi_os_vprintf(format, arg_list);
181 ACPI_MSG_SUFFIX;
182 va_end(arg_list);
184 ACPI_MSG_REDIRECT_END;
187 ACPI_EXPORT_SYMBOL(acpi_warning)
189 /*******************************************************************************
191 * FUNCTION: acpi_info
193 * PARAMETERS: module_name - Caller's module name (for error output)
194 * line_number - Caller's line number (for error output)
195 * format - Printf format string + additional args
197 * RETURN: None
199 * DESCRIPTION: Print generic "ACPI:" information message. There is no
200 * module/line/version info in order to keep the message simple.
202 * TBD: module_name and line_number args are not needed, should be removed.
204 ******************************************************************************/
205 void ACPI_INTERNAL_VAR_XFACE
206 acpi_info(const char *module_name, u32 line_number, const char *format, ...)
208 va_list arg_list;
210 ACPI_MSG_REDIRECT_BEGIN;
211 acpi_os_printf(ACPI_MSG_INFO);
213 va_start(arg_list, format);
214 acpi_os_vprintf(format, arg_list);
215 acpi_os_printf("\n");
216 va_end(arg_list);
218 ACPI_MSG_REDIRECT_END;
221 ACPI_EXPORT_SYMBOL(acpi_info)
223 /*******************************************************************************
225 * FUNCTION: acpi_bios_error
227 * PARAMETERS: module_name - Caller's module name (for error output)
228 * line_number - Caller's line number (for error output)
229 * format - Printf format string + additional args
231 * RETURN: None
233 * DESCRIPTION: Print "ACPI Firmware Error" message with module/line/version
234 * info
236 ******************************************************************************/
237 void ACPI_INTERNAL_VAR_XFACE
238 acpi_bios_error(const char *module_name,
239 u32 line_number, const char *format, ...)
241 va_list arg_list;
243 ACPI_MSG_REDIRECT_BEGIN;
244 acpi_os_printf(ACPI_MSG_BIOS_ERROR);
246 va_start(arg_list, format);
247 acpi_os_vprintf(format, arg_list);
248 ACPI_MSG_SUFFIX;
249 va_end(arg_list);
251 ACPI_MSG_REDIRECT_END;
254 ACPI_EXPORT_SYMBOL(acpi_bios_error)
256 /*******************************************************************************
258 * FUNCTION: acpi_bios_warning
260 * PARAMETERS: module_name - Caller's module name (for error output)
261 * line_number - Caller's line number (for error output)
262 * format - Printf format string + additional args
264 * RETURN: None
266 * DESCRIPTION: Print "ACPI Firmware Warning" message with module/line/version
267 * info
269 ******************************************************************************/
270 void ACPI_INTERNAL_VAR_XFACE
271 acpi_bios_warning(const char *module_name,
272 u32 line_number, const char *format, ...)
274 va_list arg_list;
276 ACPI_MSG_REDIRECT_BEGIN;
277 acpi_os_printf(ACPI_MSG_BIOS_WARNING);
279 va_start(arg_list, format);
280 acpi_os_vprintf(format, arg_list);
281 ACPI_MSG_SUFFIX;
282 va_end(arg_list);
284 ACPI_MSG_REDIRECT_END;
287 ACPI_EXPORT_SYMBOL(acpi_bios_warning)
290 * The remainder of this module contains internal error functions that may
291 * be configured out.
293 #if !defined (ACPI_NO_ERROR_MESSAGES) && !defined (ACPI_BIN_APP)
294 /*******************************************************************************
296 * FUNCTION: acpi_ut_predefined_warning
298 * PARAMETERS: module_name - Caller's module name (for error output)
299 * line_number - Caller's line number (for error output)
300 * pathname - Full pathname to the node
301 * node_flags - From Namespace node for the method/object
302 * format - Printf format string + additional args
304 * RETURN: None
306 * DESCRIPTION: Warnings for the predefined validation module. Messages are
307 * only emitted the first time a problem with a particular
308 * method/object is detected. This prevents a flood of error
309 * messages for methods that are repeatedly evaluated.
311 ******************************************************************************/
312 void ACPI_INTERNAL_VAR_XFACE
313 acpi_ut_predefined_warning(const char *module_name,
314 u32 line_number,
315 char *pathname,
316 u8 node_flags, const char *format, ...)
318 va_list arg_list;
321 * Warning messages for this method/object will be disabled after the
322 * first time a validation fails or an object is successfully repaired.
324 if (node_flags & ANOBJ_EVALUATED) {
325 return;
328 acpi_os_printf(ACPI_MSG_WARNING "For %s: ", pathname);
330 va_start(arg_list, format);
331 acpi_os_vprintf(format, arg_list);
332 ACPI_MSG_SUFFIX;
333 va_end(arg_list);
336 /*******************************************************************************
338 * FUNCTION: acpi_ut_predefined_info
340 * PARAMETERS: module_name - Caller's module name (for error output)
341 * line_number - Caller's line number (for error output)
342 * pathname - Full pathname to the node
343 * node_flags - From Namespace node for the method/object
344 * format - Printf format string + additional args
346 * RETURN: None
348 * DESCRIPTION: Info messages for the predefined validation module. Messages
349 * are only emitted the first time a problem with a particular
350 * method/object is detected. This prevents a flood of
351 * messages for methods that are repeatedly evaluated.
353 ******************************************************************************/
355 void ACPI_INTERNAL_VAR_XFACE
356 acpi_ut_predefined_info(const char *module_name,
357 u32 line_number,
358 char *pathname, u8 node_flags, const char *format, ...)
360 va_list arg_list;
363 * Warning messages for this method/object will be disabled after the
364 * first time a validation fails or an object is successfully repaired.
366 if (node_flags & ANOBJ_EVALUATED) {
367 return;
370 acpi_os_printf(ACPI_MSG_INFO "For %s: ", pathname);
372 va_start(arg_list, format);
373 acpi_os_vprintf(format, arg_list);
374 ACPI_MSG_SUFFIX;
375 va_end(arg_list);
378 /*******************************************************************************
380 * FUNCTION: acpi_ut_namespace_error
382 * PARAMETERS: module_name - Caller's module name (for error output)
383 * line_number - Caller's line number (for error output)
384 * internal_name - Name or path of the namespace node
385 * lookup_status - Exception code from NS lookup
387 * RETURN: None
389 * DESCRIPTION: Print error message with the full pathname for the NS node.
391 ******************************************************************************/
393 void
394 acpi_ut_namespace_error(const char *module_name,
395 u32 line_number,
396 const char *internal_name, acpi_status lookup_status)
398 acpi_status status;
399 u32 bad_name;
400 char *name = NULL;
402 ACPI_MSG_REDIRECT_BEGIN;
403 acpi_os_printf(ACPI_MSG_ERROR);
405 if (lookup_status == AE_BAD_CHARACTER) {
407 /* There is a non-ascii character in the name */
409 ACPI_MOVE_32_TO_32(&bad_name,
410 ACPI_CAST_PTR(u32, internal_name));
411 acpi_os_printf("[0x%.8X] (NON-ASCII)", bad_name);
412 } else {
413 /* Convert path to external format */
415 status = acpi_ns_externalize_name(ACPI_UINT32_MAX,
416 internal_name, NULL, &name);
418 /* Print target name */
420 if (ACPI_SUCCESS(status)) {
421 acpi_os_printf("[%s]", name);
422 } else {
423 acpi_os_printf("[COULD NOT EXTERNALIZE NAME]");
426 if (name) {
427 ACPI_FREE(name);
431 acpi_os_printf(" Namespace lookup failure, %s",
432 acpi_format_exception(lookup_status));
434 ACPI_MSG_SUFFIX;
435 ACPI_MSG_REDIRECT_END;
438 /*******************************************************************************
440 * FUNCTION: acpi_ut_method_error
442 * PARAMETERS: module_name - Caller's module name (for error output)
443 * line_number - Caller's line number (for error output)
444 * message - Error message to use on failure
445 * prefix_node - Prefix relative to the path
446 * path - Path to the node (optional)
447 * method_status - Execution status
449 * RETURN: None
451 * DESCRIPTION: Print error message with the full pathname for the method.
453 ******************************************************************************/
455 void
456 acpi_ut_method_error(const char *module_name,
457 u32 line_number,
458 const char *message,
459 struct acpi_namespace_node *prefix_node,
460 const char *path, acpi_status method_status)
462 acpi_status status;
463 struct acpi_namespace_node *node = prefix_node;
465 ACPI_MSG_REDIRECT_BEGIN;
466 acpi_os_printf(ACPI_MSG_ERROR);
468 if (path) {
469 status =
470 acpi_ns_get_node(prefix_node, path, ACPI_NS_NO_UPSEARCH,
471 &node);
472 if (ACPI_FAILURE(status)) {
473 acpi_os_printf("[Could not get node by pathname]");
477 acpi_ns_print_node_pathname(node, message);
478 acpi_os_printf(", %s", acpi_format_exception(method_status));
480 ACPI_MSG_SUFFIX;
481 ACPI_MSG_REDIRECT_END;
484 #endif /* ACPI_NO_ERROR_MESSAGES */