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

Michael Klein
2025-03-17T17:23:17Z

Thank you for your insights,

On Mon, Mar 17, 2025 at 11:15:11AM +0000, Russell King (Oracle) wrote:
>On Sun, Mar 16, 2025 at 01:14:23PM +0100, Michael Klein wrote:
>> +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?

I don't think this needs to be atomic at all, as the phydev lock is held
by the one and only caller (phy_led_hw_control_get()).

rtl8211f_led_hw_control_get() also uses set_bit(). Should I change those
also to __set_bit() in a separate patch while I'm at it?

--
Michael