@@ -17,7 +17,8 @@ ACPI_MODULE_NAME("exconvrt")
17
17
18
18
/* Local prototypes */
19
19
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 );
21
22
22
23
/*******************************************************************************
23
24
*
@@ -249,6 +250,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
249
250
* base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
250
251
* string - Where the string is returned
251
252
* data_width - Size of data item to be converted, in bytes
253
+ * leading_zeros - Allow leading zeros
252
254
*
253
255
* RETURN: Actual string length
254
256
*
@@ -257,7 +259,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
257
259
******************************************************************************/
258
260
259
261
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 )
261
264
{
262
265
u64 digit ;
263
266
u32 i ;
@@ -266,7 +269,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
266
269
u32 hex_length ;
267
270
u32 decimal_length ;
268
271
u32 remainder ;
269
- u8 supress_zeros ;
272
+ u8 supress_zeros = ! leading_zeros ;
270
273
271
274
ACPI_FUNCTION_ENTRY ();
272
275
@@ -293,7 +296,6 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
293
296
break ;
294
297
}
295
298
296
- supress_zeros = TRUE; /* No leading zeros */
297
299
remainder = 0 ;
298
300
299
301
for (i = decimal_length ; i > 0 ; i -- ) {
@@ -379,6 +381,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
379
381
u32 string_length = 0 ;
380
382
u16 base = 16 ;
381
383
u8 separator = ',' ;
384
+ u8 leading_zeros ;
382
385
383
386
ACPI_FUNCTION_TRACE_PTR (ex_convert_to_string , obj_desc );
384
387
@@ -400,6 +403,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
400
403
* Make room for the maximum decimal number size
401
404
*/
402
405
string_length = ACPI_MAX_DECIMAL_DIGITS ;
406
+ leading_zeros = FALSE;
403
407
base = 10 ;
404
408
break ;
405
409
@@ -408,6 +412,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
408
412
/* Two hex string characters for each integer byte */
409
413
410
414
string_length = ACPI_MUL_2 (acpi_gbl_integer_byte_width );
415
+ leading_zeros = TRUE;
411
416
break ;
412
417
}
413
418
@@ -428,7 +433,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
428
433
string_length =
429
434
acpi_ex_convert_to_ascii (obj_desc -> integer .value , base ,
430
435
new_buf ,
431
- acpi_gbl_integer_byte_width );
436
+ acpi_gbl_integer_byte_width ,
437
+ leading_zeros );
432
438
433
439
/* Null terminate at the correct place */
434
440
@@ -448,6 +454,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
448
454
* From ACPI: "If the input is a buffer, it is converted to a
449
455
* a string of decimal values separated by commas."
450
456
*/
457
+ leading_zeros = FALSE;
451
458
base = 10 ;
452
459
453
460
/*
@@ -475,6 +482,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
475
482
*
476
483
* Each hex number is prefixed with 0x (11/2018)
477
484
*/
485
+ leading_zeros = TRUE;
478
486
separator = ' ' ;
479
487
string_length = (obj_desc -> buffer .length * 5 );
480
488
break ;
@@ -488,6 +496,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
488
496
*
489
497
* Each hex number is prefixed with 0x (11/2018)
490
498
*/
499
+ leading_zeros = TRUE;
491
500
separator = ',' ;
492
501
string_length = (obj_desc -> buffer .length * 5 );
493
502
break ;
@@ -528,7 +537,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
528
537
529
538
new_buf += acpi_ex_convert_to_ascii ((u64 ) obj_desc ->
530
539
buffer .pointer [i ],
531
- base , new_buf , 1 );
540
+ base , new_buf , 1 ,
541
+ leading_zeros );
532
542
533
543
/* Each digit is separated by either a comma or space */
534
544
0 commit comments