aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2014-07-07 22:08:13 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-08 08:22:27 -0400
commitff2389fe662460c71e4ee221cc223b175c231246 (patch)
tree44aa08ad98bc8f0989653b45fe6f086542a091d2 /drivers/acpi/acpica
parentc04691292ff75a3560279bcafb1be0848ae82c23 (diff)
ACPICA: utprint/oslibcfs: cleanup - no functional change
Some cleanup and comment update. 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>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r--drivers/acpi/acpica/utprint.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c
index 9d5293fd992f..10311648f701 100644
--- a/drivers/acpi/acpica/utprint.c
+++ b/drivers/acpi/acpica/utprint.c
@@ -67,6 +67,11 @@ static char *acpi_ut_format_number(char *string,
67 67
68static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper); 68static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper);
69 69
70/* Module globals */
71
72static const char acpi_gbl_lower_hex_digits[] = "0123456789abcdef";
73static const char acpi_gbl_upper_hex_digits[] = "0123456789ABCDEF";
74
70/******************************************************************************* 75/*******************************************************************************
71 * 76 *
72 * FUNCTION: acpi_ut_bound_string_length 77 * FUNCTION: acpi_ut_bound_string_length
@@ -74,7 +79,7 @@ static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper);
74 * PARAMETERS: string - String with boundary 79 * PARAMETERS: string - String with boundary
75 * count - Boundary of the string 80 * count - Boundary of the string
76 * 81 *
77 * RETURN: Length of the string. 82 * RETURN: Length of the string. Less than or equal to Count.
78 * 83 *
79 * DESCRIPTION: Calculate the length of a string with boundary. 84 * DESCRIPTION: Calculate the length of a string with boundary.
80 * 85 *
@@ -114,8 +119,8 @@ static char *acpi_ut_bound_string_output(char *string, const char *end, char c)
114 if (string < end) { 119 if (string < end) {
115 *string = c; 120 *string = c;
116 } 121 }
117 ++string;
118 122
123 ++string;
119 return (string); 124 return (string);
120} 125}
121 126
@@ -137,14 +142,12 @@ static char *acpi_ut_bound_string_output(char *string, const char *end, char c)
137 142
138static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper) 143static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper)
139{ 144{
140 const char lower_digits[] = "0123456789abcdef";
141 const char upper_digits[] = "0123456789ABCDEF";
142 const char *digits; 145 const char *digits;
143 u64 digit_index; 146 u64 digit_index;
144 char *pos; 147 char *pos;
145 148
146 pos = string; 149 pos = string;
147 digits = upper ? upper_digits : lower_digits; 150 digits = upper ? acpi_gbl_upper_hex_digits : acpi_gbl_lower_hex_digits;
148 151
149 if (number == 0) { 152 if (number == 0) {
150 *(pos++) = '0'; 153 *(pos++) = '0';
@@ -155,8 +158,8 @@ static char *acpi_ut_put_number(char *string, u64 number, u8 base, u8 upper)
155 *(pos++) = digits[digit_index]; 158 *(pos++) = digits[digit_index];
156 } 159 }
157 } 160 }
158 /* *(Pos++) = '0'; */
159 161
162 /* *(Pos++) = '0'; */
160 return (pos); 163 return (pos);
161} 164}
162 165
@@ -181,8 +184,8 @@ const char *acpi_ut_scan_number(const char *string, u64 *number_ptr)
181 number *= 10; 184 number *= 10;
182 number += *(string++) - '0'; 185 number += *(string++) - '0';
183 } 186 }
184 *number_ptr = number;
185 187
188 *number_ptr = number;
186 return (string); 189 return (string);
187} 190}
188 191
@@ -211,8 +214,8 @@ const char *acpi_ut_print_number(char *string, u64 number)
211 while (pos1 != ascii_string) { 214 while (pos1 != ascii_string) {
212 *(pos2++) = *(--pos1); 215 *(pos2++) = *(--pos1);
213 } 216 }
214 *pos2 = 0;
215 217
218 *pos2 = 0;
216 return (string); 219 return (string);
217} 220}
218 221
@@ -246,11 +249,12 @@ static char *acpi_ut_format_number(char *string,
246 s32 i; 249 s32 i;
247 char reversed_string[66]; 250 char reversed_string[66];
248 251
249 /* Perform sanity checks */ 252 /* Parameter validation */
250 253
251 if (base < 2 || base > 16) { 254 if (base < 2 || base > 16) {
252 return NULL; 255 return (NULL);
253 } 256 }
257
254 if (type & ACPI_FORMAT_LEFT) { 258 if (type & ACPI_FORMAT_LEFT) {
255 type &= ~ACPI_FORMAT_ZERO; 259 type &= ~ACPI_FORMAT_ZERO;
256 } 260 }
@@ -294,6 +298,7 @@ static char *acpi_ut_format_number(char *string,
294 if (i > precision) { 298 if (i > precision) {
295 precision = i; 299 precision = i;
296 } 300 }
301
297 width -= precision; 302 width -= precision;
298 303
299 /* Output the string */ 304 /* Output the string */
@@ -318,6 +323,7 @@ static char *acpi_ut_format_number(char *string,
318 string = acpi_ut_bound_string_output(string, end, zero); 323 string = acpi_ut_bound_string_output(string, end, zero);
319 } 324 }
320 } 325 }
326
321 while (i <= --precision) { 327 while (i <= --precision) {
322 string = acpi_ut_bound_string_output(string, end, '0'); 328 string = acpi_ut_bound_string_output(string, end, '0');
323 } 329 }
@@ -341,7 +347,7 @@ static char *acpi_ut_format_number(char *string,
341 * format - Standard printf format 347 * format - Standard printf format
342 * args - Argument list 348 * args - Argument list
343 * 349 *
344 * RETURN: Size of successfully output bytes 350 * RETURN: Number of bytes actually written.
345 * 351 *
346 * DESCRIPTION: Formatted output to a string using argument list pointer. 352 * DESCRIPTION: Formatted output to a string using argument list pointer.
347 * 353 *
@@ -428,6 +434,7 @@ acpi_ut_vsnprintf(char *string,
428 if (*format == 'h' || *format == 'l' || *format == 'L') { 434 if (*format == 'h' || *format == 'l' || *format == 'L') {
429 qualifier = *format; 435 qualifier = *format;
430 ++format; 436 ++format;
437
431 if (qualifier == 'l' && *format == 'l') { 438 if (qualifier == 'l' && *format == 'l') {
432 qualifier = 'L'; 439 qualifier = 'L';
433 ++format; 440 ++format;
@@ -450,8 +457,10 @@ acpi_ut_vsnprintf(char *string,
450 ' '); 457 ' ');
451 } 458 }
452 } 459 }
460
453 c = (char)va_arg(args, int); 461 c = (char)va_arg(args, int);
454 pos = acpi_ut_bound_string_output(pos, end, c); 462 pos = acpi_ut_bound_string_output(pos, end, c);
463
455 while (--width > 0) { 464 while (--width > 0) {
456 pos = 465 pos =
457 acpi_ut_bound_string_output(pos, end, ' '); 466 acpi_ut_bound_string_output(pos, end, ' ');
@@ -512,10 +521,11 @@ acpi_ut_vsnprintf(char *string,
512 width = 2 * sizeof(void *); 521 width = 2 * sizeof(void *);
513 type |= ACPI_FORMAT_ZERO; 522 type |= ACPI_FORMAT_ZERO;
514 } 523 }
524
515 p = va_arg(args, void *); 525 p = va_arg(args, void *);
516 pos = acpi_ut_format_number(pos, end, 526 pos = acpi_ut_format_number(pos, end,
517 ACPI_TO_INTEGER(p), 527 ACPI_TO_INTEGER(p), 16,
518 16, width, precision, type); 528 width, precision, type);
519 continue; 529 continue;
520 530
521 default: 531 default:
@@ -552,6 +562,7 @@ acpi_ut_vsnprintf(char *string,
552 number = (signed int)number; 562 number = (signed int)number;
553 } 563 }
554 } 564 }
565
555 pos = acpi_ut_format_number(pos, end, number, base, 566 pos = acpi_ut_format_number(pos, end, number, base,
556 width, precision, type); 567 width, precision, type);
557 } 568 }
@@ -575,7 +586,7 @@ acpi_ut_vsnprintf(char *string,
575 * size - Boundary of the string 586 * size - Boundary of the string
576 * Format, ... - Standard printf format 587 * Format, ... - Standard printf format
577 * 588 *
578 * RETURN: Size of successfully output bytes 589 * RETURN: Number of bytes actually written.
579 * 590 *
580 * DESCRIPTION: Formatted output to a string. 591 * DESCRIPTION: Formatted output to a string.
581 * 592 *
@@ -602,7 +613,7 @@ int acpi_ut_snprintf(char *string, acpi_size size, const char *format, ...)
602 * format - Standard printf format 613 * format - Standard printf format
603 * args - Argument list 614 * args - Argument list
604 * 615 *
605 * RETURN: Size of successfully output bytes 616 * RETURN: Number of bytes actually written.
606 * 617 *
607 * DESCRIPTION: Formatted output to a file using argument list pointer. 618 * DESCRIPTION: Formatted output to a file using argument list pointer.
608 * 619 *
@@ -616,6 +627,7 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)
616 flags = acpi_os_acquire_lock(acpi_gbl_print_lock); 627 flags = acpi_os_acquire_lock(acpi_gbl_print_lock);
617 length = acpi_ut_vsnprintf(acpi_gbl_print_buffer, 628 length = acpi_ut_vsnprintf(acpi_gbl_print_buffer,
618 sizeof(acpi_gbl_print_buffer), format, args); 629 sizeof(acpi_gbl_print_buffer), format, args);
630
619 (void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1); 631 (void)acpi_os_write_file(file, acpi_gbl_print_buffer, length, 1);
620 acpi_os_release_lock(acpi_gbl_print_lock, flags); 632 acpi_os_release_lock(acpi_gbl_print_lock, flags);
621 633
@@ -629,7 +641,7 @@ int acpi_ut_file_vprintf(ACPI_FILE file, const char *format, va_list args)
629 * PARAMETERS: file - File descriptor 641 * PARAMETERS: file - File descriptor
630 * Format, ... - Standard printf format 642 * Format, ... - Standard printf format
631 * 643 *
632 * RETURN: Size of successfully output bytes 644 * RETURN: Number of bytes actually written.
633 * 645 *
634 * DESCRIPTION: Formatted output to a file. 646 * DESCRIPTION: Formatted output to a file.
635 * 647 *