diff mbox

[v2,5/8] seabios: pciinit: factor out bar offset calculation.

Message ID 6d3326909eeeaed29704c93d09b54fe7714919bf.1277196704.git.yamahata@valinux.co.jp
State New
Headers show

Commit Message

Isaku Yamahata June 22, 2010, 8:57 a.m. UTC
This patch factors out bar offset calculation.
Later the calculation logic will be enhanced.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 src/pciinit.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
diff mbox

Patch

diff --git a/src/pciinit.c b/src/pciinit.c
index a65c58d..9109739 100644
--- a/src/pciinit.c
+++ b/src/pciinit.c
@@ -22,15 +22,19 @@  static u8 pci_irqs[4] = {
     10, 10, 11, 11
 };
 
+static u32 pci_bar(u16 bdf, int region_num)
+{
+    if (region_num != PCI_ROM_SLOT) {
+        return PCI_BASE_ADDRESS_0 + region_num * 4;
+    }
+    return PCI_ROM_ADDRESS;
+}
+
 static void pci_set_io_region_addr(u16 bdf, int region_num, u32 addr)
 {
     u32 ofs, old_addr;
 
-    if (region_num == PCI_ROM_SLOT) {
-        ofs = PCI_ROM_ADDRESS;
-    } else {
-        ofs = PCI_BASE_ADDRESS_0 + region_num * 4;
-    }
+    ofs = pci_bar(bdf, region_num);
 
     old_addr = pci_config_readl(bdf, ofs);
 
@@ -46,11 +50,7 @@  static void pci_set_io_region_addr(u16 bdf, int region_num, u32 addr)
 static int pci_bios_allocate_region(u16 bdf, int region_num)
 {
     u32 *paddr;
-    int ofs;
-    if (region_num == PCI_ROM_SLOT)
-        ofs = PCI_ROM_ADDRESS;
-    else
-        ofs = PCI_BASE_ADDRESS_0 + region_num * 4;
+    u32 ofs = pci_bar(bdf, region_num);
 
     u32 old = pci_config_readl(bdf, ofs);
     u32 mask;