Re: [PATCH] reset: don't overwrite fwnode_reset_n_cells
From: Tommaso Merciai
Date: Wed Mar 11 2026 - 12:13:58 EST
Hi Bartosz,
Thanks for your patch.
On Tue, Mar 10, 2026 at 04:15:15PM +0100, Bartosz Golaszewski wrote:
> 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.
Tested-by: Tommaso Merciai <tommaso.merciai.xr@xxxxxxxxxxxxxx>
Kind Regards,
Tommaso
> Reported-by: Mark Brown <broonie@xxxxxxxxxx>
> Closes: https://lore.kernel.org/all/0b72286b-33dd-4bc9-8c0e-161c2f4baed8@xxxxxxxxxxxxx/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
> ---
> 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
>