Patchwork [24/25] e1000: unfold mac_regarraystosave array

login
register
mail settings
Submitter Juan Quintela
Date Oct. 19, 2009, 6:43 p.m.
Message ID <e0ff13901b90402e4c0ccbb4aaad643064dc5921.1255976538.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/36413/
State New
Headers show

Comments

Juan Quintela - Oct. 19, 2009, 6:43 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/e1000.c |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 deletions(-)

Patch

diff --git a/hw/e1000.c b/hw/e1000.c
index 0d40fbe..e5541c7 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -879,17 +879,11 @@  e1000_mmio_readw(void *opaque, target_phys_addr_t addr)
             (8 * (addr & 3))) & 0xffff;
 }

-static const struct {
-    int size;
-    int array0;
-} mac_regarraystosave[] = { {32, RA}, {128, MTA}, {128, VFTA} };
-enum { MAC_NARRAYS = ARRAY_SIZE(mac_regarraystosave) };
-
 static void
 nic_save(QEMUFile *f, void *opaque)
 {
     E1000State *s = opaque;
-    int i, j;
+    int i;

     pci_device_save(&s->dev, f);
     qemu_put_be32(f, 0);
@@ -957,17 +951,19 @@  nic_save(QEMUFile *f, void *opaque)
     qemu_put_be32s(f, &s->mac_reg[TXDCTL]);
     qemu_put_be32s(f, &s->mac_reg[WUFC]);
     qemu_put_be32s(f, &s->mac_reg[VET]);
-    for (i = 0; i < MAC_NARRAYS; i++)
-        for (j = 0; j < mac_regarraystosave[i].size; j++)
-            qemu_put_be32s(f,
-                           s->mac_reg + mac_regarraystosave[i].array0 + j);
+    for (i = RA; i < RA + 32; i++)
+        qemu_put_be32s(f, &s->mac_reg[i]);
+    for (i = MTA; i < MTA + 128; i++)
+        qemu_put_be32s(f, &s->mac_reg[i]);
+    for (i = VFTA; i < VFTA + 128; i++)
+        qemu_put_be32s(f, &s->mac_reg[i]);
 }

 static int
 nic_load(QEMUFile *f, void *opaque, int version_id)
 {
     E1000State *s = opaque;
-    int i, j, ret;
+    int i, ret;

     if ((ret = pci_device_load(&s->dev, f)) < 0)
         return ret;
@@ -1038,10 +1034,12 @@  nic_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_be32s(f, &s->mac_reg[TXDCTL]);
     qemu_get_be32s(f, &s->mac_reg[WUFC]);
     qemu_get_be32s(f, &s->mac_reg[VET]);
-    for (i = 0; i < MAC_NARRAYS; i++)
-        for (j = 0; j < mac_regarraystosave[i].size; j++)
-            qemu_get_be32s(f,
-                           s->mac_reg + mac_regarraystosave[i].array0 + j);
+    for (i = RA; i < RA + 32; i++)
+        qemu_get_be32s(f, &s->mac_reg[i]);
+    for (i = MTA; i < MTA + 128; i++)
+        qemu_get_be32s(f, &s->mac_reg[i]);
+    for (i = VFTA; i < VFTA + 128; i++)
+        qemu_get_be32s(f, &s->mac_reg[i]);
     return 0;
 }