aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-12-21 10:33:26 -0500
committerBjorn Helgaas <bhelgaas@google.com>2013-12-21 12:07:46 -0500
commit06cf56e497c8c1469b0931caa7d5b1d827655fe2 (patch)
tree2d81aadde5d73e3b96ae41468c9d3b5648c352d1
parentfc2798502f860b18f3c7121e4dc659d3d9d28d74 (diff)
PCI: Add pci_bus_address() to get bus address of a BAR
We store BAR information as a struct resource, which contains the CPU address, not the bus address. Drivers often need the bus address, and there's currently no convenient way to get it, so they often read the BAR directly, or use the resource address (which doesn't work if there's any translation between CPU and bus addresses). Add pci_bus_address() to make this convenient. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r--include/linux/pci.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/pci.h b/include/linux/pci.h
index bf32412704a7..966b286b5d53 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1077,6 +1077,14 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
1077 resource_size_t), 1077 resource_size_t),
1078 void *alignf_data); 1078 void *alignf_data);
1079 1079
1080static inline dma_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
1081{
1082 struct pci_bus_region region;
1083
1084 pcibios_resource_to_bus(pdev->bus, &region, &pdev->resource[bar]);
1085 return region.start;
1086}
1087
1080/* Proper probing supporting hot-pluggable devices */ 1088/* Proper probing supporting hot-pluggable devices */
1081int __must_check __pci_register_driver(struct pci_driver *, struct module *, 1089int __must_check __pci_register_driver(struct pci_driver *, struct module *,
1082 const char *mod_name); 1090 const char *mod_name);