diff mbox

[5/8] acpi: syntaxcheck: add helpers to convert error_code

Message ID 1361976054-28357-6-git-send-email-colin.king@canonical.com
State Accepted
Headers show

Commit Message

Colin Ian King Feb. 27, 2013, 2:40 p.m. UTC
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(-)

Comments

Alex Hung March 4, 2013, 10:02 a.m. UTC | #1
On 02/27/2013 10:40 PM, Colin King wrote:
> 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) &&
>
Acked-by Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin March 5, 2013, 8:28 a.m. UTC | #2
On Wed, Feb 27, 2013 at 10:40 PM, Colin King <colin.king@canonical.com> wrote:
> 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
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
diff mbox

Patch

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) &&