From patchwork Wed Feb 27 14:40:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 223616 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 4EBD62C008E for ; Thu, 28 Feb 2013 01:41:03 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UAiBp-0002SN-Qz; Wed, 27 Feb 2013 14:41:01 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UAiBl-0002RD-34 for fwts-devel@lists.ubuntu.com; Wed, 27 Feb 2013 14:40:57 +0000 Received: from cpc3-craw6-2-0-cust180.croy.cable.virginmedia.com ([77.100.248.181] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UAiBl-0006Li-0y for fwts-devel@lists.ubuntu.com; Wed, 27 Feb 2013 14:40:57 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 5/8] acpi: syntaxcheck: add helpers to convert error_code Date: Wed, 27 Feb 2013 14:40:51 +0000 Message-Id: <1361976054-28357-6-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361976054-28357-1-git-send-email-colin.king@canonical.com> References: <1361976054-28357-1-git-send-email-colin.king@canonical.com> X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King Add a few simple inline helpers to convert the assembler error_codes Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin --- src/acpi/syntaxcheck/syntaxcheck.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/acpi/syntaxcheck/syntaxcheck.c b/src/acpi/syntaxcheck/syntaxcheck.c index 557219c..4ebf450 100644 --- a/src/acpi/syntaxcheck/syntaxcheck.c +++ b/src/acpi/syntaxcheck/syntaxcheck.c @@ -235,10 +235,24 @@ static int syntaxcheck_deinit(fwts_framework *fw) return FWTS_OK; } +static inline uint16_t syntaxcheck_error_code_to_error_level(const uint32_t error_code) +{ + uint16_t error_level = (error_code / 1000) - 1; + + return error_level; +} + +static inline uint16_t syntaxcheck_error_code_to_error_number(const uint32_t error_code) +{ + uint16_t error_number = (error_code % 1000); + + return error_number; +} + static const char *syntaxcheck_error_code_to_id(const uint32_t error_code) { int i; - uint16_t error_number = (error_code % 1000); + uint16_t error_number = syntaxcheck_error_code_to_error_number(error_code); static const char *unknown = "Unknown"; for (i = 0; syntaxcheck_error_map[i].id_str != NULL; i++) { @@ -251,8 +265,7 @@ static const char *syntaxcheck_error_code_to_id(const uint32_t error_code) static const char *syntaxcheck_error_level(uint32_t error_code) { - /* iasl encodes error_level as follows: */ - uint16_t error_level = (error_code / 1000) - 1; + uint16_t error_level = syntaxcheck_error_code_to_error_level(error_code); static char *error_levels[] = { "warning (level 0)", @@ -395,7 +408,7 @@ static void syntaxcheck_give_advice(fwts_framework *fw, uint32_t error_code) { int i; /* iasl encodes error_codes as follows: */ - uint16_t error_number = (error_code % 1000); + uint16_t error_number = syntaxcheck_error_code_to_error_number(error_code); for (i = 0; syntaxcheck_error_map[i].id_str != NULL; i++) { if ((syntaxcheck_error_map[i].error_number == error_number) &&