[PATCH] soc: fsl: cpm1: tsa: switch to for_each_available_child_of_node_scoped()
Herve Codina
herve.codina at bootlin.com
Thu Nov 14 18:14:31 AEDT 2024
Hi Javier,
On Wed, 02 Oct 2024 22:21:51 +0200
Javier Carrasco <javier.carrasco.cruz at gmail.com> 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 at gmail.com>
> ---
> drivers/soc/fsl/qe/tsa.c | 28 ++++------------------------
> 1 file changed, 4 insertions(+), 24 deletions(-)
Acked-by: Herve Codina <herve.codina at bootlin.com>
Best regards,
Hervé
More information about the Linuxppc-dev
mailing list