]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: phy: simplify a check in phy_check_link_status
authorHeiner Kallweit <hkallweit1@gmail.com>
Thu, 7 Mar 2024 21:16:12 +0000 (22:16 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 11 Mar 2024 20:46:27 +0000 (13:46 -0700)
Handling case err == 0 in the other branch allows to simplify the
code. In addition I assume in "err & phydev->eee_cfg.tx_lpi_enabled"
it should have been a logical and operator. It works as expected also
with the bitwise and, but using a bitwise and with a bool value looks
ugly to me.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/de37bf30-61dd-49f9-b645-2d8ea11ddb5d@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phy.c

index c3a0a5ee5f116daa4504514a0aed8e626c4a00d0..c4236564c1cd01422db451f9118b3217b55ada97 100644 (file)
@@ -985,10 +985,10 @@ static int phy_check_link_status(struct phy_device *phydev)
                phydev->state = PHY_RUNNING;
                err = genphy_c45_eee_is_active(phydev,
                                               NULL, NULL, NULL);
-               if (err < 0)
+               if (err <= 0)
                        phydev->enable_tx_lpi = false;
                else
-                       phydev->enable_tx_lpi = (err & phydev->eee_cfg.tx_lpi_enabled);
+                       phydev->enable_tx_lpi = phydev->eee_cfg.tx_lpi_enabled;
 
                phy_link_up(phydev);
        } else if (!phydev->link && phydev->state != PHY_NOLINK) {