aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2017-09-19 22:00:43 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-10-03 19:43:06 -0400
commit72a2935502cc0f23567df649ebc644038d24abcf (patch)
treed5e0c49532c180474475255edc9874cff99dceda
parentfe97d28704147ba72f7d7859909f80b4bb5a17d4 (diff)
ACPICA: String conversions: Cleanup/format comments. No functional changes
ACPICA commit 33e38cd2406709b13fa0a7821e588505b3771163 Cleanup some of the language used in the large comments, especially the ones that reference the rules in the ACPI spec. Fixed some typos. Link: https://github.com/acpica/acpica/commit/33e38cd24067 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpica/utstrsuppt.c48
-rw-r--r--drivers/acpi/acpica/utstrtoul64.c104
2 files changed, 74 insertions, 78 deletions
diff --git a/drivers/acpi/acpica/utstrsuppt.c b/drivers/acpi/acpica/utstrsuppt.c
index ca41f037fd9a..2526ba3b4f12 100644
--- a/drivers/acpi/acpica/utstrsuppt.c
+++ b/drivers/acpi/acpica/utstrsuppt.c
@@ -1,6 +1,6 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Module Name: utstrsuppt - string-to-integer conversion support functions 3 * Module Name: utstrsuppt - Support functions for string-to-integer conversion
4 * 4 *
5 ******************************************************************************/ 5 ******************************************************************************/
6 6
@@ -83,7 +83,7 @@ acpi_status acpi_ut_convert_octal_string(char *string, u64 *return_value_ptr)
83 83
84 while (*string) { 84 while (*string) {
85 85
86 /* Must be ASCII 0-7, otherwise terminate with no error */ 86 /* Character must be ASCII 0-7, otherwise terminate with no error */
87 87
88 if (!(ACPI_IS_OCTAL_DIGIT(*string))) { 88 if (!(ACPI_IS_OCTAL_DIGIT(*string))) {
89 break; 89 break;
@@ -132,7 +132,7 @@ acpi_status acpi_ut_convert_decimal_string(char *string, u64 *return_value_ptr)
132 132
133 while (*string) { 133 while (*string) {
134 134
135 /* Must be ASCII 0-9, otherwise terminate with no error */ 135 /* Character must be ASCII 0-9, otherwise terminate with no error */
136 136
137 if (!isdigit(*string)) { 137 if (!isdigit(*string)) {
138 break; 138 break;
@@ -210,18 +210,17 @@ acpi_status acpi_ut_convert_hex_string(char *string, u64 *return_value_ptr)
210 * 210 *
211 * PARAMETERS: string - Pointer to input ASCII string 211 * PARAMETERS: string - Pointer to input ASCII string
212 * 212 *
213 * RETURN: Next character after the leading zeros. This behavior may be 213 * RETURN: Next character after any leading zeros. This character may be
214 * Used by the caller to detect end-of-string. 214 * used by the caller to detect end-of-string.
215 * 215 *
216 * DESCRIPTION: Remove all leading zeros in the input string. Return the 216 * DESCRIPTION: Remove any leading zeros in the input string. Return the
217 * next character after the final zero to check for the end 217 * next character after the final ASCII zero to enable the caller
218 * of the string (NULL terminator). 218 * to check for the end of the string (NULL terminator).
219 * 219 *
220 ******************************************************************************/ 220 ******************************************************************************/
221 221
222char acpi_ut_remove_leading_zeros(char **string) 222char acpi_ut_remove_leading_zeros(char **string)
223{ 223{
224 /* Skip all leading zeros */
225 224
226 while (**string == ACPI_ASCII_ZERO) { 225 while (**string == ACPI_ASCII_ZERO) {
227 *string += 1; 226 *string += 1;
@@ -236,9 +235,9 @@ char acpi_ut_remove_leading_zeros(char **string)
236 * 235 *
237 * PARAMETERS: string - Pointer to input ASCII string 236 * PARAMETERS: string - Pointer to input ASCII string
238 * 237 *
239 * RETURN: TRUE if a 0x prefix was found 238 * RETURN: TRUE if a "0x" prefix was found at the start of the string
240 * 239 *
241 * DESCRIPTION: Detect and remove a hex 0x prefix 240 * DESCRIPTION: Detect and remove a hex "0x" prefix
242 * 241 *
243 ******************************************************************************/ 242 ******************************************************************************/
244 243
@@ -260,7 +259,8 @@ u8 acpi_ut_detect_hex_prefix(char **string)
260 * 259 *
261 * PARAMETERS: string - Pointer to input ASCII string 260 * PARAMETERS: string - Pointer to input ASCII string
262 * 261 *
263 * RETURN: True if an octal 0 prefix was found 262 * RETURN: True if an octal "0" prefix was found at the start of the
263 * string
264 * 264 *
265 * DESCRIPTION: Detect and remove an octal prefix (zero) 265 * DESCRIPTION: Detect and remove an octal prefix (zero)
266 * 266 *
@@ -282,23 +282,22 @@ u8 acpi_ut_detect_octal_prefix(char **string)
282 * FUNCTION: acpi_ut_insert_digit 282 * FUNCTION: acpi_ut_insert_digit
283 * 283 *
284 * PARAMETERS: accumulated_value - Current value of the integer value 284 * PARAMETERS: accumulated_value - Current value of the integer value
285 * accumulator. The New value is 285 * accumulator. The new value is
286 * returned here. 286 * returned here.
287 * base - Radix, either 8/10/16 supported 287 * base - Radix, either 8/10/16
288 * ascii_digit - ASCII single digit to be inserted 288 * ascii_digit - ASCII single digit to be inserted
289 * 289 *
290 * RETURN: Status and result of convert/insert operation. The only 290 * RETURN: Status and result of the convert/insert operation. The only
291 * exception is numeric overflow of either the multiply or the 291 * possible returned exception code is numeric overflow of
292 * add operations. 292 * either the multiply or add conversion operations.
293 * 293 *
294 * DESCRIPTION: Generic conversion and insertion function for all bases: 294 * DESCRIPTION: Generic conversion and insertion function for all bases:
295 * 295 *
296 * 1) Multiply the current accumulated converted value by the 296 * 1) Multiply the current accumulated/converted value by the
297 * base in order to make room for the new character. 297 * base in order to make room for the new character.
298 * 298 *
299 * 2) Add the current accumulated/converted value the new 299 * 2) Convert the new character to binary and add it to the
300 * character (after the character has been converted to a binary 300 * current accumulated value.
301 * value).
302 * 301 *
303 * Note: The only possible exception indicates an integer 302 * Note: The only possible exception indicates an integer
304 * overflow (AE_NUMERIC_OVERFLOW) 303 * overflow (AE_NUMERIC_OVERFLOW)
@@ -318,17 +317,14 @@ acpi_ut_insert_digit(u64 *accumulated_value, u32 base, int ascii_digit)
318 return (status); 317 return (status);
319 } 318 }
320 319
321 /* Add in the new digit, and store to the caller's accumulated value */ 320 /* Add in the new digit, and store the sum to the accumulated value */
322 321
323 status = 322 status =
324 acpi_ut_strtoul_add64(product, 323 acpi_ut_strtoul_add64(product,
325 acpi_ut_ascii_char_to_hex(ascii_digit), 324 acpi_ut_ascii_char_to_hex(ascii_digit),
326 accumulated_value); 325 accumulated_value);
327 if (ACPI_FAILURE(status)) {
328 return (status);
329 }
330 326
331 return (AE_OK); 327 return (status);
332} 328}
333 329
334/******************************************************************************* 330/*******************************************************************************
diff --git a/drivers/acpi/acpica/utstrtoul64.c b/drivers/acpi/acpica/utstrtoul64.c
index e5a2df3f16e5..67a39d97a6d6 100644
--- a/drivers/acpi/acpica/utstrtoul64.c
+++ b/drivers/acpi/acpica/utstrtoul64.c
@@ -1,7 +1,7 @@
1/******************************************************************************* 1/*******************************************************************************
2 * 2 *
3 * Module Name: utstrtoul64 - string-to-integer support for both 64-bit 3 * Module Name: utstrtoul64 - String-to-integer conversion support for both
4 * and 32-bit integers 4 * 64-bit and 32-bit integers
5 * 5 *
6 ******************************************************************************/ 6 ******************************************************************************/
7 7
@@ -50,21 +50,23 @@ ACPI_MODULE_NAME("utstrtoul64")
50 50
51/******************************************************************************* 51/*******************************************************************************
52 * 52 *
53 * This module contains the external string to 64/32-bit unsigned integer 53 * This module contains the top-level string to 64/32-bit unsigned integer
54 * conversion functions: 54 * conversion functions:
55 * 55 *
56 * 1) Standard strtoul() function with 64-bit support. This is mostly used by 56 * 1) A standard strtoul() function that supports 64-bit integers, base
57 * the iASL compiler. 57 * 8/10/16, with integer overflow support. This is used mainly by the
58 * iASL compiler, which implements tighter constraints on integer
59 * constants than the runtime (interpreter) integer-to-string conversions.
58 * 2) Runtime "Explicit conversion" as defined in the ACPI specification. 60 * 2) Runtime "Explicit conversion" as defined in the ACPI specification.
59 * 3) Runtime "Implicit conversion" as defined in the ACPI specification. 61 * 3) Runtime "Implicit conversion" as defined in the ACPI specification.
60 * 62 *
61 * Current users of this module: 63 * Current users of this module:
62 * 64 *
65 * iASL - Preprocessor (constants and math expressions)
66 * iASL - Main parser, conversion of constants to integers
67 * iASL - Data Table Compiler parser (constants and math expressions)
63 * interpreter - Implicit and explicit conversions, GPE method names 68 * interpreter - Implicit and explicit conversions, GPE method names
64 * debugger - Command line input string conversion 69 * debugger - Command line input string conversion
65 * iASL - Main parser, conversion of constants to integers
66 * iASL - Data Table Compiler parser (constant math expressions)
67 * iASL - Preprocessor (constant math expressions)
68 * acpi_dump - Input table addresses 70 * acpi_dump - Input table addresses
69 * acpi_exec - Testing of the acpi_ut_strtoul64 function 71 * acpi_exec - Testing of the acpi_ut_strtoul64 function
70 * 72 *
@@ -77,15 +79,17 @@ ACPI_MODULE_NAME("utstrtoul64")
77 * a 64-bit constant is wrongly defined in a 32-bit DSDT/SSDT. 79 * a 64-bit constant is wrongly defined in a 32-bit DSDT/SSDT.
78 * 80 *
79 * In ACPI, the only place where octal numbers are supported is within 81 * In ACPI, the only place where octal numbers are supported is within
80 * the ASL language itself. There is no runtime support for octal. 82 * the ASL language itself. This is implemented via the main acpi_ut_strtoul64
83 * interface. According the ACPI specification, there is no ACPI runtime
84 * support for octal string conversions.
81 * 85 *
82 ******************************************************************************/ 86 ******************************************************************************/
83/******************************************************************************* 87/*******************************************************************************
84 * 88 *
85 * FUNCTION: acpi_ut_strtoul64 89 * FUNCTION: acpi_ut_strtoul64
86 * 90 *
87 * PARAMETERS: string - Null terminated input string. 91 * PARAMETERS: string - Null terminated input string,
88 * Must be a valid pointer 92 * must be a valid pointer
89 * return_value - Where the converted integer is 93 * return_value - Where the converted integer is
90 * returned. Must be a valid pointer 94 * returned. Must be a valid pointer
91 * 95 *
@@ -98,9 +102,9 @@ ACPI_MODULE_NAME("utstrtoul64")
98 * 102 *
99 * Current users of this function: 103 * Current users of this function:
100 * 104 *
101 * iASL - Preprocessor (constant math expressions) 105 * iASL - Preprocessor (constants and math expressions)
102 * iASL - Main parser, conversion of ASL constants to integers 106 * iASL - Main ASL parser, conversion of ASL constants to integers
103 * iASL - Data Table Compiler parser (constant math expressions) 107 * iASL - Data Table Compiler parser (constants and math expressions)
104 * 108 *
105 ******************************************************************************/ 109 ******************************************************************************/
106acpi_status acpi_ut_strtoul64(char *string, u64 *return_value) 110acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
@@ -112,17 +116,14 @@ acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
112 116
113 *return_value = 0; 117 *return_value = 0;
114 118
115 /* Null return string returns a value of zero */ 119 /* A NULL return string returns a value of zero */
116 120
117 if (*string == 0) { 121 if (*string == 0) {
118 return_ACPI_STATUS(AE_OK); 122 return_ACPI_STATUS(AE_OK);
119 } 123 }
120 124
121 /* 125 /*
122 * 1) The "0x" prefix indicates base 16. Per the ACPI specification, 126 * 1) Check for a hex constant. A "0x" prefix indicates base 16.
123 * the "0x" prefix is only allowed for implicit (non-strict) conversions.
124 * However, we always allow it for compatibility with older ACPICA and
125 * just plain on principle.
126 */ 127 */
127 if (acpi_ut_detect_hex_prefix(&string)) { 128 if (acpi_ut_detect_hex_prefix(&string)) {
128 base = 16; 129 base = 16;
@@ -130,7 +131,7 @@ acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
130 131
131 /* 132 /*
132 * 2) Check for an octal constant, defined to be a leading zero 133 * 2) Check for an octal constant, defined to be a leading zero
133 * followed by an valid octal digit (0-7) 134 * followed by sequence of octal digits (0-7)
134 */ 135 */
135 else if (acpi_ut_detect_octal_prefix(&string)) { 136 else if (acpi_ut_detect_octal_prefix(&string)) {
136 base = 8; 137 base = 8;
@@ -142,7 +143,7 @@ acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
142 143
143 /* 144 /*
144 * Perform the base 8, 10, or 16 conversion. A numeric overflow will 145 * Perform the base 8, 10, or 16 conversion. A numeric overflow will
145 * return an exception. 146 * return an exception (to allow iASL to flag the statement).
146 */ 147 */
147 switch (base) { 148 switch (base) {
148 case 8: 149 case 8:
@@ -154,11 +155,8 @@ acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
154 break; 155 break;
155 156
156 case 16: 157 case 16:
157 status = acpi_ut_convert_hex_string(string, return_value);
158 break;
159
160 default: 158 default:
161 status = AE_AML_INTERNAL; /* Should never happen */ 159 status = acpi_ut_convert_hex_string(string, return_value);
162 break; 160 break;
163 } 161 }
164 162
@@ -169,8 +167,8 @@ acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
169 * 167 *
170 * FUNCTION: acpi_ut_implicit_strtoul64 168 * FUNCTION: acpi_ut_implicit_strtoul64
171 * 169 *
172 * PARAMETERS: string - Null terminated input string. 170 * PARAMETERS: string - Null terminated input string,
173 * Must be a valid pointer 171 * must be a valid pointer
174 * 172 *
175 * RETURN: Converted integer 173 * RETURN: Converted integer
176 * 174 *
@@ -178,42 +176,44 @@ acpi_status acpi_ut_strtoul64(char *string, u64 *return_value)
178 * an "implicit conversion" by the ACPI specification. Used by 176 * an "implicit conversion" by the ACPI specification. Used by
179 * many ASL operators that require an integer operand, and support 177 * many ASL operators that require an integer operand, and support
180 * an automatic (implicit) conversion from a string operand 178 * an automatic (implicit) conversion from a string operand
181 * to the final integer operand. The restriction is that only 179 * to the final integer operand. The major restriction is that
182 * hex strings are supported. 180 * only hex strings are supported.
183 * 181 *
184 * ----------------------------------------------------------------------------- 182 * -----------------------------------------------------------------------------
185 * 183 *
186 * Base is always 16, either with or without the 0x prefix. 184 * Base is always 16, either with or without the 0x prefix. Decimal and
185 * Octal strings are not supported, as per the ACPI specification.
187 * 186 *
188 * Examples (both are hex values): 187 * Examples (both are hex values):
189 * Add ("BA98", Arg0, Local0) 188 * Add ("BA98", Arg0, Local0)
190 * Subtract ("0x12345678", Arg1, Local1) 189 * Subtract ("0x12345678", Arg1, Local1)
191 * 190 *
192 * Rules extracted from the ACPI specification: 191 * Conversion rules as extracted from the ACPI specification:
193 * 192 *
194 * The converted integer is initialized to the value zero. 193 * The converted integer is initialized to the value zero.
195 * The ASCII string is interpreted as a hexadecimal constant. 194 * The ASCII string is always interpreted as a hexadecimal constant.
196 * 195 *
197 * 1) A "0x" prefix is not allowed. However, ACPICA allows this as an 196 * 1) According to the ACPI specification, a "0x" prefix is not allowed.
198 * ACPI extension on general principle. (NO ERROR) 197 * However, ACPICA allows this as an ACPI extension on general
198 * principle. (NO ERROR)
199 * 199 *
200 * 2) Terminates when the size of an integer is reached (32 or 64 bits). 200 * 2) The conversion terminates when the size of an integer is reached
201 * There are no numeric overflow conditions. (NO ERROR) 201 * (32 or 64 bits). There are no numeric overflow conditions. (NO ERROR)
202 * 202 *
203 * 3) The first non-hex character terminates the conversion and returns 203 * 3) The first non-hex character terminates the conversion and returns
204 * the current accumulated value of the converted integer (NO ERROR). 204 * the current accumulated value of the converted integer (NO ERROR).
205 * 205 *
206 * 4) Conversion of a null (zero-length) string to an integer is 206 * 4) Conversion of a null (zero-length) string to an integer is
207 * technically allowed. However, ACPICA allows as an ACPI extension. 207 * technically not allowed. However, ACPICA allows this as an ACPI
208 * The conversion returns the value 0. (NO ERROR) 208 * extension. The conversion returns the value 0. (NO ERROR)
209 * 209 *
210 * Note: there are no error conditions returned by this function. At 210 * NOTE: There are no error conditions returned by this function. At
211 * the minimum, a value of zero is returned. 211 * the minimum, a value of zero is returned.
212 * 212 *
213 * Current users of this function: 213 * Current users of this function:
214 * 214 *
215 * interpreter - All runtime implicit conversions, as per ACPI specification 215 * interpreter - All runtime implicit conversions, as per ACPI specification
216 * iASL - Data Table Compiler parser (constant math expressions) 216 * iASL - Data Table Compiler parser (constants and math expressions)
217 * 217 *
218 ******************************************************************************/ 218 ******************************************************************************/
219 219
@@ -247,8 +247,8 @@ u64 acpi_ut_implicit_strtoul64(char *string)
247 * 247 *
248 * FUNCTION: acpi_ut_explicit_strtoul64 248 * FUNCTION: acpi_ut_explicit_strtoul64
249 * 249 *
250 * PARAMETERS: string - Null terminated input string. 250 * PARAMETERS: string - Null terminated input string,
251 * Must be a valid pointer 251 * must be a valid pointer
252 * 252 *
253 * RETURN: Converted integer 253 * RETURN: Converted integer
254 * 254 *
@@ -258,16 +258,16 @@ u64 acpi_ut_implicit_strtoul64(char *string)
258 * 258 *
259 * ----------------------------------------------------------------------------- 259 * -----------------------------------------------------------------------------
260 * 260 *
261 * Base is either 10 (default) or 16 (with 0x prefix). There is no octal 261 * Base is either 10 (default) or 16 (with 0x prefix). Octal (base 8) strings
262 * (base 8), as per the ACPI specification. 262 * are not supported, as per the ACPI specification.
263 * 263 *
264 * Examples: 264 * Examples:
265 * to_integer ("1000") Decimal 265 * to_integer ("1000") Decimal
266 * to_integer ("0xABCD") Hex 266 * to_integer ("0xABCD") Hex
267 * 267 *
268 * Rules extracted from the ACPI specification: 268 * Conversion rules as extracted from the ACPI specification:
269 * 269 *
270 * 1) Thi input string is either a decimal or hexadecimal numeric string. 270 * 1) The input string is either a decimal or hexadecimal numeric string.
271 * A hex value must be prefixed by "0x" or it is interpreted as decimal. 271 * A hex value must be prefixed by "0x" or it is interpreted as decimal.
272 * 272 *
273 * 2) The value must not exceed the maximum of an integer value 273 * 2) The value must not exceed the maximum of an integer value
@@ -275,18 +275,18 @@ u64 acpi_ut_implicit_strtoul64(char *string)
275 * "unpredictable", so ACPICA matches the behavior of the implicit 275 * "unpredictable", so ACPICA matches the behavior of the implicit
276 * conversion case. There are no numeric overflow conditions. (NO ERROR) 276 * conversion case. There are no numeric overflow conditions. (NO ERROR)
277 * 277 *
278 * 3) Behavior on the first non-hex character is not specified by the ACPI 278 * 3) Behavior on the first non-hex character is not defined by the ACPI
279 * specification (for the to_integer operator), so ACPICA matches the 279 * specification (for the to_integer operator), so ACPICA matches the
280 * behavior of the implicit conversion case. It terminates the 280 * behavior of the implicit conversion case. It terminates the
281 * conversion and returns the current accumulated value of the converted 281 * conversion and returns the current accumulated value of the converted
282 * integer. (NO ERROR) 282 * integer. (NO ERROR)
283 * 283 *
284 * 4) Conversion of a null (zero-length) string to an integer is 284 * 4) Conversion of a null (zero-length) string to an integer is
285 * technically allowed. However, ACPICA allows as an ACPI extension. 285 * technically not allowed. However, ACPICA allows this as an ACPI
286 * The conversion returns the value 0. (NO ERROR) 286 * extension. The conversion returns the value 0. (NO ERROR)
287 * 287 *
288 * Note: there are no error conditions returned by this function. At 288 * NOTE: There are no error conditions returned by this function. At the
289 * the minimum, a value of zero is returned. 289 * minimum, a value of zero is returned.
290 * 290 *
291 * Current users of this function: 291 * Current users of this function:
292 * 292 *
@@ -303,7 +303,7 @@ u64 acpi_ut_explicit_strtoul64(char *string)
303 303
304 /* 304 /*
305 * Only Hex and Decimal are supported, as per the ACPI specification. 305 * Only Hex and Decimal are supported, as per the ACPI specification.
306 * 0x prefix means hex; otherwise decimal is assumed. 306 * A "0x" prefix indicates hex; otherwise decimal is assumed.
307 */ 307 */
308 if (acpi_ut_detect_hex_prefix(&string)) { 308 if (acpi_ut_detect_hex_prefix(&string)) {
309 base = 16; 309 base = 16;