summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-08-10 07:05:04 -0600
committerSimon Glass <sjg@chromium.org>2015-08-14 03:24:21 -0600
commit76c3fbcd3db61b9a3d9c38b0c18968322c5b1588 (patch)
treef249db33f5aab55cca438a4eac045d96b6560d3d /include
parent66afb4ed924693412f2f4e05fbfae6a642159402 (diff)
dm: pci: Add a way to iterate through all PCI devices
These functions allow iteration through all PCI devices including bridges. The children of each PCI bus are returned in turn. This can be useful for configuring, checking or enumerating all the devices. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/pci.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/include/pci.h b/include/pci.h
index d1e2765cac..488ff44c53 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -910,6 +910,31 @@ int pci_bus_find_devfn(struct udevice *bus, pci_dev_t find_devfn,
struct udevice **devp);
/**
+ * pci_find_first_device() - return the first available PCI device
+ *
+ * This function and pci_find_first_device() allow iteration through all
+ * available PCI devices on all buses. Assuming there are any, this will
+ * return the first one.
+ *
+ * @devp: Set to the first available device, or NULL if no more are left
+ * or we got an error
+ * @return 0 if all is OK, -ve on error (e.g. a bus/bridge failed to probe)
+ */
+int pci_find_first_device(struct udevice **devp);
+
+/**
+ * pci_find_next_device() - return the next available PCI device
+ *
+ * Finds the next available PCI device after the one supplied, or sets @devp
+ * to NULL if there are no more.
+ *
+ * @devp: On entry, the last device returned. Set to the next available
+ * device, or NULL if no more are left or we got an error
+ * @return 0 if all is OK, -ve on error (e.g. a bus/bridge failed to probe)
+ */
+int pci_find_next_device(struct udevice **devp);
+
+/**
* pci_get_ff() - Returns a mask for the given access size
*
* @size: Access size