Commit 0194b645 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Jakub Kicinski
Browse files

net: phy: improve phy_read_poll_timeout



cond sometimes is (val & MASK) what may result in a false positive
if val is a negative errno. We shouldn't evaluate cond if val < 0.
This has no functional impact here, but it's not nice.
Therefore switch order of the checks.

Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/6d8274ac-4344-23b4-d9a3-cad4c39517d4@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 36e5e391
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1130,7 +1130,7 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum)
#define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \
				timeout_us, sleep_before_read) \
({ \
	int __ret = read_poll_timeout(phy_read, val, (cond) || val < 0, \
	int __ret = read_poll_timeout(phy_read, val, val < 0 || (cond), \
		sleep_us, timeout_us, sleep_before_read, phydev, regnum); \
	if (val < 0) \
		__ret = val; \
@@ -1139,7 +1139,6 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum)
	__ret; \
})


/**
 * __phy_read - convenience function for reading a given PHY register
 * @phydev: the phy_device struct