[PATCH 2/2] reset: Allow reset_get_by_name() with NULL name

Samuel Holland samuel at sholland.org
Mon Nov 28 06:53:59 CET 2022


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 at sholland.org>
---

 drivers/reset/reset-uclass.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c
index bcef46039c2..a26c623a77e 100644
--- a/drivers/reset/reset-uclass.c
+++ b/drivers/reset/reset-uclass.c
@@ -147,13 +147,14 @@ 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 (name)
+		index = dev_read_stringlist_search(dev, "reset-names", name);
 	if (index < 0) {
 		debug("fdt_stringlist_search() failed: %d\n", index);
 		return index;
-- 
2.37.4



More information about the U-Boot mailing list