Re: [net-next PATCH v8 3/5] net: phy: add support for PHY LEDs polarity modes
From: Christian Marangi <ansuelsmth@gmail.com>
Date: 2024-01-04 21:51:42
Also in:
linux-devicetree, linux-leds, lkml, netdev
On Thu, Jan 04, 2024 at 02:20:45PM +0100, Andrew Lunn wrote:
quoted
+ if (phydev->drv->led_polarity_set) { + if (of_property_read_bool(led, "active-low")) + set_bit(PHY_LED_ACTIVE_LOW, &modes); + if (of_property_read_bool(led, "inactive-high-impedance")) + set_bit(PHY_LED_INACTIVE_HIGH_IMPEDANCE, &modes); + + err = phydev->drv->led_polarity_set(phydev, index, modes); + if (err) + return err; + }I think we should return an error if asked to set the mode, but its not implemented by the driver. Something like: if (of_property_read_bool(led, "active-low")) set_bit(PHY_LED_ACTIVE_LOW, &modes); if (of_property_read_bool(led, "inactive-high-impedance")) set_bit(PHY_LED_INACTIVE_HIGH_IMPEDANCE, &modes); if (mode) if (phydev->drv->led_polarity_set) { return -EINVAL; } else { err = phydev->drv->led_polarity_set(phydev, index, modes); if (err) return err; } }quoted
+ /** + * @led_polarity_set: Set the LED polarity if active lowThe 'if active low' is not ouw of date, since it is used for more than that.quoted
+ * @dev: PHY device which has the LED + * @index: Which LED of the PHY device or -1 + * @modes: bitmap of LED polarity modes + * + * Configure LED with all the required polarity modes in @modes + * to make it correctly turn ON or OFF.index == -1 should be explained.
If you are referring to the special way of setting the LED globally, that is not a thing anymore. Rob pointed out that having the double reference in DT is problematic and PHY driver should handle that internally.
quoted
+ * + * Returns 0, or an error code. + */ + int (*led_polarity_set)(struct phy_device *dev, int index, + unsigned long modes);Andrew --- pw-bot: cr
-- Ansuel _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel