* [net-next PATCH v3] net: phy: Validate PHY LED OPs presence before registering
@ 2024-10-08 19:47 Christian Marangi
2024-10-08 19:51 ` Andrew Lunn
2024-10-10 12:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Christian Marangi @ 2024-10-08 19:47 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
Cc: Christian Marangi
Validate PHY LED OPs presence before registering and parsing them.
Defining LED nodes for a PHY driver that actually doesn't supports them
is redundant and useless.
It's also the case with Generic PHY driver used and a DT having LEDs
node for the specific PHY.
Skip it and report the error with debug print enabled.
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
Changes v3:
- Make condition more readable
Changes v2:
- Use phydev_dbg instead of warn
drivers/net/phy/phy_device.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 499797646580..e4a1d0e74e47 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3421,6 +3421,16 @@ static int of_phy_leds(struct phy_device *phydev)
if (!leds)
return 0;
+ /* Check if the PHY driver have at least an OP to
+ * set the LEDs.
+ */
+ if (!(phydev->drv->led_brightness_set ||
+ phydev->drv->led_blink_set ||
+ phydev->drv->led_hw_control_set)) {
+ phydev_dbg(phydev, "ignoring leds node defined with no PHY driver support\n");
+ goto exit;
+ }
+
for_each_available_child_of_node_scoped(leds, led) {
err = of_phy_led(phydev, led);
if (err) {
@@ -3430,6 +3440,7 @@ static int of_phy_leds(struct phy_device *phydev)
}
}
+exit:
of_node_put(leds);
return 0;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [net-next PATCH v3] net: phy: Validate PHY LED OPs presence before registering
2024-10-08 19:47 [net-next PATCH v3] net: phy: Validate PHY LED OPs presence before registering Christian Marangi
@ 2024-10-08 19:51 ` Andrew Lunn
2024-10-10 12:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2024-10-08 19:51 UTC (permalink / raw)
To: Christian Marangi
Cc: Heiner Kallweit, Russell King, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel
On Tue, Oct 08, 2024 at 09:47:16PM +0200, Christian Marangi wrote:
> Validate PHY LED OPs presence before registering and parsing them.
> Defining LED nodes for a PHY driver that actually doesn't supports them
> is redundant and useless.
>
> It's also the case with Generic PHY driver used and a DT having LEDs
> node for the specific PHY.
>
> Skip it and report the error with debug print enabled.
>
> Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [net-next PATCH v3] net: phy: Validate PHY LED OPs presence before registering
2024-10-08 19:47 [net-next PATCH v3] net: phy: Validate PHY LED OPs presence before registering Christian Marangi
2024-10-08 19:51 ` Andrew Lunn
@ 2024-10-10 12:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-10-10 12:00 UTC (permalink / raw)
To: Christian Marangi
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 8 Oct 2024 21:47:16 +0200 you wrote:
> Validate PHY LED OPs presence before registering and parsing them.
> Defining LED nodes for a PHY driver that actually doesn't supports them
> is redundant and useless.
>
> It's also the case with Generic PHY driver used and a DT having LEDs
> node for the specific PHY.
>
> [...]
Here is the summary with links:
- [net-next,v3] net: phy: Validate PHY LED OPs presence before registering
https://git.kernel.org/netdev/net-next/c/16aef66643a2
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-10 12:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 19:47 [net-next PATCH v3] net: phy: Validate PHY LED OPs presence before registering Christian Marangi
2024-10-08 19:51 ` Andrew Lunn
2024-10-10 12:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox