Patchwork [v3,12/16] boot-order-test: Code motion for better readability

login
register
mail settings
Submitter Markus Armbruster
Date June 14, 2013, 11:15 a.m.
Message ID <1371208516-7857-13-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/251364/
State New
Headers show

Comments

Markus Armbruster - June 14, 2013, 11:15 a.m.
Cc: Andreas Färber <afaerber@suse.de>
Cc: Alexander Graf <agraf@suse.de>
Cc: qemu-ppc@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/boot-order-test.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

Patch

diff --git a/tests/boot-order-test.c b/tests/boot-order-test.c
index 23edacf..003140f 100644
--- a/tests/boot-order-test.c
+++ b/tests/boot-order-test.c
@@ -15,19 +15,15 @@ 
 #include "libqtest.h"
 #include "qemu/bswap.h"
 
-static uint8_t read_mc146818(uint16_t port, uint8_t reg)
-{
-    outb(port, reg);
-    return inb(port + 1);
-}
-
-static uint64_t read_boot_order_pc(void)
-{
-    uint8_t b1 = read_mc146818(0x70, 0x38);
-    uint8_t b2 = read_mc146818(0x70, 0x3d);
+#define NO_QEMU_PROTOS
+#include "hw/nvram/fw_cfg.h"
+#undef NO_QEMU_PROTOS
 
-    return b1 | (b2 << 8);
-}
+typedef struct {
+    const char *args;
+    uint64_t expected_boot;
+    uint64_t expected_reboot;
+} boot_order_test;
 
 static void test_a_boot_order(const char *machine,
                               const char *test_args,
@@ -52,12 +48,6 @@  static void test_a_boot_order(const char *machine,
     g_free(args);
 }
 
-typedef struct {
-    const char *args;
-    uint64_t expected_boot;
-    uint64_t expected_reboot;
-} boot_order_test;
-
 static void test_boot_orders(const char *machine,
                              uint64_t (*read_boot_order)(void),
                              const boot_order_test *tests)
@@ -72,6 +62,20 @@  static void test_boot_orders(const char *machine,
     }
 }
 
+static uint8_t read_mc146818(uint16_t port, uint8_t reg)
+{
+    outb(port, reg);
+    return inb(port + 1);
+}
+
+static uint64_t read_boot_order_pc(void)
+{
+    uint8_t b1 = read_mc146818(0x70, 0x38);
+    uint8_t b2 = read_mc146818(0x70, 0x3d);
+
+    return b1 | (b2 << 8);
+}
+
 static const boot_order_test test_cases_pc[] = {
     { "",
       0x1230, 0x1230 },
@@ -103,12 +107,6 @@  static void test_pc_boot_order(void)
     test_boot_orders(NULL, read_boot_order_pc, test_cases_pc);
 }
 
-#define PMAC_CFG_ADDR 0xf0000510
-
-#define NO_QEMU_PROTOS
-#include "hw/nvram/fw_cfg.h"
-#undef NO_QEMU_PROTOS
-
 static void read_fw_cfg(uint64_t cfg_addr, uint16_t cmd,
                         void *buf, size_t len)
 {
@@ -129,6 +127,8 @@  static uint16_t read_fw_cfg_i16(uint64_t cfg_addr, uint16_t cmd)
     return le16_to_cpu(value);
 }
 
+#define PMAC_CFG_ADDR 0xf0000510
+
 static uint64_t read_boot_order_pmac(void)
 {
     return read_fw_cfg_i16(PMAC_CFG_ADDR, FW_CFG_BOOT_DEVICE);