The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH RFC net-next] net: phy: always set polarity_modes if op is supported
@ 2024-10-04 15:46 Daniel Golle
  2024-10-04 20:59 ` Andrew Lunn
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Golle @ 2024-10-04 15:46 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Christian Marangi,
	netdev, linux-kernel

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@makrotopia.org>
---
 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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-10-05 16:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04 15:46 [PATCH RFC net-next] net: phy: always set polarity_modes if op is supported Daniel Golle
2024-10-04 20:59 ` Andrew Lunn
2024-10-04 22:11   ` Daniel Golle
2024-10-05 14:17     ` Andrew Lunn
2024-10-05 15:51       ` Daniel Golle
2024-10-05 16:35         ` Andrew Lunn
2024-10-05 16:59           ` Daniel Golle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox