[PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
From: Wolfram Sang
Date: Wed Oct 15 2025 - 16:59:39 EST
Optional GPIOs mean they can be omitted. If they are described, a
failure in acquiring them still needs to be reported. When the
RESET_GPIO is not enabled (so the reset core cannot provide its assumed
fallback), the user should be informed about it. So, not only bail out
but also give a hint how to fix the situation. This means the check has
to be moved after ensuring the GPIO is really described.
Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
---
Changes since RFC v1:
* moved the code after second phandle check
* switched to pr_err
* updated commit message
* moved Reported-by to patch 2
drivers/reset/core.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 22f67fc77ae5..c1909074f715 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -1028,9 +1028,6 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
if (ret == -EINVAL)
return ERR_PTR(ret);
if (ret) {
- if (!IS_ENABLED(CONFIG_RESET_GPIO))
- return optional ? NULL : ERR_PTR(ret);
-
/*
* There can be only one reset-gpio for regular devices, so
* don't bother with the "reset-gpios" phandle index.
@@ -1040,6 +1037,11 @@ __of_reset_control_get(struct device_node *node, const char *id, int index,
if (ret)
return optional ? NULL : ERR_PTR(ret);
+ if (!IS_ENABLED(CONFIG_RESET_GPIO)) {
+ pr_err("%s(): RESET_GPIO driver not enabled, cannot fall back\n", __func__);
+ return ERR_PTR(-ENOEXEC);
+ }
+
gpio_fallback = true;
ret = __reset_add_reset_gpio_device(&args);
--
2.47.2