[PATCH v2] reset: core: honour optional resets when the GPIO fallback returns -ENOENT

From: Yang Siyuan

Date: Tue Nov 17 2026 - 04:55:28 EST


__fwnode_reset_control_get() honours RESET_CONTROL_FLAGS_BIT_OPTIONAL by
returning NULL when the requested reset is not described in the device
tree. The reset-gpio fallback breaks this: when
__reset_add_reset_gpio_device() fails with -ENOENT, the error is returned
even for an optional reset.

This is reachable on Allwinner SoCs, whose pinctrl uses three-cell GPIO
specifiers. The reset-gpio fallback only supports two cells, so it
returns -ENOENT and a consumer asking for an optional reset fails to
probe instead of falling back to its own GPIO handling. mmc-pwrseq-simple
on the Anbernic RG35XX family hits this: its wifi_pwrseq node has
reset-gpios but no resets, so the SDIO WiFi adapter never probes.

Return NULL only for -ENOENT when the reset was requested as optional.
A reset that is described but cannot be used is still an error, so
-EPROBE_DEFER and all other failures are propagated.

Fixes: c721f189e89c ("reset: Instantiate reset GPIO controller for shared reset-gpios")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yang Siyuan <hsyysy@xxxxxxx>
---
Changes in v2:
- Only translate -ENOENT to NULL for an optional reset; propagate all
other errors, as suggested by Philipp Zabel.

drivers/reset/core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 38e189d..daa4038 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -1181,6 +1181,8 @@ __fwnode_reset_control_get(struct fwnode_handle *fwnode, const char *id, int ind
ret = __reset_add_reset_gpio_device(fwnode, &args);
if (ret) {
fwnode_handle_put(args.fwnode);
+ if (ret == -ENOENT && optional)
+ return NULL;
return ERR_PTR(ret);
}
}

base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.56.1