From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-renesas-soc@vger.kernel.org
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	linux-kernel@vger.kernel.org,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver
Date: Wed, 15 Oct 2025 22:59:21 +0200	[thread overview]
Message-ID: <20251015205919.12678-5-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20251015205919.12678-4-wsa+renesas@sang-engineering.com>
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@sang-engineering.com>
---
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
next prev parent reply	other threads:[~2025-10-15 20:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 20:59 [PATCH v2 0/2] reset: handle RESET_GPIO better to provide the fallback Wolfram Sang
2025-10-15 20:59 ` Wolfram Sang [this message]
2025-10-17  9:35   ` [PATCH v2 1/2] reset: always bail out on missing RESET_GPIO driver Philipp Zabel
2025-10-30 11:59   ` Philipp Zabel
2025-10-30 12:54   ` Philipp Zabel
2025-10-15 20:59 ` [PATCH v2 2/2] reset: always include RESET_GPIO driver if possible Wolfram Sang
2025-10-16 13:02   ` Geert Uytterhoeven
2025-10-16 14:27     ` Wolfram Sang
2025-10-17 10:16       ` Bartosz Golaszewski
2025-10-17 10:48         ` Wolfram Sang
2025-10-17 11:09           ` Bartosz Golaszewski
2025-10-17 11:25             ` Wolfram Sang
2025-10-17 17:02               ` Bartosz Golaszewski
2025-10-22  9:07                 ` Philipp Zabel
2025-10-23  9:22                   ` Wolfram Sang
2025-10-23  9:37                     ` Bartosz Golaszewski
2025-10-23 11:18                       ` Wolfram Sang
2025-10-23 12:04                         ` Bartosz Golaszewski
2025-10-23 12:51                           ` Wolfram Sang
2025-10-17  9:42     ` Philipp Zabel
2025-10-17  9:46       ` Wolfram Sang
2025-10-17  9:35   ` Philipp Zabel
2025-10-17  9:43     ` Wolfram Sang
2025-10-16  0:02 ` [PATCH v2 0/2] reset: handle RESET_GPIO better to provide the fallback Kuninori Morimoto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=20251015205919.12678-5-wsa+renesas@sang-engineering.com \
    --to=wsa+renesas@sang-engineering.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).