diff options
author | Simon Glass <sjg@chromium.org> | 2022-04-24 23:31:00 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-04-25 10:00:03 -0400 |
commit | 4e0710a2d007032c8a82ef3af45a0e6e9176a2a7 (patch) | |
tree | dbfcd2034200743eac28ce5b8ef3dbcd93fc7e95 /drivers/core | |
parent | 6aa4fe39122a85ce1ef559139518fa5042406186 (diff) | |
download | u-boot-4e0710a2d007032c8a82ef3af45a0e6e9176a2a7.zip u-boot-4e0710a2d007032c8a82ef3af45a0e6e9176a2a7.tar.gz u-boot-4e0710a2d007032c8a82ef3af45a0e6e9176a2a7.tar.bz2 |
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 <sjg@chromium.org>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/uclass.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/core/uclass.c b/drivers/core/uclass.c index 4b9b54f..08d9ed8 100644 --- a/drivers/core/uclass.c +++ b/drivers/core/uclass.c @@ -274,8 +274,8 @@ int uclass_find_next_device(struct udevice **devp) return 0; } -int uclass_find_device_by_name(enum uclass_id id, const char *name, - struct udevice **devp) +int uclass_find_device_by_namelen(enum uclass_id id, const char *name, int len, + struct udevice **devp) { struct uclass *uc; struct udevice *dev; @@ -289,7 +289,8 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, return ret; uclass_foreach_dev(dev, uc) { - if (!strcmp(dev->name, name)) { + if (!strncmp(dev->name, name, len) && + strlen(dev->name) == len) { *devp = dev; return 0; } @@ -298,6 +299,12 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name, return -ENODEV; } +int uclass_find_device_by_name(enum uclass_id id, const char *name, + struct udevice **devp) +{ + return uclass_find_device_by_namelen(id, name, strlen(name), devp); +} + int uclass_find_next_free_seq(struct uclass *uc) { struct udevice *dev; |