From patchwork Thu Dec 13 20:30:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Schmauss, Erik" X-Patchwork-Id: 10729879 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A6EE91E for ; Thu, 13 Dec 2018 20:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CEE329D73 for ; Thu, 13 Dec 2018 20:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B8FD2BC6A; Thu, 13 Dec 2018 20:36:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 159CB29D73 for ; Thu, 13 Dec 2018 20:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727476AbeLMUgH (ORCPT ); Thu, 13 Dec 2018 15:36:07 -0500 Received: from mga18.intel.com ([134.134.136.126]:49812 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727455AbeLMUgH (ORCPT ); Thu, 13 Dec 2018 15:36:07 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Dec 2018 12:36:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,349,1539673200"; d="scan'208";a="301988697" Received: from bartok.jf.intel.com ([10.54.75.137]) by fmsmga006.fm.intel.com with ESMTP; 13 Dec 2018 12:36:05 -0800 From: Erik Schmauss To: rjw@rjwysocki.net, linux-acpi@vger.kernel.org Cc: Bob Moore , Erik Schmauss Subject: [PATCH 04/10] ACPICA: Update buffer-to-string conversions Date: Thu, 13 Dec 2018 12:30:29 -0800 Message-Id: <20181213203035.12387-5-erik.schmauss@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181213203035.12387-1-erik.schmauss@intel.com> References: <20181213203035.12387-1-erik.schmauss@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bob Moore Add "0x" prefix for hex values. Provides compatibility with other ACPI implementations. Signed-off-by: Bob Moore Signed-off-by: Erik Schmauss --- drivers/acpi/acpica/exconvrt.c | 49 +++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/drivers/acpi/acpica/exconvrt.c b/drivers/acpi/acpica/exconvrt.c index 98de48481776..1a70b80cc406 100644 --- a/drivers/acpi/acpica/exconvrt.c +++ b/drivers/acpi/acpica/exconvrt.c @@ -323,7 +323,7 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width) /* hex_length: 2 ascii hex chars per data byte */ - hex_length = ACPI_MUL_2(data_width); + hex_length = (data_width * 2); for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) { /* Get one hex digit, most significant digits first */ @@ -364,7 +364,8 @@ acpi_ex_convert_to_ascii(u64 integer, u16 base, u8 *string, u8 data_width) * * RETURN: Status * - * DESCRIPTION: Convert an ACPI Object to a string + * DESCRIPTION: Convert an ACPI Object to a string. Supports both implicit + * and explicit conversions and related rules. * ******************************************************************************/ @@ -393,9 +394,11 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, switch (type) { case ACPI_EXPLICIT_CONVERT_DECIMAL: - - /* Make room for maximum decimal number */ - + /* + * From to_decimal_string, integer source. + * + * Make room for the maximum decimal number size + */ string_length = ACPI_MAX_DECIMAL_DIGITS; base = 10; break; @@ -440,8 +443,10 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, switch (type) { case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */ /* - * From ACPI: "If Data is a buffer, it is converted to a string of - * decimal values separated by commas." + * Explicit conversion from the to_decimal_string ASL operator. + * + * From ACPI: "If the input is a buffer, it is converted to a + * a string of decimal values separated by commas." */ base = 10; @@ -462,20 +467,29 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, case ACPI_IMPLICIT_CONVERT_HEX: /* + * Implicit buffer-to-string conversion + * * From the ACPI spec: - *"The entire contents of the buffer are converted to a string of + * "The entire contents of the buffer are converted to a string of * two-character hexadecimal numbers, each separated by a space." + * + * Each hex number is prefixed with 0x (11/2018) */ separator = ' '; - string_length = (obj_desc->buffer.length * 3); + string_length = (obj_desc->buffer.length * 5); break; - case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */ + case ACPI_EXPLICIT_CONVERT_HEX: /* + * Explicit conversion from the to_hex_string ASL operator. + * * From ACPI: "If Data is a buffer, it is converted to a string of * hexadecimal values separated by commas." + * + * Each hex number is prefixed with 0x (11/2018) */ - string_length = (obj_desc->buffer.length * 3); + separator = ','; + string_length = (obj_desc->buffer.length * 5); break; default: @@ -504,10 +518,21 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc, * (separated by commas or spaces) */ for (i = 0; i < obj_desc->buffer.length; i++) { + if (base == 16) { + + /* Emit 0x prefix for explict/implicit hex conversion */ + + *new_buf++ = '0'; + *new_buf++ = 'x'; + } + new_buf += acpi_ex_convert_to_ascii((u64) obj_desc-> buffer.pointer[i], base, new_buf, 1); - *new_buf++ = separator; /* each separated by a comma or space */ + + /* Each digit is separated by either a comma or space */ + + *new_buf++ = separator; } /*