Re: [PATCH] soc: fsl: cpm1: tsa: switch to for_each_available_child_of_node_scoped()

From: Herve Codina
Date: Thu Nov 14 2024 - 02:14:45 EST


Hi Javier,

On Wed, 02 Oct 2024 22:21:51 +0200
Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx> wrote:

> The non-scoped variant of this macro turns error-prone as soon as error
> paths are included, because explicit calls to of_node_put() are required
> to avoid leaking memory.
>
> Using its scoped counterpart simplifies the code by removing the need of
> explicit calls to of_node_put(), as they are automatically triggered as
> soon as the child node goes out of scope. Moreover, it is more robust as
> it accounts for new error paths without having to worry about
> decrementing the object's refcount.
>
> Note that the device_node is declared within the macro, and its explicit
> declaration can be dropped as well if it is not used anywhere else.
>
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@xxxxxxxxx>
> ---
> drivers/soc/fsl/qe/tsa.c | 28 ++++------------------------
> 1 file changed, 4 insertions(+), 24 deletions(-)

Acked-by: Herve Codina <herve.codina@xxxxxxxxxxx>

Best regards,
Hervé