Skip to content

Commit 76a09d9

Browse files
Wer-Wolfrafaeljw
authored andcommitted
ACPICA: Allow for supressing leading zeros when using acpi_ex_convert_to_ascii()
ACPICA commit 792a337104ce2c1729d33d76241b42b3214aa60f Allow to specifiy wether leading zeros should be supressed ot not when using acpi_ex_convert_to_ascii(). Link: acpica/acpica@792a3371 Signed-off-by: Armin Wolf <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent e6169a8 commit 76a09d9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

drivers/acpi/acpica/exconvrt.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ ACPI_MODULE_NAME("exconvrt")
1717

1818
/* Local prototypes */
1919
static u32
20-
acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
20+
acpi_ex_convert_to_ascii(u64 integer,
21+
u16 base, u8 *string, u8 max_length, u8 leading_zeros);
2122

2223
/*******************************************************************************
2324
*
@@ -249,6 +250,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
249250
* base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
250251
* string - Where the string is returned
251252
* data_width - Size of data item to be converted, in bytes
253+
* leading_zeros - Allow leading zeros
252254
*
253255
* RETURN: Actual string length
254256
*
@@ -257,7 +259,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
257259
******************************************************************************/
258260

259261
static u32
260-
acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
262+
acpi_ex_convert_to_ascii(u64 integer,
263+
u16 base, u8 *string, u8 data_width, u8 leading_zeros)
261264
{
262265
u64 digit;
263266
u32 i;
@@ -266,7 +269,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
266269
u32 hex_length;
267270
u32 decimal_length;
268271
u32 remainder;
269-
u8 supress_zeros;
272+
u8 supress_zeros = !leading_zeros;
270273

271274
ACPI_FUNCTION_ENTRY();
272275

@@ -293,7 +296,6 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
293296
break;
294297
}
295298

296-
supress_zeros = TRUE; /* No leading zeros */
297299
remainder = 0;
298300

299301
for (i = decimal_length; i > 0; i--) {
@@ -379,6 +381,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
379381
u32 string_length = 0;
380382
u16 base = 16;
381383
u8 separator = ',';
384+
u8 leading_zeros;
382385

383386
ACPI_FUNCTION_TRACE_PTR(ex_convert_to_string, obj_desc);
384387

@@ -400,6 +403,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
400403
* Make room for the maximum decimal number size
401404
*/
402405
string_length = ACPI_MAX_DECIMAL_DIGITS;
406+
leading_zeros = FALSE;
403407
base = 10;
404408
break;
405409

@@ -408,6 +412,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
408412
/* Two hex string characters for each integer byte */
409413

410414
string_length = ACPI_MUL_2(acpi_gbl_integer_byte_width);
415+
leading_zeros = TRUE;
411416
break;
412417
}
413418

@@ -428,7 +433,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
428433
string_length =
429434
acpi_ex_convert_to_ascii(obj_desc->integer.value, base,
430435
new_buf,
431-
acpi_gbl_integer_byte_width);
436+
acpi_gbl_integer_byte_width,
437+
leading_zeros);
432438

433439
/* Null terminate at the correct place */
434440

@@ -448,6 +454,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
448454
* From ACPI: "If the input is a buffer, it is converted to a
449455
* a string of decimal values separated by commas."
450456
*/
457+
leading_zeros = FALSE;
451458
base = 10;
452459

453460
/*
@@ -475,6 +482,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
475482
*
476483
* Each hex number is prefixed with 0x (11/2018)
477484
*/
485+
leading_zeros = TRUE;
478486
separator = ' ';
479487
string_length = (obj_desc->buffer.length * 5);
480488
break;
@@ -488,6 +496,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
488496
*
489497
* Each hex number is prefixed with 0x (11/2018)
490498
*/
499+
leading_zeros = TRUE;
491500
separator = ',';
492501
string_length = (obj_desc->buffer.length * 5);
493502
break;
@@ -528,7 +537,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
528537

529538
new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
530539
buffer.pointer[i],
531-
base, new_buf, 1);
540+
base, new_buf, 1,
541+
leading_zeros);
532542

533543
/* Each digit is separated by either a comma or space */
534544

0 commit comments

Comments
 (0)