Skip to content

Commit

Permalink
PCI: Add pci_bus_address() to get bus address of a BAR
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Bjorn Helgaas committed Dec 21, 2013
1 parent fc27985 commit 06cf56e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,14 @@ int __must_check pci_bus_alloc_resource(struct pci_bus *bus,
resource_size_t),
void *alignf_data);

static inline dma_addr_t pci_bus_address(struct pci_dev *pdev, int bar)
{
struct pci_bus_region region;

pcibios_resource_to_bus(pdev->bus, &region, &pdev->resource[bar]);
return region.start;
}

/* Proper probing supporting hot-pluggable devices */
int __must_check __pci_register_driver(struct pci_driver *, struct module *,
const char *mod_name);
Expand Down

0 comments on commit 06cf56e

Please sign in to comment.