[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d9bdc1b6-ea7e-47aa-80aa-02ae649abf72@csgroup.eu>
Date: Wed, 2 Oct 2024 22:43:46 +0200
From: Christophe Leroy <christophe.leroy@...roup.eu>
To: Markus Elfring <Markus.Elfring@....de>, linuxppc-dev@...ts.ozlabs.org,
Jani Nikula <jani.nikula@...el.com>,
Madhavan Srinivasan <maddy@...ux.ibm.com>,
Michael Ellerman <mpe@...erman.id.au>, Naveen N Rao <naveen@...nel.org>,
Nicholas Piggin <npiggin@...il.com>, Paul Mackerras <paulus@...ba.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Thomas Zimmermann <tzimmermann@...e.de>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: Re: [PATCH] powermac: Call of_node_put(bk_node) only once in
pmac_has_backlight_type()
Le 02/10/2024 à 22:02, Markus Elfring a écrit :
> From: Markus Elfring <elfring@...rs.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@...rs.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
>
Powered by blists - more mailing lists