aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Marangi <ansuelsmth@gmail.com>2024-10-08 21:47:16 +0200
committerPaolo Abeni <pabeni@redhat.com>2024-10-10 13:55:15 +0200
commit16aef66643a2f92275351caaaa4640bbaf84040c (patch)
tree635fdb9083d5d1ed1ea59ed0c1b9e65b7c9f2e85
parent88dc9aebd04cbc319e96a3a416109faf7e45b61c (diff)
downloadlinux-16aef66643a2f92275351caaaa4640bbaf84040c.tar.gz
linux-16aef66643a2f92275351caaaa4640bbaf84040c.tar.bz2
linux-16aef66643a2f92275351caaaa4640bbaf84040c.zip
net: phy: Validate PHY LED OPs presence before registering
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> Link: https://patch.msgid.link/20241008194718.9682-1-ansuelsmth@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--drivers/net/phy/phy_device.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4ccf504a8b2c..bfb28b85392e 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3420,6 +3420,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) {
@@ -3429,6 +3439,7 @@ static int of_phy_leds(struct phy_device *phydev)
}
}
+exit:
of_node_put(leds);
return 0;
}