summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-10-24 02:26:08 +0300
committerSimon Glass <sjg@chromium.org>2021-11-29 02:51:51 +0300
commit4b030177b6608bc6f2508e023089112e8adb2f4b (patch)
treeaa80d60404bb5c60c8ebfea451f57120c3a76bf6 /include/dm
parent075bfc9575aedca15e61f5f1cfa300409e2979fe (diff)
downloadu-boot-4b030177b6608bc6f2508e023089112e8adb2f4b.tar.xz
dm: core: Allow finding children / uclasses by partial name
In some cases it is useful to search just by a partial name, such as when looking for a sibling device that has a common name substring. Add helper functions to handle these requirements. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/device.h12
-rw-r--r--include/dm/uclass.h9
2 files changed, 21 insertions, 0 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 3028d002ab..daf28a0a45 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -763,6 +763,18 @@ int device_find_first_child_by_uclass(const struct udevice *parent,
*
* @parent: Parent device to search
* @name: Name to look for
+ * @len: Length of the name
+ * @devp: Returns device found, if any
+ * @return 0 if found, else -ENODEV
+ */
+int device_find_child_by_namelen(const struct udevice *parent, const char *name,
+ int len, struct udevice **devp);
+
+/**
+ * device_find_child_by_name() - Find a child by device name
+ *
+ * @parent: Parent device to search
+ * @name: Name to look for
* @devp: Returns device found, if any
* @return 0 if found, else -ENODEV
*/
diff --git a/include/dm/uclass.h b/include/dm/uclass.h
index 15e5f9ef5b..aea2f34fce 100644
--- a/include/dm/uclass.h
+++ b/include/dm/uclass.h
@@ -176,6 +176,15 @@ const char *uclass_get_name(enum uclass_id id);
* uclass_get_by_name() - Look up a uclass by its driver name
*
* @name: Name to look up
+ * @len: Length of name
+ * @returns the associated uclass ID, or UCLASS_INVALID if not found
+ */
+enum uclass_id uclass_get_by_name_len(const char *name, int len);
+
+/**
+ * uclass_get_by_name() - Look up a uclass by its driver name
+ *
+ * @name: Name to look up
* @returns the associated uclass ID, or UCLASS_INVALID if not found
*/
enum uclass_id uclass_get_by_name(const char *name);