[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fwts-devel
Subject:    [PATCH 5/8] acpi: syntaxcheck: add helpers to convert error_code
From:       Colin King <colin.king () canonical ! com>
Date:       2013-02-27 14:40:51
Message-ID: 1361976054-28357-6-git-send-email-colin.king () canonical ! com
[Download RAW message or body]

From: Colin Ian King <colin.king@canonical.com>

Add a few simple inline helpers to convert the assembler error_codes

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 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) &&
-- 
1.8.1.2



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic