mm/hmm.c: remove superfluous RCU protection around radix tree lookup
[linux/fpc-iii.git] / drivers / acpi / acpica / utexcep.c
blob60fbdcde151b772b27f46ec4cdf9ea9d3abf9e07
1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /*******************************************************************************
4 * Module Name: utexcep - Exception code support
6 ******************************************************************************/
8 #define EXPORT_ACPI_INTERFACES
10 #define ACPI_DEFINE_EXCEPTION_TABLE
11 #include <acpi/acpi.h>
12 #include "accommon.h"
14 #define _COMPONENT ACPI_UTILITIES
15 ACPI_MODULE_NAME("utexcep")
17 /*******************************************************************************
19 * FUNCTION: acpi_format_exception
21 * PARAMETERS: status - The acpi_status code to be formatted
23 * RETURN: A string containing the exception text. A valid pointer is
24 * always returned.
26 * DESCRIPTION: This function translates an ACPI exception into an ASCII
27 * string. Returns "unknown status" string for invalid codes.
29 ******************************************************************************/
30 const char *acpi_format_exception(acpi_status status)
32 const struct acpi_exception_info *exception;
34 ACPI_FUNCTION_ENTRY();
36 exception = acpi_ut_validate_exception(status);
37 if (!exception) {
39 /* Exception code was not recognized */
41 ACPI_ERROR((AE_INFO,
42 "Unknown exception code: 0x%8.8X", status));
44 return ("UNKNOWN_STATUS_CODE");
47 return (exception->name);
50 ACPI_EXPORT_SYMBOL(acpi_format_exception)
52 /*******************************************************************************
54 * FUNCTION: acpi_ut_validate_exception
56 * PARAMETERS: status - The acpi_status code to be formatted
58 * RETURN: A string containing the exception text. NULL if exception is
59 * not valid.
61 * DESCRIPTION: This function validates and translates an ACPI exception into
62 * an ASCII string.
64 ******************************************************************************/
65 const struct acpi_exception_info *acpi_ut_validate_exception(acpi_status status)
67 u32 sub_status;
68 const struct acpi_exception_info *exception = NULL;
70 ACPI_FUNCTION_ENTRY();
73 * Status is composed of two parts, a "type" and an actual code
75 sub_status = (status & ~AE_CODE_MASK);
77 switch (status & AE_CODE_MASK) {
78 case AE_CODE_ENVIRONMENTAL:
80 if (sub_status <= AE_CODE_ENV_MAX) {
81 exception = &acpi_gbl_exception_names_env[sub_status];
83 break;
85 case AE_CODE_PROGRAMMER:
87 if (sub_status <= AE_CODE_PGM_MAX) {
88 exception = &acpi_gbl_exception_names_pgm[sub_status];
90 break;
92 case AE_CODE_ACPI_TABLES:
94 if (sub_status <= AE_CODE_TBL_MAX) {
95 exception = &acpi_gbl_exception_names_tbl[sub_status];
97 break;
99 case AE_CODE_AML:
101 if (sub_status <= AE_CODE_AML_MAX) {
102 exception = &acpi_gbl_exception_names_aml[sub_status];
104 break;
106 case AE_CODE_CONTROL:
108 if (sub_status <= AE_CODE_CTRL_MAX) {
109 exception = &acpi_gbl_exception_names_ctrl[sub_status];
111 break;
113 default:
115 break;
118 if (!exception || !exception->name) {
119 return (NULL);
122 return (exception);