summaryrefslogtreecommitdiff
path: root/drivers/pci/setup-res.c
diff options
context:
space:
mode:
authorYu Zhao <yu.zhao@intel.com>2008-11-21 21:41:27 +0300
committerJesse Barnes <jbarnes@virtuousgeek.org>2009-01-07 22:13:04 +0300
commit613e7ed6f72b1a115f7ece8ce1b66cf095de1348 (patch)
tree2af16f01cbf78f1de6b858788091a72fa57af6c8 /drivers/pci/setup-res.c
parent3789fa8a2e534523c896a32a9f27f78d52ad7d82 (diff)
downloadlinux-613e7ed6f72b1a115f7ece8ce1b66cf095de1348.tar.xz
PCI: add a new function to map BAR offsets
Add a function to map a given resource number to a corresponding register so drivers can get the offset and type of device specific BARs. Signed-off-by: Yu Zhao <yu.zhao@intel.com> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/setup-res.c')
-rw-r--r--drivers/pci/setup-res.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index 3c5203ff53c7..32e8d88a4619 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -31,6 +31,7 @@ void pci_update_resource(struct pci_dev *dev, int resno)
struct pci_bus_region region;
u32 new, check, mask;
int reg;
+ enum pci_bar_type type;
struct resource *res = dev->resource + resno;
/*
@@ -62,17 +63,13 @@ void pci_update_resource(struct pci_dev *dev, int resno)
else
mask = (u32)PCI_BASE_ADDRESS_MEM_MASK;
- if (resno < 6) {
- reg = PCI_BASE_ADDRESS_0 + 4 * resno;
- } else if (resno == PCI_ROM_RESOURCE) {
+ reg = pci_resource_bar(dev, resno, &type);
+ if (!reg)
+ return;
+ if (type != pci_bar_unknown) {
if (!(res->flags & IORESOURCE_ROM_ENABLE))
return;
new |= PCI_ROM_ADDRESS_ENABLE;
- reg = dev->rom_base_reg;
- } else {
- /* Hmm, non-standard resource. */
-
- return; /* kill uninitialised var warning */
}
pci_write_config_dword(dev, reg, new);