Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

of/address: Add of_find_matching_node_by_address helper

of_find_matching_node_by_address() can be used to find a device tree
node for a device at a specific address.

Signed-off-by: Grant Likely <grant.likely@secretlab.ca>

+22
+18
drivers/of/address.c
··· 577 577 } 578 578 EXPORT_SYMBOL_GPL(of_address_to_resource); 579 579 580 + struct device_node *of_find_matching_node_by_address(struct device_node *from, 581 + const struct of_device_id *matches, 582 + u64 base_address) 583 + { 584 + struct device_node *dn = of_find_matching_node(from, matches); 585 + struct resource res; 586 + 587 + while (dn) { 588 + if (of_address_to_resource(dn, 0, &res)) 589 + continue; 590 + if (res.start == base_address) 591 + return dn; 592 + dn = of_find_matching_node(dn, matches); 593 + } 594 + 595 + return NULL; 596 + } 597 + 580 598 581 599 /** 582 600 * of_iomap - Maps the memory mapped IO for a given device_node
+4
include/linux/of_address.h
··· 6 6 extern u64 of_translate_address(struct device_node *np, const __be32 *addr); 7 7 extern int of_address_to_resource(struct device_node *dev, int index, 8 8 struct resource *r); 9 + extern struct device_node *of_find_matching_node_by_address( 10 + struct device_node *from, 11 + const struct of_device_id *matches, 12 + u64 base_address); 9 13 extern void __iomem *of_iomap(struct device_node *device, int index); 10 14 11 15 /* Extract an address from a device, returns the region size and