Patchwork acpi: fadt: only perform port read on valid port widths

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

Comments

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

Only peform ioperm() and port read when we have a valid port
width specified.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/acpi/fadt/fadt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Keng-Yu Lin - Dec. 10, 2012, 7:16 a.m.
On Fri, Dec 7, 2012 at 2:27 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Only peform ioperm() and port read when we have a valid port
> width specified.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/acpi/fadt/fadt.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c
> index e14d7be..2114b42 100644
> --- a/src/acpi/fadt/fadt.c
> +++ b/src/acpi/fadt/fadt.c
> @@ -92,22 +92,23 @@ static int fadt_test1(fwts_framework *fw)
>                 width = fadt->x_pm1a_cnt_blk.register_bit_width;
>         }
>
> -       ioperm(port, width/8, 1);
>         switch (width) {
>         case 8:
> +               ioperm(port, width/8, 1);
>                 value = inb(fadt->pm1a_cnt_blk);
>                 ioperm(port, width/8, 0);
>                 break;
>         case 16:
> +               ioperm(port, width/8, 1);
>                 value = inw(fadt->pm1a_cnt_blk);
>                 ioperm(port, width/8, 0);
>                 break;
>         case 32:
> +               ioperm(port, width/8, 1);
>                 value = inl(fadt->pm1a_cnt_blk);
>                 ioperm(port, width/8, 0);
>                 break;
>         default:
> -               ioperm(port, width/8, 0);
>                 fwts_failed(fw, LOG_LEVEL_HIGH, "FADTPM1AInvalidWidth",
>                         "FADT pm1a register has invalid bit width of %d.",
>                         width);
> --
> 1.8.0
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>
Alex Hung - Dec. 12, 2012, 6:32 a.m.
On 12/07/2012 02:27 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Only peform ioperm() and port read when we have a valid port
> width specified.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/acpi/fadt/fadt.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c
> index e14d7be..2114b42 100644
> --- a/src/acpi/fadt/fadt.c
> +++ b/src/acpi/fadt/fadt.c
> @@ -92,22 +92,23 @@ static int fadt_test1(fwts_framework *fw)
>   		width = fadt->x_pm1a_cnt_blk.register_bit_width;
>   	}
>
> -	ioperm(port, width/8, 1);
>   	switch (width) {
>   	case 8:
> +		ioperm(port, width/8, 1);
>   		value = inb(fadt->pm1a_cnt_blk);
>   		ioperm(port, width/8, 0);
>   		break;
>   	case 16:
> +		ioperm(port, width/8, 1);
>   		value = inw(fadt->pm1a_cnt_blk);
>   		ioperm(port, width/8, 0);
>   		break;
>   	case 32:
> +		ioperm(port, width/8, 1);
>   		value = inl(fadt->pm1a_cnt_blk);
>   		ioperm(port, width/8, 0);
>   		break;
>   	default:
> -		ioperm(port, width/8, 0);
>   		fwts_failed(fw, LOG_LEVEL_HIGH, "FADTPM1AInvalidWidth",
>   			"FADT pm1a register has invalid bit width of %d.",
>   			width);
>
Acked-by: Alex Hung <alex.hung@canonical.com>

Patch

diff --git a/src/acpi/fadt/fadt.c b/src/acpi/fadt/fadt.c
index e14d7be..2114b42 100644
--- a/src/acpi/fadt/fadt.c
+++ b/src/acpi/fadt/fadt.c
@@ -92,22 +92,23 @@  static int fadt_test1(fwts_framework *fw)
 		width = fadt->x_pm1a_cnt_blk.register_bit_width;
 	}
 
-	ioperm(port, width/8, 1);
 	switch (width) {
 	case 8:
+		ioperm(port, width/8, 1);
 		value = inb(fadt->pm1a_cnt_blk);
 		ioperm(port, width/8, 0);
 		break;
 	case 16:
+		ioperm(port, width/8, 1);
 		value = inw(fadt->pm1a_cnt_blk);
 		ioperm(port, width/8, 0);
 		break;
 	case 32:
+		ioperm(port, width/8, 1);
 		value = inl(fadt->pm1a_cnt_blk);
 		ioperm(port, width/8, 0);
 		break;
 	default:
-		ioperm(port, width/8, 0);
 		fwts_failed(fw, LOG_LEVEL_HIGH, "FADTPM1AInvalidWidth",
 			"FADT pm1a register has invalid bit width of %d.",
 			width);