diff options
author | Yinghai Lu <yinghai@kernel.org> | 2012-09-17 22:20:31 -0700 |
---|---|---|
committer | Yinghai Lu <yinghai@kernel.org> | 2012-09-17 22:20:31 -0700 |
commit | 4132a42165bd2ece9afa2a8e36eea4b14a59ea62 (patch) | |
tree | 17a9077195670fb5434a04cfc9db5e01e1eb7f76 | |
parent | 02c3c764de79aa21c770f5bdfb2dbcfe5dd39b14 (diff) | |
download | linux-yinghai-4132a42165bd2ece9afa2a8e36eea4b14a59ea62.tar.gz |
PCI: Make assign/update resource to support addon_res
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
-rw-r--r-- | drivers/pci/setup-res.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index 94ef232e5a13b..6a85dcf8522b9 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c @@ -35,7 +35,7 @@ void pci_update_resource(struct pci_dev *dev, int resno) u32 new, check, mask; int reg; enum pci_bar_type type; - struct resource *res = dev->resource + resno; + struct resource *res = pci_dev_resource_n(dev, resno); /* * Ignore resources for unimplemented BARs and unused resource slots @@ -52,6 +52,21 @@ void pci_update_resource(struct pci_dev *dev, int resno) if (res->flags & IORESOURCE_PCI_FIXED) return; + if (resno >= PCI_NUM_RESOURCES) { + struct pci_dev_addon_resource *addon_res; + + addon_res = to_pci_dev_addon_resource(res); + reg = addon_res->reg_addr; + if (addon_res->ops) { + addon_res->ops->write(dev, res, reg); + return; + } + } else + reg = pci_resource_bar(dev, resno, &type); + + if (!reg) + return; + pcibios_resource_to_bus(dev, ®ion, res); new = region.start | (res->flags & PCI_REGION_FLAG_MASK); @@ -60,9 +75,6 @@ void pci_update_resource(struct pci_dev *dev, int resno) else mask = (u32)PCI_BASE_ADDRESS_MEM_MASK; - reg = pci_resource_bar(dev, resno, &type); - if (!reg) - return; if (type != pci_bar_unknown) { if (!(res->flags & IORESOURCE_ROM_ENABLE)) return; @@ -286,7 +298,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno) if (!ret) { res->flags &= ~IORESOURCE_STARTALIGN; dev_info(&dev->dev, "BAR %d: assigned %pR\n", resno, res); - if (resno < PCI_BRIDGE_RESOURCES) + if (!is_pci_bridge_resource_idx(resno)) pci_update_resource(dev, resno); } return ret; @@ -311,7 +323,7 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz if (!ret) { res->flags &= ~IORESOURCE_STARTALIGN; dev_info(&dev->dev, "BAR %d: reassigned %pR\n", resno, res); - if (resno < PCI_BRIDGE_RESOURCES) + if (!is_pci_bridge_resource_idx(resno)) pci_update_resource(dev, resno); } return ret; |