Patchwork acpi: method: handle ACPI failures a little more gracefully

login
register
mail settings
Submitter Colin King
Date Dec. 7, 2012, 6:32 p.m.
Message ID <1354905177-29726-1-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/204593/
State Accepted
Headers show

Comments

Colin King - Dec. 7, 2012, 6:32 p.m.
From: Colin Ian King <colin.king@canonical.com>

Add some improved error handling on systems that don't support ACPI.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/method/method.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
Keng-Yu Lin - Dec. 12, 2012, 3:17 a.m.
On Sat, Dec 8, 2012 at 2:32 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Add some improved error handling on systems that don't support ACPI.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/method/method.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index fd57015..a8669f2 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -280,6 +280,7 @@ static int method_init(fwts_framework *fw)
>  {
>         fwts_acpi_table_info *info;
>         int i;
> +       bool got_fadt = false;
>
>         fadt_mobile_platform = false;
>
> @@ -289,20 +290,23 @@ static int method_init(fwts_framework *fw)
>                 if (ret == FWTS_NULL_POINTER || info == NULL)
>                         break;
>                 fwts_acpi_table_fadt *fadt = (fwts_acpi_table_fadt*)info->data;
> +               got_fadt = true;
>                 if (fadt->preferred_pm_profile == 2) {
>                         fadt_mobile_platform = true;
>                         break;
>                 }
>         }
>
> -       if (!fadt_mobile_platform) {
> +       if (got_fadt && !fadt_mobile_platform) {
>                 fwts_log_info(fw,
>                         "FADT Preferred PM profile indicates this is not "
>                         "a Mobile Platform.");
>         }
>
> -       if (fwts_method_init(fw) != FWTS_OK)
> +       if (fwts_method_init(fw) != FWTS_OK) {
> +               fwts_log_error(fw, "Cannot initialise ACPI.");
>                 return FWTS_ERROR;
> +       }
>
>         return FWTS_OK;
>  }
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - Dec. 12, 2012, 6:41 a.m.
On 12/08/2012 02:32 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Add some improved error handling on systems that don't support ACPI.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/method/method.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
> index fd57015..a8669f2 100644
> --- a/src/acpi/method/method.c
> +++ b/src/acpi/method/method.c
> @@ -280,6 +280,7 @@ static int method_init(fwts_framework *fw)
>   {
>   	fwts_acpi_table_info *info;
>   	int i;
> +	bool got_fadt = false;
>
>   	fadt_mobile_platform = false;
>
> @@ -289,20 +290,23 @@ static int method_init(fwts_framework *fw)
>   		if (ret == FWTS_NULL_POINTER || info == NULL)
>   			break;
>   		fwts_acpi_table_fadt *fadt = (fwts_acpi_table_fadt*)info->data;
> +		got_fadt = true;
>   		if (fadt->preferred_pm_profile == 2) {
>   			fadt_mobile_platform = true;
>   			break;
>   		}
>   	}
>
> -	if (!fadt_mobile_platform) {
> +	if (got_fadt && !fadt_mobile_platform) {
>   		fwts_log_info(fw,
>   			"FADT Preferred PM profile indicates this is not "
>   			"a Mobile Platform.");
>   	}
>
> -	if (fwts_method_init(fw) != FWTS_OK)
> +	if (fwts_method_init(fw) != FWTS_OK) {
> +		fwts_log_error(fw, "Cannot initialise ACPI.");
>   		return FWTS_ERROR;
> +	}
>
>   	return FWTS_OK;
>   }
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/acpi/method/method.c b/src/acpi/method/method.c
index fd57015..a8669f2 100644
--- a/src/acpi/method/method.c
+++ b/src/acpi/method/method.c
@@ -280,6 +280,7 @@  static int method_init(fwts_framework *fw)
 {
 	fwts_acpi_table_info *info;
 	int i;
+	bool got_fadt = false;
 
 	fadt_mobile_platform = false;
 
@@ -289,20 +290,23 @@  static int method_init(fwts_framework *fw)
 		if (ret == FWTS_NULL_POINTER || info == NULL)
 			break;
 		fwts_acpi_table_fadt *fadt = (fwts_acpi_table_fadt*)info->data;
+		got_fadt = true;
 		if (fadt->preferred_pm_profile == 2) {
 			fadt_mobile_platform = true;
 			break;
 		}
 	}
 
-	if (!fadt_mobile_platform) {
+	if (got_fadt && !fadt_mobile_platform) {
 		fwts_log_info(fw,
 			"FADT Preferred PM profile indicates this is not "
 			"a Mobile Platform.");
 	}
 
-	if (fwts_method_init(fw) != FWTS_OK)
+	if (fwts_method_init(fw) != FWTS_OK) {
+		fwts_log_error(fw, "Cannot initialise ACPI.");
 		return FWTS_ERROR;
+	}
 
 	return FWTS_OK;
 }