aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/pci/mmconfig_64.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2009-11-13 19:35:04 -0500
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-11-24 18:30:36 -0500
commitf6e1d8cc38b3776038fb15d3acc82ed8bb552f82 (patch)
treed6ff3745b8f3843bad4cf284e653e38ba3b0a693 /arch/x86/pci/mmconfig_64.c
parent8c57786ad3d921713c7ad8e44132aa537a1d0fec (diff)
x86/PCI: MMCONFIG: add lookup function
This patch factors out the search for an MMCONFIG region, which was previously implemented in both mmconfig_32 and mmconfig_64. No functional change. Reviewed-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'arch/x86/pci/mmconfig_64.c')
-rw-r--r--arch/x86/pci/mmconfig_64.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/arch/x86/pci/mmconfig_64.c b/arch/x86/pci/mmconfig_64.c
index cfa6cdb6d262..e783841bd1d7 100644
--- a/arch/x86/pci/mmconfig_64.c
+++ b/arch/x86/pci/mmconfig_64.c
@@ -14,28 +14,13 @@
14 14
15#define PREFIX "PCI: " 15#define PREFIX "PCI: "
16 16
17static char __iomem *get_virt(unsigned int seg, unsigned bus)
18{
19 struct pci_mmcfg_region *cfg;
20
21 list_for_each_entry(cfg, &pci_mmcfg_list, list)
22 if (cfg->segment == seg &&
23 (cfg->start_bus <= bus) &&
24 (cfg->end_bus >= bus))
25 return cfg->virt;
26
27 /* Fall back to type 0 */
28 return NULL;
29}
30
31static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn) 17static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
32{ 18{
33 char __iomem *addr; 19 struct pci_mmcfg_region *cfg = pci_mmconfig_lookup(seg, bus);
34 20
35 addr = get_virt(seg, bus); 21 if (cfg && cfg->virt)
36 if (!addr) 22 return cfg->virt + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12));
37 return NULL; 23 return NULL;
38 return addr + (PCI_MMCFG_BUS_OFFSET(bus) | (devfn << 12));
39} 24}
40 25
41static int pci_mmcfg_read(unsigned int seg, unsigned int bus, 26static int pci_mmcfg_read(unsigned int seg, unsigned int bus,