[PATCH] powermac: Call of_node_put(bk_node) only once in pmac_has_backlight_type()
Christophe Leroy
christophe.leroy at csgroup.eu
Thu Oct 3 06:43:46 AEST 2024
Le 02/10/2024 à 22:02, Markus Elfring a écrit :
> From: Markus Elfring <elfring at users.sourceforge.net>
> Date: Wed, 2 Oct 2024 21:50:27 +0200
>
> An of_node_put(bk_node) call was immediately used after a pointer check
> for an of_get_property() call in this function implementation.
> Thus call such a function only once instead directly before the check.
It seems pointless to perform a put immediately after a get. Shouldn't
of_find_property() be used instead ? And then of_property_read_string()
would probably be better.
Maybe you can even use of_property_match_string().
>
> This issue was transformed by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
> ---
> arch/powerpc/platforms/powermac/backlight.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
> index 12bc01353bd3..d3666595a62e 100644
> --- a/arch/powerpc/platforms/powermac/backlight.c
> +++ b/arch/powerpc/platforms/powermac/backlight.c
> @@ -61,11 +61,9 @@ int pmac_has_backlight_type(const char *type)
> if (bk_node) {
> const char *prop = of_get_property(bk_node,
> "backlight-control", NULL);
> - if (prop && strncmp(prop, type, strlen(type)) == 0) {
> - of_node_put(bk_node);
> - return 1;
> - }
> of_node_put(bk_node);
> + if (prop && strncmp(prop, type, strlen(type)) == 0)
> + return 1;
> }
>
> return 0;
> --
> 2.46.1
>
More information about the Linuxppc-dev
mailing list