On 06/25/2017 07:10 PM, Lin Yun Sheng wrote:
> This patch add set_loopback in phy_driver, which is used by Mac
> driver to enable or disable a phy. it also add a generic
> genphy_loopback function, which use BMCR loopback bit to enable
> or disable a phy.
> 
> Signed-off-by: Lin Yun Sheng <linyunsh...@huawei.com>

Reviewed-by: Florian Fainelli <f.faine...@gmail.com>

[snip]

> +int phy_loopback(struct phy_device *phydev, bool enable)
> +{
> +     struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
> +     int ret = 0;
> +
> +     mutex_lock(&phydev->lock);
> +
> +     if (enable && phydev->loopback_enabled) {
> +             ret = -EBUSY;
> +             goto out;
> +     }
> +
> +     if (!enable && !phydev->loopback_enabled) {
> +             ret = -EINVAL;
> +             goto out;
> +     }

I am not sure if it is necessary to treat that condition as an error,
but I guess why not.
-- 
Florian

Reply via email to