Re: [PATCH net-next 3/9] net: phy: mediatek: Move LED helper functions into mtk phy lib

From: Andrew Lunn
Date: Sun Oct 06 2024 - 17:28:29 EST


> static int mt798x_phy_led_blink_set(struct phy_device *phydev, u8 index,
> unsigned long *delay_on,
> unsigned long *delay_off)
> {
> + struct mtk_socphy_priv *priv = phydev->priv;
> bool blinking = false;
> int err = 0;
>
> - if (index > 1)
> - return -EINVAL;
> -
> - if (delay_on && delay_off && (*delay_on > 0) && (*delay_off > 0)) {
> - blinking = true;
> - *delay_on = 50;
> - *delay_off = 50;
> - }
> + err = mtk_phy_led_num_dly_cfg(index, delay_on, delay_off, &blinking);
> + if (err < 0)
> + return err;
>
> - err = mt798x_phy_hw_led_blink_set(phydev, index, blinking);
> + err = mtk_phy_hw_led_blink_set(phydev, index, &priv->led_state,
> + blinking);
> if (err)
> return err;
>
> - return mt798x_phy_hw_led_on_set(phydev, index, false);
> + return mtk_phy_hw_led_on_set(phydev, index, &priv->led_state,
> + MTK_GPHY_LED_ON_MASK, false);
> }
>
> static int mt798x_phy_led_brightness_set(struct phy_device *phydev,
> u8 index, enum led_brightness value)
> {
> + struct mtk_socphy_priv *priv = phydev->priv;
> int err;
>
> - err = mt798x_phy_hw_led_blink_set(phydev, index, false);
> + err = mtk_phy_hw_led_blink_set(phydev, index, &priv->led_state, false);
> if (err)
> return err;

If this is just moving code into a shared helper library, why is priv
now needed, when it was not before?

Maybe this needs splitting into two patches, to help explain this
change.

Andrew