net: phy: correctly check soft_reset ret ONLY if defined for PHY

JIRA: https://issues.redhat.com/browse/RHEL-33716

commit aadbd27f9674d7f5457331fe0248b370d5c1f25d
Author: Christian Marangi <ansuelsmth@gmail.com>
Date:   Tue Nov 21 14:53:32 2023 +0100

    net: phy: correctly check soft_reset ret ONLY if defined for PHY

    Introduced by commit 6e2d85ec05 ("net: phy: Stop with excessive soft
    reset").

    soft_reset call for phy_init_hw had multiple revision across the years
    and the implementation goes back to 2014. Originally was a simple call
    to write the generic PHY reset BIT, it was then moved to a dedicated
    function. It was then added the option for PHY driver to define their
    own special way to reset the PHY. Till this change, checking for ret was
    correct as it was always filled by either the generic reset or the
    custom implementation. This changed tho with commit 6e2d85ec05 ("net:
    phy: Stop with excessive soft reset"), as the generic reset call to PHY
    was dropped but the ret check was never made entirely optional and
    dependent whether soft_reset was defined for the PHY driver or not.

    Luckly nothing was ever added before the soft_reset call so the ret
    check (in the case where a PHY didn't had soft_reset defined) although
    wrong, never caused problems as ret was init 0 at the start of
    phy_init_hw.

    To prevent any kind of problem and to make the function cleaner and more
    robust, correctly move the ret check if the soft_reset section making it
    optional and needed only with the function defined.

    Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
    Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Izabela Bakollari <ibakolla@redhat.com>
This commit is contained in:
Izabela Bakollari 2024-06-25 10:31:27 +02:00
parent 39908de3d1
commit a0083e9dc7
1 changed files with 5 additions and 6 deletions

View File

@ -1236,13 +1236,12 @@ int phy_init_hw(struct phy_device *phydev)
if (phydev->drv->soft_reset) {
ret = phydev->drv->soft_reset(phydev);
/* see comment in genphy_soft_reset for an explanation */
if (!ret)
phydev->suspended = 0;
}
if (ret < 0)
return ret;
if (ret < 0)
return ret;
/* see comment in genphy_soft_reset for an explanation */
phydev->suspended = 0;
}
ret = phy_scan_fixups(phydev);
if (ret < 0)