Re: [net-next,v3,2/2] net: phy: realtek: Add support for PHY LEDs on RTL8211E

Russell King (Oracle)
2025-03-17T11:15:20Z

On Sun, Mar 16, 2025 at 01:14:23PM +0100, Michael Klein wrote:
> +static int rtl8211e_read_ext_page(struct phy_device *phydev, u16 ext_page,
> + u32 regnum)
> +{
> + int oldpage, ret = 0;
> +
> + oldpage = phy_select_page(phydev, RTL8211E_SET_EXT_PAGE);
> + if (oldpage >= 0) {
> + ret = __phy_write(phydev, RTL8211E_EXT_PAGE_SELECT, ext_page);
> + if (!ret)

Same nit as patch 1.

> +static int rtl8211e_led_hw_control_get(struct phy_device *phydev, u8 index,
> + unsigned long *rules)
> +{
> + int ret;
> + u16 cr1, cr2;
> +
> + if (index >= RTL8211x_LED_COUNT)
> + return -EINVAL;
> +
> + ret = rtl8211e_read_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE,
> + RTL8211E_LEDCR1);
> + if (ret < 0)
> + return ret;
> +
> + cr1 = ret >> RTL8211E_LEDCR1_SHIFT * index;
> + if (cr1 & RTL8211E_LEDCR1_ACT_TXRX) {
> + set_bit(TRIGGER_NETDEV_RX, rules);
> + set_bit(TRIGGER_NETDEV_TX, rules);
> + }
> +
> + ret = rtl8211e_read_ext_page(phydev, RTL8211E_LEDCR_EXT_PAGE,
> + RTL8211E_LEDCR2);
> + if (ret < 0)
> + return ret;
> +
> + cr2 = ret >> RTL8211E_LEDCR2_SHIFT * index;
> + if (cr2 & RTL8211E_LEDCR2_LINK_10)
> + set_bit(TRIGGER_NETDEV_LINK_10, rules);
> +
> + if (cr2 & RTL8211E_LEDCR2_LINK_100)
> + set_bit(TRIGGER_NETDEV_LINK_100, rules);
> +
> + if (cr2 & RTL8211E_LEDCR2_LINK_1000)
> + set_bit(TRIGGER_NETDEV_LINK_1000, rules);

Do you need these set_bit()s to be a heavy-weight atomic operation, or
will __set_bit() being its lighter-weight non-atomic version be better?

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!