Patchwork [19/19] pci: simplify memory region registration

login
register
mail settings
Submitter Avi Kivity
Date Aug. 25, 2011, 8:09 a.m.
Message ID <1314259758-5198-20-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/111535/
State New
Headers show

Comments

Avi Kivity - Aug. 25, 2011, 8:09 a.m.
The two code paths (for ADDRESS_SPACE_IO and ADDRESS_SPACE_MEM) are almost
identical.  Unify them.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 hw/pci.c |   15 ++++-----------
 1 files changed, 4 insertions(+), 11 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 1a5d2b6..e9e37ef 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1059,18 +1059,11 @@  static void pci_update_mappings(PCIDevice *d)
              * Teach them such cases, such that filtered_size < size and
              * addr & (size - 1) != 0.
              */
-            if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
-                memory_region_add_subregion_overlap(r->address_space,
-                                                    r->addr,
-                                                    r->memory,
-                                                    1);
-            } else {
-                memory_region_add_subregion_overlap(r->address_space,
-                                                    pci_to_cpu_addr(d->bus,
-                                                                    r->addr),
-                                                    r->memory,
-                                                    1);
+            if (!(r->type & PCI_BASE_ADDRESS_SPACE_IO)) {
+                new_addr = pci_to_cpu_addr(d->bus, new_addr);
             }
+            memory_region_add_subregion_overlap(r->address_space,
+                                                new_addr, r->memory, 1);
         }
     }
 }