rswitch: Fix imbalance phy_power_off() calling
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tue, 10 Oct 2023 12:48:58 +0000 (21:48 +0900)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 12 Oct 2023 09:22:21 +0000 (11:22 +0200)
The phy_power_off() should not be called if phy_power_on() failed.
So, add a condition .power_count before calls phy_power_off().

Fixes: 5cb630925b49 ("net: renesas: rswitch: Add phy_power_{on,off}() calling")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/renesas/rswitch.c

index 4d7c482..0fc0b6b 100644 (file)
@@ -1254,7 +1254,7 @@ static void rswitch_adjust_link(struct net_device *ndev)
                phy_print_status(phydev);
                if (phydev->link)
                        phy_power_on(rdev->serdes);
-               else
+               else if (rdev->serdes->power_count)
                        phy_power_off(rdev->serdes);
 
                rdev->etha->link = phydev->link;