diff mbox

[16/20] pci: kill goto in pci_update_mappings()

Message ID 1258005528-25383-17-git-send-email-yamahata@valinux.co.jp
State New
Headers show

Commit Message

Isaku Yamahata Nov. 12, 2009, 5:58 a.m. UTC
This patch kills nasty goto in pci_update_mappings().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |   54 ++++++++++++++++++++++++++++--------------------------
 1 files changed, 28 insertions(+), 26 deletions(-)
diff mbox

Patch

diff --git a/hw/pci.c b/hw/pci.c
index cae3d53..2eff7fe 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -756,35 +756,37 @@  static void pci_update_mappings(PCIDevice *d)
                     new_addr = pci_get_long(d->config + pci_bar(d, i));
                 }
                 /* the ROM slot has a specific enable bit */
-                if (i == PCI_ROM_SLOT && !(new_addr & PCI_ROM_ADDRESS_ENABLE))
-                    goto no_mem_map;
-                new_addr = new_addr & ~(r->size - 1);
-                last_addr = new_addr + r->size - 1;
-                /* NOTE: we do not support wrapping */
-                /* XXX: as we cannot support really dynamic
-                   mappings, we handle specific values as invalid
-                   mappings. */
-                if (last_addr <= new_addr || new_addr == 0 ||
-                    last_addr == PCI_BAR_UNMAPPED ||
-
-                    /* Now pcibus_t is 64bit.
-                     * Check if 32 bit BAR wrap around explicitly.
-                     * Without this, PC ide doesn't work well.
-                     * TODO: remove this work around.
-                     */
-                    (!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) &&
-                     last_addr >= UINT32_MAX) ||
-
-                    /*
-                     * OS is allowed to set BAR beyond its addressable
-                     * bits. For example, 32 bit OS can set 64bit bar
-                     * to >4G. Check it.
-                     */
-                    last_addr >= TARGET_PHYS_ADDR_MAX) {
+                if (i == PCI_ROM_SLOT &&
+                    !(new_addr & PCI_ROM_ADDRESS_ENABLE)) {
                     new_addr = PCI_BAR_UNMAPPED;
+                } else {
+                    new_addr = new_addr & ~(r->size - 1);
+                    last_addr = new_addr + r->size - 1;
+                    /* NOTE: we do not support wrapping */
+                    /* XXX: as we cannot support really dynamic
+                       mappings, we handle specific values as invalid
+                       mappings. */
+                    if (last_addr <= new_addr || new_addr == 0 ||
+                        last_addr == PCI_BAR_UNMAPPED ||
+
+                        /* Now pcibus_t is 64bit.
+                         * Check if 32 bit BAR wrap around explicitly.
+                         * Without this, PC ide doesn't work well.
+                         * TODO: remove this work around.
+                         */
+                        (!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64) &&
+                         last_addr >= UINT32_MAX) ||
+
+                        /*
+                         * OS is allowed to set BAR beyond its addressable
+                         * bits. For example, 32 bit OS can set 64bit bar
+                         * to >4G. Check it.
+                         */
+                        last_addr >= TARGET_PHYS_ADDR_MAX) {
+                        new_addr = PCI_BAR_UNMAPPED;
+                    }
                 }
             } else {
-            no_mem_map:
                 new_addr = PCI_BAR_UNMAPPED;
             }
         }