[PATCH RFC net-next] net: phy: always set polarity_modes if op is supported
From: Daniel Golle
Date: Fri Oct 04 2024 - 11:59:03 EST
Some PHYs drive LEDs active-low by default and polarity needs to be
configured in case the 'active-low' property is NOT set.
One way to achieve this without introducing an additional 'active-high'
property would be to always call the led_polarity_set operation if it
is supported by the phy driver.
Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
---
drivers/net/phy/phy_device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 560e338b307a..d25c61223e83 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3362,11 +3362,11 @@ static int of_phy_led(struct phy_device *phydev,
if (of_property_read_bool(led, "inactive-high-impedance"))
set_bit(PHY_LED_INACTIVE_HIGH_IMPEDANCE, &modes);
- if (modes) {
- /* Return error if asked to set polarity modes but not supported */
- if (!phydev->drv->led_polarity_set)
- return -EINVAL;
+ /* Return error if asked to set polarity modes but not supported */
+ if (modes && !phydev->drv->led_polarity_set)
+ return -EINVAL;
+ if (phydev->drv->led_polarity_set) {
err = phydev->drv->led_polarity_set(phydev, index, modes);
if (err)
return err;
--
2.46.2