From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux ACPI <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Bob Moore <robert.moore@intel.com>,
Saket Dumbre <saket.dumbre@intel.com>
Subject: [PATCH v1 12/20] ACPICA: Allow for supressing leading zeros when using acpi_ex_convert_to_ascii()
Date: Thu, 29 Aug 2024 20:37:31 +0200 [thread overview]
Message-ID: <3510303.QJadu78ljV@rjwysocki.net> (raw)
In-Reply-To: <5819337.DvuYhMxLoT@rjwysocki.net>
From: Armin Wolf <W_Armin@gmx.de>
ACPICA commit 792a337104ce2c1729d33d76241b42b3214aa60f
Allow to specifiy wether leading zeros should be supressed
ot not when using acpi_ex_convert_to_ascii().
Link: https://github.com/acpica/acpica/commit/792a3371
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/acpi/acpica/exconvrt.c | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c
index 3729bf3b74f7..4e8ab3c26565 100644
--- a/drivers/acpi/acpica/exconvrt.c
+++ b/drivers/acpi/acpica/exconvrt.c
@@ -17,7 +17,8 @@ ACPI_MODULE_NAME("exconvrt")
/* Local prototypes */
static u32
-acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 max_length);
+acpi_ex_convert_to_ascii(u64 integer,
+ u16 base, u8 *string, u8 max_length, u8 leading_zeros);
/*******************************************************************************
*
@@ -249,6 +250,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
* base - ACPI_STRING_DECIMAL or ACPI_STRING_HEX
* string - Where the string is returned
* data_width - Size of data item to be converted, in bytes
+ * leading_zeros - Allow leading zeros
*
* RETURN: Actual string length
*
@@ -257,7 +259,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
******************************************************************************/
static u32
-acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
+acpi_ex_convert_to_ascii(u64 integer,
+ u16 base, u8 *string, u8 data_width, u8 leading_zeros)
{
u64 digit;
u32 i;
@@ -266,7 +269,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
u32 hex_length;
u32 decimal_length;
u32 remainder;
- u8 supress_zeros;
+ u8 supress_zeros = !leading_zeros;
ACPI_FUNCTION_ENTRY();
@@ -293,7 +296,6 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width)
break;
}
- supress_zeros = TRUE; /* No leading zeros */
remainder = 0;
for (i = decimal_length; i > 0; i--) {
@@ -379,6 +381,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
u32 string_length = 0;
u16 base = 16;
u8 separator = ',';
+ u8 leading_zeros;
ACPI_FUNCTION_TRACE_PTR(ex_convert_to_string, obj_desc);
@@ -400,6 +403,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
* Make room for the maximum decimal number size
*/
string_length = ACPI_MAX_DECIMAL_DIGITS;
+ leading_zeros = FALSE;
base = 10;
break;
@@ -408,6 +412,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
/* Two hex string characters for each integer byte */
string_length = ACPI_MUL_2(acpi_gbl_integer_byte_width);
+ leading_zeros = TRUE;
break;
}
@@ -428,7 +433,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
string_length =
acpi_ex_convert_to_ascii(obj_desc->integer.value, base,
new_buf,
- acpi_gbl_integer_byte_width);
+ acpi_gbl_integer_byte_width,
+ leading_zeros);
/* Null terminate at the correct place */
@@ -448,6 +454,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
* From ACPI: "If the input is a buffer, it is converted to a
* a string of decimal values separated by commas."
*/
+ leading_zeros = FALSE;
base = 10;
/*
@@ -475,6 +482,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
*
* Each hex number is prefixed with 0x (11/2018)
*/
+ leading_zeros = TRUE;
separator = ' ';
string_length = (obj_desc->buffer.length * 5);
break;
@@ -488,6 +496,7 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
*
* Each hex number is prefixed with 0x (11/2018)
*/
+ leading_zeros = TRUE;
separator = ',';
string_length = (obj_desc->buffer.length * 5);
break;
@@ -528,7 +537,8 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
buffer.pointer[i],
- base, new_buf, 1);
+ base, new_buf, 1,
+ leading_zeros);
/* Each digit is separated by either a comma or space */
--
2.43.0
next prev parent reply other threads:[~2024-08-29 18:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-29 18:18 [PATCH v1 00/20] ACPICA: Release 20240827 Rafael J. Wysocki
2024-08-29 18:21 ` [PATCH v1 01/20] ACPICA: haiku: Fix invalid value used for semaphores Rafael J. Wysocki
2024-08-29 18:22 ` [PATCH v1 02/20] ACPICA: Complete CXL 3.0 CXIMS structures Rafael J. Wysocki
2024-08-29 18:27 ` [PATCH v1 03/20] ACPICA: SPCR: Update the SPCR table to version 4 Rafael J. Wysocki
2024-08-29 18:28 ` [PATCH v1 04/20] ACPICA: Headers: Add RISC-V SBI Subtype to DBG2 Rafael J. Wysocki
2024-08-29 18:29 ` [PATCH v1 05/20] ACPICA: Implement the Dword_PCC Resource Descriptor Macro Rafael J. Wysocki
2024-08-29 18:30 ` [PATCH v1 06/20] ACPICA: MPAM: Correct the typo in struct acpi_mpam_msc_node member Rafael J. Wysocki
2024-08-29 18:31 ` [PATCH v1 07/20] ACPICA: Implement ACPI_WARNING_ONCE and ACPI_ERROR_ONCE Rafael J. Wysocki
2024-08-29 18:32 ` [PATCH v1 08/20] ACPICA: executer/exsystem: Don't nag user about every Stall() violating the spec Rafael J. Wysocki
2024-08-29 18:34 ` [PATCH v1 09/20] ACPICA: Allow PCC Data Type in MCTP resource Rafael J. Wysocki
2024-08-29 18:35 ` [PATCH v1 10/20] ACPICA: Fix memory leak if acpi_ps_get_next_namepath() fails Rafael J. Wysocki
2024-08-29 18:36 ` [PATCH v1 11/20] ACPICA: Fix memory leak if acpi_ps_get_next_field() fails Rafael J. Wysocki
2024-08-29 18:37 ` Rafael J. Wysocki [this message]
2024-08-29 18:38 ` [PATCH v1 13/20] ACPICA: Add support for supressing leading zeros in hex strings Rafael J. Wysocki
2024-08-29 18:39 ` [PATCH v1 14/20] ACPICA: Update integer-to-hex-string conversions Rafael J. Wysocki
2024-08-29 18:40 ` [PATCH v1 15/20] ACPICA: Add support for Windows 11 22H2 _OSI string Rafael J. Wysocki
2024-08-29 18:41 ` [PATCH v1 16/20] ACPICA: Avoid warning for Dump Functions Rafael J. Wysocki
2024-08-29 18:41 ` [PATCH v1 17/20] ACPICA: HMAT: Add extended linear address mode to MSCIS Rafael J. Wysocki
2024-08-29 18:42 ` [PATCH v1 18/20] ACPICA: iasl: handle empty connection_node Rafael J. Wysocki
2024-08-29 18:43 ` [PATCH v1 19/20] ACPICA: Allow for more flexibility in _DSM args Rafael J. Wysocki
2024-08-29 18:44 ` [PATCH v1 20/20] ACPICA: Setup for ACPICA release 20240827 Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3510303.QJadu78ljV@rjwysocki.net \
--to=rjw@rjwysocki.net \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.moore@intel.com \
--cc=saket.dumbre@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox