Skip to content

Commit 0194b64

Browse files
hkallweitkuba-moo
authored andcommitted
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: Heiner Kallweit <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 36e5e39 commit 0194b64

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

include/linux/phy.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,16 +1130,15 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum)
11301130
#define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \
11311131
timeout_us, sleep_before_read) \
11321132
({ \
1133-
int __ret = read_poll_timeout(phy_read, val, (cond) || val < 0, \
1133+
int __ret = read_poll_timeout(phy_read, val, val < 0 || (cond), \
11341134
sleep_us, timeout_us, sleep_before_read, phydev, regnum); \
1135-
if (val < 0) \
1135+
if (val < 0) \
11361136
__ret = val; \
11371137
if (__ret) \
11381138
phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \
11391139
__ret; \
11401140
})
11411141

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

0 commit comments

Comments
 (0)