From: Simon Horman <horms@kernel.org>
To: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Cc: "Linus Walleij" <linus.walleij@linaro.org>,
"Alvin Šipraga" <alsi@bang-olufsen.dk>,
"Andrew Lunn" <andrew@lunn.ch>,
"Florian Fainelli" <f.fainelli@gmail.com>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 4/4] net: dsa: realtek: add LED drivers for rtl8366rb
Date: Sun, 10 Mar 2024 11:49:28 +0000 [thread overview]
Message-ID: <20240310114928.GB1623@kernel.org> (raw)
In-Reply-To: <20240310-realtek-led-v1-4-4d9813ce938e@gmail.com>
On Sun, Mar 10, 2024 at 01:52:01AM -0300, Luiz Angelo Daros de Luca wrote:
> This commit introduces LED drivers for rtl8366rb, enabling LEDs to be
> described in the device tree using the same format as qca8k. Each port
> can configure up to 4 LEDs.
>
> If all LEDs in a group use the default state "keep", they will use the
> default behavior after a reset. Changing the brightness of one LED,
> either manually or by a trigger, will disable the default hardware
> trigger and switch the entire LED group to manually controlled LEDs.
> Once in this mode, there is no way to revert to hardware-controlled LEDs
> (except by resetting the switch).
>
> Software triggers function as expected with manually controlled LEDs.
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/net/dsa/realtek/rtl8366rb.c | 270 ++++++++++++++++++++++++++++++++----
...
> +static int rtl8366rb_setup_led(struct realtek_priv *priv, struct dsa_port *dp,
> + struct fwnode_handle *led_fwnode)
> +{
> + struct rtl8366rb *rb = priv->chip_data;
> + struct led_init_data init_data = { };
> + struct rtl8366rb_led *led;
> + enum led_default_state state;
> + u32 led_group;
> + int ret;
nit: Please consider using reverse xmas tree - longest line to shortest -
for local variables in networking code.
...
> +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;
> +
> + 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);
FWIIW, Coccinelle complans about "probable double put" here.
But it looks correct to me as it's only called when breaking out of
the loop, when it is required AFAIK.
> + break;
> + }
> + }
> +
> + of_node_put(leds_np);
> + if (ret)
I'm unsure if this can happen. But if for_each_child_of_node()
iterates zero times then ret may be uninitialised here.
Flagged by Smatch.
> + return ret;
> + }
> + return 0;
> +}
...
next prev parent reply other threads:[~2024-03-10 11:49 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-10 4:51 [PATCH net-next 0/4] net: dsa: realtek: fix LED support for rtl8366 Luiz Angelo Daros de Luca
2024-03-10 4:51 ` [PATCH net-next 1/4] dt-bindings: net: dsa: realtek: describe LED usage Luiz Angelo Daros de Luca
2024-03-10 8:34 ` Krzysztof Kozlowski
2024-03-21 11:56 ` Luiz Angelo Daros de Luca
2024-03-21 12:18 ` Krzysztof Kozlowski
2024-03-24 2:10 ` Luiz Angelo Daros de Luca
2024-03-25 7:41 ` Krzysztof Kozlowski
2024-03-10 18:02 ` Andrew Lunn
2024-03-21 12:03 ` Luiz Angelo Daros de Luca
2024-03-10 18:31 ` Linus Walleij
2024-03-21 11:57 ` Luiz Angelo Daros de Luca
2024-03-10 18:52 ` Andrew Lunn
2024-03-21 11:58 ` Luiz Angelo Daros de Luca
2024-03-10 23:08 ` Rob Herring
2024-03-21 12:00 ` Luiz Angelo Daros de Luca
2024-03-10 4:51 ` [PATCH net-next 2/4] net: dsa: realtek: keep default LED state in rtl8366rb Luiz Angelo Daros de Luca
2024-03-10 8:01 ` Krzysztof Kozlowski
2024-03-10 11:37 ` Simon Horman
2024-03-10 11:47 ` Krzysztof Kozlowski
2024-03-11 16:11 ` Jakub Kicinski
2024-03-11 16:19 ` Krzysztof Kozlowski
2024-03-11 17:14 ` Jakub Kicinski
2024-03-11 18:40 ` Konstantin Ryabitsev
2024-03-11 18:52 ` Jakub Kicinski
2024-03-11 19:11 ` Konstantin Ryabitsev
2024-03-10 4:52 ` [PATCH net-next 3/4] net: dsa: realtek: do not assert reset on remove Luiz Angelo Daros de Luca
2024-03-10 18:33 ` Linus Walleij
2024-03-10 4:52 ` [PATCH net-next 4/4] net: dsa: realtek: add LED drivers for rtl8366rb Luiz Angelo Daros de Luca
2024-03-10 8:02 ` Krzysztof Kozlowski
2024-03-10 11:49 ` Simon Horman [this message]
2024-03-24 2:31 ` Luiz Angelo Daros de Luca
2024-03-10 18:47 ` Andrew Lunn
2024-03-24 3:46 ` Luiz Angelo Daros de Luca
2024-03-24 15:32 ` Andrew Lunn
2024-03-25 2:50 ` Luiz Angelo Daros de Luca
2024-03-25 12:38 ` Andrew Lunn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240310114928.GB1623@kernel.org \
--to=horms@kernel.org \
--cc=alsi@bang-olufsen.dk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luizluca@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.