aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exconvrt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/executer/exconvrt.c')
-rw-r--r--drivers/acpi/executer/exconvrt.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 261d97516d9b..1d1f35adddde 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -57,7 +57,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer,
57 * 57 *
58 * FUNCTION: acpi_ex_convert_to_integer 58 * FUNCTION: acpi_ex_convert_to_integer
59 * 59 *
60 * PARAMETERS: obj_desc - Object to be converted. Must be an 60 * PARAMETERS: obj_desc - Object to be converted. Must be an
61 * Integer, Buffer, or String 61 * Integer, Buffer, or String
62 * result_desc - Where the new Integer object is returned 62 * result_desc - Where the new Integer object is returned
63 * Flags - Used for string conversion 63 * Flags - Used for string conversion
@@ -103,7 +103,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
103 } 103 }
104 104
105 /* 105 /*
106 * Convert the buffer/string to an integer. Note that both buffers and 106 * Convert the buffer/string to an integer. Note that both buffers and
107 * strings are treated as raw data - we don't convert ascii to hex for 107 * strings are treated as raw data - we don't convert ascii to hex for
108 * strings. 108 * strings.
109 * 109 *
@@ -120,7 +120,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
120 120
121 /* 121 /*
122 * Convert string to an integer - for most cases, the string must be 122 * Convert string to an integer - for most cases, the string must be
123 * hexadecimal as per the ACPI specification. The only exception (as 123 * hexadecimal as per the ACPI specification. The only exception (as
124 * of ACPI 3.0) is that the to_integer() operator allows both decimal 124 * of ACPI 3.0) is that the to_integer() operator allows both decimal
125 * and hexadecimal strings (hex prefixed with "0x"). 125 * and hexadecimal strings (hex prefixed with "0x").
126 */ 126 */
@@ -159,6 +159,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
159 break; 159 break;
160 160
161 default: 161 default:
162
162 /* No other types can get here */ 163 /* No other types can get here */
163 break; 164 break;
164 } 165 }
@@ -185,7 +186,7 @@ acpi_ex_convert_to_integer(union acpi_operand_object *obj_desc,
185 * 186 *
186 * FUNCTION: acpi_ex_convert_to_buffer 187 * FUNCTION: acpi_ex_convert_to_buffer
187 * 188 *
188 * PARAMETERS: obj_desc - Object to be converted. Must be an 189 * PARAMETERS: obj_desc - Object to be converted. Must be an
189 * Integer, Buffer, or String 190 * Integer, Buffer, or String
190 * result_desc - Where the new buffer object is returned 191 * result_desc - Where the new buffer object is returned
191 * 192 *
@@ -365,7 +366,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer,
365 } 366 }
366 367
367 /* 368 /*
368 * Since leading zeros are supressed, we must check for the case where 369 * Since leading zeros are suppressed, we must check for the case where
369 * the integer equals 0 370 * the integer equals 0
370 * 371 *
371 * Finally, null terminate the string and return the length 372 * Finally, null terminate the string and return the length
@@ -383,7 +384,7 @@ acpi_ex_convert_to_ascii(acpi_integer integer,
383 * 384 *
384 * FUNCTION: acpi_ex_convert_to_string 385 * FUNCTION: acpi_ex_convert_to_string
385 * 386 *
386 * PARAMETERS: obj_desc - Object to be converted. Must be an 387 * PARAMETERS: obj_desc - Object to be converted. Must be an
387 * Integer, Buffer, or String 388 * Integer, Buffer, or String
388 * result_desc - Where the string object is returned 389 * result_desc - Where the string object is returned
389 * Type - String flags (base and conversion type) 390 * Type - String flags (base and conversion type)
@@ -472,7 +473,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
472 base = 10; 473 base = 10;
473 474
474 /* 475 /*
475 * Calculate the final string length. Individual string values 476 * Calculate the final string length. Individual string values
476 * are variable length (include separator for each) 477 * are variable length (include separator for each)
477 */ 478 */
478 for (i = 0; i < obj_desc->buffer.length; i++) { 479 for (i = 0; i < obj_desc->buffer.length; i++) {
@@ -511,9 +512,14 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
511 /* 512 /*
512 * Create a new string object and string buffer 513 * Create a new string object and string buffer
513 * (-1 because of extra separator included in string_length from above) 514 * (-1 because of extra separator included in string_length from above)
515 * Allow creation of zero-length strings from zero-length buffers.
514 */ 516 */
517 if (string_length) {
518 string_length--;
519 }
520
515 return_desc = acpi_ut_create_string_object((acpi_size) 521 return_desc = acpi_ut_create_string_object((acpi_size)
516 (string_length - 1)); 522 string_length);
517 if (!return_desc) { 523 if (!return_desc) {
518 return_ACPI_STATUS(AE_NO_MEMORY); 524 return_ACPI_STATUS(AE_NO_MEMORY);
519 } 525 }
@@ -536,7 +542,9 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
536 * Null terminate the string 542 * Null terminate the string
537 * (overwrites final comma/space from above) 543 * (overwrites final comma/space from above)
538 */ 544 */
539 new_buf--; 545 if (obj_desc->buffer.length) {
546 new_buf--;
547 }
540 *new_buf = 0; 548 *new_buf = 0;
541 break; 549 break;
542 550
@@ -617,7 +625,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
617 case ACPI_TYPE_LOCAL_BANK_FIELD: 625 case ACPI_TYPE_LOCAL_BANK_FIELD:
618 case ACPI_TYPE_LOCAL_INDEX_FIELD: 626 case ACPI_TYPE_LOCAL_INDEX_FIELD:
619 /* 627 /*
620 * These types require an Integer operand. We can convert 628 * These types require an Integer operand. We can convert
621 * a Buffer or a String to an Integer if necessary. 629 * a Buffer or a String to an Integer if necessary.
622 */ 630 */
623 status = 631 status =
@@ -627,7 +635,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
627 635
628 case ACPI_TYPE_STRING: 636 case ACPI_TYPE_STRING:
629 /* 637 /*
630 * The operand must be a String. We can convert an 638 * The operand must be a String. We can convert an
631 * Integer or Buffer if necessary 639 * Integer or Buffer if necessary
632 */ 640 */
633 status = 641 status =
@@ -637,7 +645,7 @@ acpi_ex_convert_to_target_type(acpi_object_type destination_type,
637 645
638 case ACPI_TYPE_BUFFER: 646 case ACPI_TYPE_BUFFER:
639 /* 647 /*
640 * The operand must be a Buffer. We can convert an 648 * The operand must be a Buffer. We can convert an
641 * Integer or String if necessary 649 * Integer or String if necessary
642 */ 650 */
643 status = 651 status =