From 4e0710a2d007032c8a82ef3af45a0e6e9176a2a7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 24 Apr 2022 23:31:00 -0600 Subject: dm: core: Allow finding a uclass device by partial name In some cases two devices are related and the only way to tell is to check that the names partially patch. Add a way to check this without needing to create a new string for the comparison. Fix the comment for device_find_child_by_namelen() while we are here. Signed-off-by: Simon Glass --- include/dm/device.h | 2 +- include/dm/uclass-internal.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/dm/device.h b/include/dm/device.h index e0f86f5..b474888 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -799,7 +799,7 @@ int device_find_first_child_by_uclass(const struct udevice *parent, struct udevice **devp); /** - * device_find_child_by_name() - Find a child by device name + * device_find_child_by_namelen() - Find a child by device name * * @parent: Parent device to search * @name: Name to look for diff --git a/include/dm/uclass-internal.h b/include/dm/uclass-internal.h index daf856c..3ddcdd2 100644 --- a/include/dm/uclass-internal.h +++ b/include/dm/uclass-internal.h @@ -155,6 +155,22 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp); int uclass_find_next_device(struct udevice **devp); /** + * uclass_find_device_by_namelen() - Find uclass device based on ID and name + * + * This searches for a device with the exactly given name. + * + * The device is NOT probed, it is merely returned. + * + * @id: ID to look up + * @name: name of a device to find + * @len: Length of @name (the uclass driver name must have the same length) + * @devp: Returns pointer to device (the first one with the name) + * Return: 0 if OK, -ve on error + */ +int uclass_find_device_by_namelen(enum uclass_id id, const char *name, int len, + struct udevice **devp); + +/** * uclass_find_device_by_name() - Find uclass device based on ID and name * * This searches for a device with the exactly given name. -- cgit v1.1