diff options
author | Samuel Holland <samuel@sholland.org> | 2023-01-22 03:02:52 +0300 |
---|---|---|
committer | Sean Anderson <seanga2@gmail.com> | 2023-02-12 21:44:20 +0300 |
commit | 5a675abfe7c3f12b475cc0a6c9074a9fbe0b6bb6 (patch) | |
tree | 7238a9ae0b06ea7d60c82497af56334efee234cb /drivers | |
parent | 2050f824e1367cb227d8e13a91c98577987fe413 (diff) | |
download | u-boot-5a675abfe7c3f12b475cc0a6c9074a9fbe0b6bb6.tar.xz |
reset: Allow reset_get_by_name() with NULL name
This allows devm_reset_control_get(dev, NULL) to work and get the first
reset control, which is common in code ported from Linux.
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/r/20230122000252.53642-2-samuel@sholland.org
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/reset/reset-uclass.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c index bcef46039c..b972faf013 100644 --- a/drivers/reset/reset-uclass.c +++ b/drivers/reset/reset-uclass.c @@ -147,16 +147,18 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk) int reset_get_by_name(struct udevice *dev, const char *name, struct reset_ctl *reset_ctl) { - int index; + int index = 0; debug("%s(dev=%p, name=%s, reset_ctl=%p)\n", __func__, dev, name, reset_ctl); reset_ctl->dev = NULL; - index = dev_read_stringlist_search(dev, "reset-names", name); - if (index < 0) { - debug("fdt_stringlist_search() failed: %d\n", index); - return index; + if (name) { + index = dev_read_stringlist_search(dev, "reset-names", name); + if (index < 0) { + debug("fdt_stringlist_search() failed: %d\n", index); + return index; + } } return reset_get_by_index(dev, index, reset_ctl); |