1 #include <linux/kernel.h>
2 #include <linux/export.h>
4 #include <linux/of_pci.h>
7 static inline int __of_pci_pci_compare(struct device_node *node,
11 const __be32 *reg = of_get_property(node, "reg", &size);
13 if (!reg || size < 5 * sizeof(__be32))
15 return ((be32_to_cpup(®[0]) >> 8) & 0xff) == devfn;
18 struct device_node *of_pci_find_child_device(struct device_node *parent,
21 struct device_node *node, *node2;
23 for_each_child_of_node(parent, node) {
24 if (__of_pci_pci_compare(node, devfn))
27 * Some OFs create a parent node "multifunc-device" as
28 * a fake root for all functions of a multi-function
29 * device we go down them as well.
31 if (!strcmp(node->name, "multifunc-device")) {
32 for_each_child_of_node(node, node2) {
33 if (__of_pci_pci_compare(node2, devfn)) {
42 EXPORT_SYMBOL_GPL(of_pci_find_child_device);