Skip to contentSkip to conversation

reset: don't overwrite fwnode_reset_n_cells

PATCH Applied Bartosz Golaszewski 6 participants 7 messages Mar 10 – Mar 11 Reset controller framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reset: don't overwrite fwnode_reset_n_cells

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")
---
 drivers/reset/core.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/reset/core.c +7 -6
index e625cf59cfb0..4d27bbea1a69 100644
@@ -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);
Signature · 1 line
2.47.3
#1 lore raw

Hi Bartosz,

Hi Bartosz,

Thanks for your patch!

Quoted 1 line · Bartosz Golaszewski

Fix a logic bug in reser_register() where we set fwnode_reset_n_cells to

One more non-existing function ;-)

reset_controller_register()

Quoted 8 lines

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.

Quoted 4 lines
Fixes ba8dbbb14b7e ("reset: convert the core API to using firmware nodes")

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw
Quoted 7 lines · Geert Uytterhoeven

Hi Bartosz,

Hi Bartosz,

Thanks for your patch!

Quoted 8 lines
Quoted 1 line · Bartosz Golaszewski

Fix a logic bug in reser_register() where we set fwnode_reset_n_cells to

One more non-existing function ;-)

reset_controller_register()

Gah! If Mark says it fixes the issue, I'll either resend it with commit message fixed or maybe Philipp can fix it when applying.

Bart

maintainer Reviewed-by
#3 lore raw
Quoted 12 lines · Bartosz Golaszewski
Quoted 11 lines · Geert Uytterhoeven

Hi Bartosz,

Hi Bartosz,

Thanks for your patch!

Quoted 1 line · Bartosz Golaszewski

Fix a logic bug in reser_register() where we set fwnode_reset_n_cells to

Quoted 7 lines
Quoted 4 lines

One more non-existing function ;-)

reset_controller_register()

Gah! If Mark says it fixes the issue, I'll either resend it with commit message fixed or maybe Philipp can fix it when applying.

I'll do that.

regards
Philipp

maintainer Applied
#5 lore raw
In reply to Bartosz Golaszewski

Hi Bartosz, Mark,

Quoted 9 lines · Bartosz Golaszewski

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.

Quoted 4 lines
Fixes ba8dbbb14b7e ("reset: convert the core API to using firmware nodes")

Applied to reset/next, thank you!

[1/1] reset: don't overwrite fwnode_reset_n_cells

      https://git.pengutronix.de/cgit/pza/linux/commit/?id=62d11b80ea5d

regards
Philipp

Tested-by on v1 1/1
#6 lore raw
In reply to Bartosz Golaszewski

Hi Bartosz,
Thanks for your patch.

Quoted 10 lines · Bartosz Golaszewski

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")

Tested on RZ/G3E.

Kind Regards,
Tommaso

Quoted 42 lines
---
 drivers/reset/core.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/reset/core.c +7 -6
index e625cf59cfb0..4d27bbea1a69 100644
@@ -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);
Signature · 1 line
2.47.3