From: Erik Schmauss <erik.schmauss@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Bob Moore <robert.moore@intel.com>,
Erik Schmauss <erik.schmauss@intel.com>
Subject: [PATCH 01/15] ACPICA: Use local 64-bit divide support for string conversions
Date: Fri, 17 Nov 2017 15:42:16 -0800 [thread overview]
Message-ID: <20171117234230.913-2-erik.schmauss@intel.com> (raw)
In-Reply-To: <20171117234230.913-1-erik.schmauss@intel.com>
From: Bob Moore <robert.moore@intel.com>
ACPICA commit f230f4df26d07b97ef00be39156ecee64250447d
On 32-bit platforms, 64-bit divide often requires a library
function which may not be present in the build.
Link: https://github.com/acpica/acpica/commit/f230f4df
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
---
drivers/acpi/acpica/utstrsuppt.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/drivers/acpi/acpica/utstrsuppt.c b/drivers/acpi/acpica/utstrsuppt.c
index bec2b8e1693e..97f48d71f9e6 100644
--- a/drivers/acpi/acpica/utstrsuppt.c
+++ b/drivers/acpi/acpica/utstrsuppt.c
@@ -52,10 +52,9 @@ static acpi_status
acpi_ut_insert_digit(u64 *accumulated_value, u32 base, int ascii_digit);
static acpi_status
-acpi_ut_strtoul_multiply64(u64 multiplicand, u64 multiplier, u64 *out_product);
+acpi_ut_strtoul_multiply64(u64 multiplicand, u32 base, u64 *out_product);
-static acpi_status
-acpi_ut_strtoul_add64(u64 addend1, u64 addend2, u64 *out_sum);
+static acpi_status acpi_ut_strtoul_add64(u64 addend1, u32 digit, u64 *out_sum);
/*******************************************************************************
*
@@ -357,7 +356,7 @@ acpi_ut_insert_digit(u64 *accumulated_value, u32 base, int ascii_digit)
* FUNCTION: acpi_ut_strtoul_multiply64
*
* PARAMETERS: multiplicand - Current accumulated converted integer
- * multiplier - Base/Radix
+ * base - Base/Radix
* out_product - Where the product is returned
*
* RETURN: Status and 64-bit product
@@ -369,24 +368,32 @@ acpi_ut_insert_digit(u64 *accumulated_value, u32 base, int ascii_digit)
******************************************************************************/
static acpi_status
-acpi_ut_strtoul_multiply64(u64 multiplicand, u64 multiplier, u64 *out_product)
+acpi_ut_strtoul_multiply64(u64 multiplicand, u32 base, u64 *out_product)
{
u64 product;
+ u64 quotient;
/* Exit if either operand is zero */
*out_product = 0;
- if (!multiplicand || !multiplier) {
+ if (!multiplicand || !base) {
return (AE_OK);
}
- /* Check for 64-bit overflow before the actual multiplication */
-
- if (multiplicand > (ACPI_UINT64_MAX / multiplier)) {
+ /*
+ * Check for 64-bit overflow before the actual multiplication.
+ *
+ * Notes: 64-bit division is often not supported on 32-bit platforms
+ * (it requires a library function), Therefore ACPICA has a local
+ * 64-bit divide function. Also, Multiplier is currently only used
+ * as the radix (8/10/16), to the 64/32 divide will always work.
+ */
+ acpi_ut_short_divide(ACPI_UINT64_MAX, base, "ient, NULL);
+ if (multiplicand > quotient) {
return (AE_NUMERIC_OVERFLOW);
}
- product = multiplicand * multiplier;
+ product = multiplicand * base;
/* Check for 32-bit overflow if necessary */
@@ -403,7 +410,7 @@ acpi_ut_strtoul_multiply64(u64 multiplicand, u64 multiplier, u64 *out_product)
* FUNCTION: acpi_ut_strtoul_add64
*
* PARAMETERS: addend1 - Current accumulated converted integer
- * addend2 - New hex value/char
+ * digit - New hex value/char
* out_sum - Where sum is returned (Accumulator)
*
* RETURN: Status and 64-bit sum
@@ -414,17 +421,17 @@ acpi_ut_strtoul_multiply64(u64 multiplicand, u64 multiplier, u64 *out_product)
*
******************************************************************************/
-static acpi_status acpi_ut_strtoul_add64(u64 addend1, u64 addend2, u64 *out_sum)
+static acpi_status acpi_ut_strtoul_add64(u64 addend1, u32 digit, u64 *out_sum)
{
u64 sum;
/* Check for 64-bit overflow before the actual addition */
- if ((addend1 > 0) && (addend2 > (ACPI_UINT64_MAX - addend1))) {
+ if ((addend1 > 0) && (digit > (ACPI_UINT64_MAX - addend1))) {
return (AE_NUMERIC_OVERFLOW);
}
- sum = addend1 + addend2;
+ sum = addend1 + digit;
/* Check for 32-bit overflow if necessary */
--
2.13.6
next prev parent reply other threads:[~2017-11-17 23:46 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 23:42 [PATCH 00/15] ACPICA release 20171110 Erik Schmauss
2017-11-17 23:42 ` Erik Schmauss [this message]
2017-11-17 23:42 ` [PATCH 02/15] ACPICA: Update output from ACPI_EXCEPTION macro Erik Schmauss
2017-11-17 23:42 ` [PATCH 03/15] ACPICA: Add an additional error message for EC timeouts Erik Schmauss
2017-11-17 23:42 ` [PATCH 04/15] ACPICA: iasl: Add SMMUv3 device ID mapping index support Erik Schmauss
2017-11-27 14:31 ` Lorenzo Pieralisi
2017-11-27 16:20 ` Rafael J. Wysocki
2017-11-17 23:42 ` [PATCH 05/15] ACPICA: ACPICA: style edits to utility function output, no functional change Erik Schmauss
2017-11-17 23:42 ` [PATCH 06/15] ACPICA: Trivial fix to spelling mistake in comment Erik Schmauss
2017-11-17 23:42 ` [PATCH 07/15] ACPICA: Enhance error messages from namespace create/lookup operations Erik Schmauss
2017-11-17 23:42 ` [PATCH 08/15] ACPICA: Namespace: fix memory leak from building prefixed pathname Erik Schmauss
2017-11-17 23:42 ` [PATCH 09/15] ACPICA: ACPI 6.0A: Changes to the NFIT ACPI table Erik Schmauss
2017-11-17 23:42 ` [PATCH 10/15] ACPICA: Small typo fix, no functional change Erik Schmauss
2017-11-17 23:42 ` [PATCH 11/15] ACPICA: Debugger: add "background" command for method execution Erik Schmauss
2017-11-17 23:42 ` [PATCH 12/15] ACPICA: Update mutex error messages, no functional change Erik Schmauss
2017-11-17 23:42 ` [PATCH 13/15] ACPICA: Update linkage for get mutex name interface Erik Schmauss
2017-11-17 23:42 ` [PATCH 14/15] ACPICA: ACPI 6.2: Additional PPTT flags Erik Schmauss
2017-11-17 23:42 ` [PATCH 15/15] ACPICA: Update version to 20171110 Erik Schmauss
2017-12-04 14:43 ` [PATCH 00/15] ACPICA release 20171110 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=20171117234230.913-2-erik.schmauss@intel.com \
--to=erik.schmauss@intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=robert.moore@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