From 40bb637dae10abff32ca2d952fd443e0e09fd524 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 18 May 2017 20:09:09 -0600 Subject: dm: core: Add a way to find a device by ofnode Add a function which looks up a device by its node (either in live tree or flat tree). Signed-off-by: Simon Glass --- include/dm/uclass-internal.h | 18 ++++++++++++++++++ include/dm/uclass.h | 17 +++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'include') diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index ad284b8445..c086004318 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -10,6 +10,8 @@ #ifndef _DM_UCLASS_INTERNAL_H #define _DM_UCLASS_INTERNAL_H +#include + /** * uclass_get_device_tail() - handle the end of a get_device call * @@ -114,6 +116,22 @@ int uclass_find_device_by_seq(enum uclass_id id, int seq_or_req_seq, int uclass_find_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp); +/** + * uclass_find_device_by_of_node() - Find a uclass device by device tree node + * + * This searches the devices in the uclass for one attached to the given + * device tree node. + * + * The device is NOT probed, it is merely returned. + * + * @id: ID to look up + * @node: Device tree offset to search for (if NULL then -ENODEV is returned) + * @devp: Returns pointer to device (there is only one for each node) + * @return 0 if OK, -ve on error + */ +int uclass_find_device_by_ofnode(enum uclass_id id, ofnode node, + struct udevice **devp); + /** * uclass_bind_device() - Associate device with a uclass * diff --git a/include/dm/uclass.h b/include/dm/uclass.h index b583aa869b..7f5a1304b5 100644 --- a/include/dm/uclass.h +++ b/include/dm/uclass.h @@ -10,6 +10,7 @@ #ifndef _DM_UCLASS_H #define _DM_UCLASS_H +#include #include #include #include @@ -185,6 +186,22 @@ int uclass_get_device_by_seq(enum uclass_id id, int seq, struct udevice **devp); int uclass_get_device_by_of_offset(enum uclass_id id, int node, struct udevice **devp); +/** + * uclass_get_device_by_ofnode() - Get a uclass device by device tree node + * + * This searches the devices in the uclass for one attached to the given + * device tree node. + * + * The device is probed to activate it ready for use. + * + * @id: ID to look up + * @np: Device tree node to search for (if NULL then -ENODEV is returned) + * @devp: Returns pointer to device (there is only one for each node) + * @return 0 if OK, -ve on error + */ +int uclass_get_device_by_ofnode(enum uclass_id id, ofnode node, + struct udevice **devp); + /** * uclass_get_device_by_phandle() - Get a uclass device by phandle * -- cgit