Re: [PATCH net-next v8 09/11] net: phy: ncn26000: Support for loopback
From: Andrew Lunn
Date: Tue Oct 06 2026 - 09:06:55 EST
> @@ -2775,6 +2775,26 @@ int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
> }
> EXPORT_SYMBOL(genphy_write_mmd_unsupported);
>
> +/**
> + * genphy_loopback_fixed_speed - Helper to modify the PHY loopback mode
> + * without affecting any other settings.
> + * @phydev: The phy_device struct
> + * @enable: Flag to enable or disable the PHY level loopback.
> + * @speed: Speed setting. Not expected to be set. Error if it is set.
> + *
> + * Returns: 0 if successful, negative error code on failure.
> + */
> +int genphy_loopback_fixed_speed(struct phy_device *phydev, bool enable,
> + int speed)
> +{
> + if (enable && speed)
> + return -EOPNOTSUPP;
> +
> + return phy_modify(phydev, MII_BMCR, BMCR_LOOPBACK,
> + enable ? BMCR_LOOPBACK : 0);
> +}
> +EXPORT_SYMBOL(genphy_loopback_fixed_speed);
Please could you place it next to genphy_loopback()
> +
> int genphy_suspend(struct phy_device *phydev)
> {
> return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN);
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 7c5098a0dd6c..c1b9bc305c82 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -2327,6 +2327,8 @@ int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad,
> u16 regnum);
> int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum,
> u16 regnum, u16 val);
> +int genphy_loopback_fixed_speed(struct phy_device *phydev, bool enable,
> + int speed);
and this next to genphy_loopback().
Andrew