mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Philipp Zabel <p.zabel@pengutronix.de>,
	Mark Brown <broonie@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-kernel@vger.kernel.org, brgl@kernel.org,
	Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Subject: [PATCH] reset: don't overwrite fwnode_reset_n_cells
Date: Tue, 10 Mar 2026 16:15:15 +0100	[thread overview]
Message-ID: <20260310151515.34681-1-bartosz.golaszewski@oss.qualcomm.com> (raw)

Fix a logic bug in reser_register() where we set fwnode_reset_n_cells to
1 if fwnode is set and fwnode_xlate is not but we do it after assigning
of_fwnode_handle(of_node) to fwnode.

Modify the logic to: assign fwnode from of_node if applicable, if fwnode
is still not set, try to get it from the device and only then check
of_xlate and fwnode_xlate and either assign fwnode_reset_n_cells from OF
or default to fwnode_reset_simple_xlate and fwnode_reset_n_cells = 1.

Fixes: ba8dbbb14b7e ("reset: convert the core API to using firmware nodes")
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/all/0b72286b-33dd-4bc9-8c0e-161c2f4baed8@sirena.org.uk/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 drivers/reset/core.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index e625cf59cfb0..4d27bbea1a69 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -132,20 +132,21 @@ int reset_controller_register(struct reset_controller_dev *rcdev)
 	if ((rcdev->of_node && rcdev->fwnode) || (rcdev->of_xlate && rcdev->fwnode_xlate))
 		return -EINVAL;
 
-	if (!rcdev->of_node && !rcdev->fwnode) {
+	if (rcdev->of_node && !rcdev->fwnode)
+		rcdev->fwnode = of_fwnode_handle(rcdev->of_node);
+
+	if (!rcdev->fwnode) {
 		rcdev->fwnode = dev_fwnode(rcdev->dev);
 		if (!rcdev->fwnode)
 			return -EINVAL;
 	}
 
-	if (rcdev->of_node) {
-		rcdev->fwnode = of_fwnode_handle(rcdev->of_node);
+	if (rcdev->of_xlate)
 		rcdev->fwnode_reset_n_cells = rcdev->of_reset_n_cells;
-	}
 
-	if (rcdev->fwnode && !rcdev->fwnode_xlate) {
-		rcdev->fwnode_reset_n_cells = 1;
+	if (!rcdev->fwnode_xlate && !rcdev->of_xlate) {
 		rcdev->fwnode_xlate = fwnode_reset_simple_xlate;
+		rcdev->fwnode_reset_n_cells = 1;
 	}
 
 	INIT_LIST_HEAD(&rcdev->reset_control_head);
-- 
2.47.3


             reply	other threads:[~2026-03-10 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-10 15:15 Bartosz Golaszewski [this message]
2026-03-10 15:17 ` Geert Uytterhoeven
2026-03-10 15:19   ` Bartosz Golaszewski
2026-03-11  7:25     ` Philipp Zabel
2026-03-10 16:38 ` Mark Brown
2026-03-11  7:51 ` Philipp Zabel
2026-03-11 16:11 ` Tommaso Merciai

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=20260310151515.34681-1-bartosz.golaszewski@oss.qualcomm.com \
    --to=bartosz.golaszewski@oss.qualcomm.com \
    --cc=brgl@kernel.org \
    --cc=broonie@kernel.org \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®