[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkda9W7SjX+saGY9U5ct6MdD_f-B6C0PTF0OffCRPEsEnrQ@mail.gmail.com>
Date: Thu, 16 May 2024 23:05:47 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Luiz Angelo Daros de Luca <luizluca@...il.com>
Cc: Jakub Kicinski <kuba@...nel.org>, Alvin Šipraga <alsi@...g-olufsen.dk>,
Andrew Lunn <andrew@...n.ch>, Florian Fainelli <f.fainelli@...il.com>,
Vladimir Oltean <olteanv@...il.com>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>, Conor Dooley <conor+dt@...nel.org>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org
Subject: Re: [PATCH net-next v2 3/3] net: dsa: realtek: add LED drivers for rtl8366rb
On Thu, May 16, 2024 at 7:30 PM Luiz Angelo Daros de Luca
<luizluca@...il.com> wrote:
> > On Sat, 27 Apr 2024 02:11:30 -0300 Luiz Angelo Daros de Luca wrote:
> > > +static int rtl8366rb_setup_leds(struct realtek_priv *priv)
> > > +{
> > > + struct device_node *leds_np, *led_np;
> > > + struct dsa_switch *ds = &priv->ds;
> > > + struct dsa_port *dp;
> > > + int ret = 0;
> > > +
> > > + dsa_switch_for_each_port(dp, ds) {
> > > + if (!dp->dn)
> > > + continue;
> > > +
> > > + leds_np = of_get_child_by_name(dp->dn, "leds");
> > > + if (!leds_np) {
> > > + dev_dbg(priv->dev, "No leds defined for port %d",
> > > + dp->index);
> > > + continue;
> > > + }
> > > +
> > > + for_each_child_of_node(leds_np, led_np) {
> > > + ret = rtl8366rb_setup_led(priv, dp,
> > > + of_fwnode_handle(led_np));
> > > + if (ret) {
> > > + of_node_put(led_np);
> > > + break;
> > > + }
> > > + }
> > > +
> > > + of_node_put(leds_np);
> > > + if (ret)
> > > + return ret;
> > > + }
> > > + return 0;
> > > +}
> >
> > coccicheck generates this warning:
> >
> > drivers/net/dsa/realtek/rtl8366rb.c:1032:4-15: ERROR: probable double put.
> >
> > I think it's a false positive.
>
> Me too. I don't think it is a double put. The put for led_np is called
> in the increment code inside the for_each_child_of_node macro. With a
> break, we skip that part and we need to put it before leaving. I don't
> know coccicheck but maybe it got confused by the double for.
Maybe I can use for_each_child_of_node_scoped() and
get the handling for free? The checkers should learn about
*_scoped now.
(I'm still working on the patch, I'm just slow.)
Yours,
Linus Walleij
Powered by blists - more mailing lists