From 2693047acdcdae20b066715d0da4937814347935 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 23 Jun 2015 15:38:37 -0600 Subject: dm: core: Add a function to find any device from device tree In some rare cases it is useful to be able to locate a device given a device tree node offset. An example is when you have an alias that points to a node and you want to find the associated device. The device may be SPI, MMC or something else, but you don't need to know the uclass to find it. Add a function to do a global search for a device, given its device tree offset. Signed-off-by: Simon Glass --- include/dm/device.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index 18296bb6861..9a94ee19d9c 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -389,6 +389,20 @@ int device_find_child_by_of_offset(struct udevice *parent, int of_offset, int device_get_child_by_of_offset(struct udevice *parent, int seq, struct udevice **devp); +/** + * device_get_global_by_of_offset() - Get a device based on FDT offset + * + * Locates a device by its device tree offset, searching globally throughout + * the all driver model devices. + * + * The device is probed to activate it ready for use. + * + * @of_offset: Device tree offset to find + * @devp: Returns pointer to device if found, otherwise this is set to NULL + * @return 0 if OK, -ve on error + */ +int device_get_global_by_of_offset(int of_offset, struct udevice **devp); + /** * device_find_first_child() - Find the first child of a device * -- cgit v1.3.1