summaryrefslogtreecommitdiff
path: root/drivers/pci/pci-uclass.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-11-19 20:27:00 -0700
committerSimon Glass <sjg@chromium.org>2015-12-01 06:26:36 -0700
commit9f60fb0db4b70c65760cb1799b76de1c9b71644d (patch)
tree9c8f9d5815a9a2bb315b683d87fd446b2dbfc689 /drivers/pci/pci-uclass.c
parent9289db6c60bc9caa285fc6459db9236d92ba94f6 (diff)
dm: pci: Add a function to get the controller for a bus
A PCI bus may be a bridge device where the controller is the bridge's parent. Add a function to return the controller device, given a PCI device. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'drivers/pci/pci-uclass.c')
-rw-r--r--drivers/pci/pci-uclass.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index e38e0b2594..f3f5f007c8 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -53,6 +53,14 @@ struct pci_controller *pci_bus_to_hose(int busnum)
return dev_get_uclass_priv(bus);
}
+struct udevice *pci_get_controller(struct udevice *dev)
+{
+ while (device_is_on_pci_bus(dev))
+ dev = dev->parent;
+
+ return dev;
+}
+
pci_dev_t pci_get_bdf(struct udevice *dev)
{
struct pci_child_platdata *pplat = dev_get_parent_platdata(dev);