[PATCH] acpi: fadt: only perform port read on valid port widths

Colin King colin.king at canonical.com
Thu Dec 6 18:27:50 UTC 2012


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

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

Signed-off-by: Colin Ian King <colin.king at 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




More information about the fwts-devel mailing list