diff options
-rw-r--r-- | drivers/reset/reset-uclass.c | 12 | ||||
-rw-r--r-- | include/reset.h | 3 | ||||
-rw-r--r-- | test/dm/reset.c | 3 |
3 files changed, 10 insertions, 8 deletions
diff --git a/drivers/reset/reset-uclass.c b/drivers/reset/reset-uclass.c index bcef46039c2..b972faf0132 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); diff --git a/include/reset.h b/include/reset.h index 965f02e0cee..036a786d2ac 100644 --- a/include/reset.h +++ b/include/reset.h @@ -238,7 +238,8 @@ int reset_get_bulk(struct udevice *dev, struct reset_ctl_bulk *bulk); * * @dev: The client device. * @name: The name of the reset signal to request, within the client's - * list of reset signals. + * list of reset signals, or NULL to request the first reset + * signal in the list. * @reset_ctl: A pointer to a reset control struct to initialize. * Return: 0 if OK, or a negative error code. */ diff --git a/test/dm/reset.c b/test/dm/reset.c index 9c004523364..e2d6f456230 100644 --- a/test/dm/reset.c +++ b/test/dm/reset.c @@ -35,8 +35,7 @@ static int dm_test_reset_base(struct unit_test_state *uts) /* Get the same reset port in 2 different ways and compare */ ut_assertok(reset_get_by_index(dev, 0, &reset_method1)); - ut_assertok(reset_get_by_index_nodev(dev_ofnode(dev), 0, - &reset_method1_1)); + ut_assertok(reset_get_by_name(dev, NULL, &reset_method1_1)); ut_assertok(reset_get_by_index(dev, 1, &reset_method2)); ut_assertok(reset_get_by_index_nodev(dev_ofnode(dev), 1, &reset_method2_1)); |