aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/uthex.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpica/uthex.c')
-rw-r--r--drivers/acpi/acpica/uthex.c46
1 files changed, 42 insertions, 4 deletions
diff --git a/drivers/acpi/acpica/uthex.c b/drivers/acpi/acpica/uthex.c
index 4354fb800fe4..36d2fc789088 100644
--- a/drivers/acpi/acpica/uthex.c
+++ b/drivers/acpi/acpica/uthex.c
@@ -75,9 +75,41 @@ char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
75 75
76/******************************************************************************* 76/*******************************************************************************
77 * 77 *
78 * FUNCTION: acpi_ut_ascii_to_hex_byte
79 *
80 * PARAMETERS: two_ascii_chars - Pointer to two ASCII characters
81 * return_byte - Where converted byte is returned
82 *
83 * RETURN: Status and converted hex byte
84 *
85 * DESCRIPTION: Perform ascii-to-hex translation, exactly two ASCII characters
86 * to a single converted byte value.
87 *
88 ******************************************************************************/
89
90acpi_status acpi_ut_ascii_to_hex_byte(char *two_ascii_chars, u8 *return_byte)
91{
92
93 /* Both ASCII characters must be valid hex digits */
94
95 if (!isxdigit((int)two_ascii_chars[0]) ||
96 !isxdigit((int)two_ascii_chars[1])) {
97 return (AE_BAD_HEX_CONSTANT);
98 }
99
100 *return_byte =
101 acpi_ut_ascii_char_to_hex(two_ascii_chars[1]) |
102 (acpi_ut_ascii_char_to_hex(two_ascii_chars[0]) << 4);
103
104 return (AE_OK);
105}
106
107/*******************************************************************************
108 *
78 * FUNCTION: acpi_ut_ascii_char_to_hex 109 * FUNCTION: acpi_ut_ascii_char_to_hex
79 * 110 *
80 * PARAMETERS: hex_char - Hex character in Ascii 111 * PARAMETERS: hex_char - Hex character in Ascii. Must be:
112 * 0-9 or A-F or a-f
81 * 113 *
82 * RETURN: The binary value of the ascii/hex character 114 * RETURN: The binary value of the ascii/hex character
83 * 115 *
@@ -88,13 +120,19 @@ char acpi_ut_hex_to_ascii_char(u64 integer, u32 position)
88u8 acpi_ut_ascii_char_to_hex(int hex_char) 120u8 acpi_ut_ascii_char_to_hex(int hex_char)
89{ 121{
90 122
91 if (hex_char <= 0x39) { 123 /* Values 0-9 */
92 return ((u8)(hex_char - 0x30)); 124
125 if (hex_char <= '9') {
126 return ((u8)(hex_char - '0'));
93 } 127 }
94 128
95 if (hex_char <= 0x46) { 129 /* Upper case A-F */
130
131 if (hex_char <= 'F') {
96 return ((u8)(hex_char - 0x37)); 132 return ((u8)(hex_char - 0x37));
97 } 133 }
98 134
135 /* Lower case a-f */
136
99 return ((u8)(hex_char - 0x57)); 137 return ((u8)(hex_char - 0x57));
100} 138}