[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e50907a9-6df7-4cbf-97a6-47acd5d8ce01@stanley.mountain>
Date: Sun, 13 Oct 2024 16:41:08 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Christophe Leroy <christophe.leroy@...roup.eu>
Cc: 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>,
LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Subject: Re: [PATCH] powermac: Use of_property_match_string() in
pmac_has_backlight_type()
On Fri, Oct 11, 2024 at 06:25:45PM +0200, Christophe Leroy wrote:
> > diff --git a/arch/powerpc/platforms/powermac/backlight.c b/arch/powerpc/platforms/powermac/backlight.c
> > index 12bc01353bd3..79741370c40c 100644
> > --- a/arch/powerpc/platforms/powermac/backlight.c
> > +++ b/arch/powerpc/platforms/powermac/backlight.c
> > @@ -57,18 +57,10 @@ struct backlight_device *pmac_backlight;
> > int pmac_has_backlight_type(const char *type)
> > {
> > struct device_node* bk_node = of_find_node_by_name(NULL, "backlight");
> > + int i = of_property_match_string(bk_node, "backlight-control", 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);
> > - }
> > -
> > - return 0;
> > + of_node_put(bk_node);
> > + return i >= 0;
>
> Could have been:
>
> return !IS_ERR_VALUE(i);
>
IS_ERR_VALUE() macro should only be used when you're dealing with memory
addresses. What I mean is there places in mm/ where we pass addresses as
unsigned long values instead of pointers. For example, get_unmapped_area()
returns unsigned long. The IS_ERR_VALUE() macro is necessary for that.
For regular error codes, we can just check for negatives. we don't have do
anything fancy.
Of course, you can find counter examples, like msm_iommu_attach_dev() or
st_fdma_of_xlate(). <small joke>But in those cases, it's done to deliberately
to ensure that the code will never accidentally get built on 64bit systems.
</small joke>
regards,
dan carpenter
Powered by blists - more mailing lists