* [PATCH net-next] net: phy: improve phy_read_poll_timeout
@ 2023-03-06 21:51 Heiner Kallweit
2023-03-07 15:42 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Heiner Kallweit @ 2023-03-06 21:51 UTC (permalink / raw)
To: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller
Cc: netdev@vger•kernel.org
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 <hkallweit1@gmail•com>
---
include/linux/phy.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 36bf0bbc8..fefd5091b 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1130,16 +1130,15 @@ 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) \
+ if (val < 0) \
__ret = val; \
if (__ret) \
phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \
__ret; \
})
-
/**
* __phy_read - convenience function for reading a given PHY register
* @phydev: the phy_device struct
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: phy: improve phy_read_poll_timeout
2023-03-06 21:51 [PATCH net-next] net: phy: improve phy_read_poll_timeout Heiner Kallweit
@ 2023-03-07 15:42 ` Simon Horman
2023-03-08 1:56 ` Andrew Lunn
2023-03-08 2:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2023-03-07 15:42 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Andrew Lunn, Russell King - ARM Linux, Paolo Abeni,
Jakub Kicinski, Eric Dumazet, David Miller,
netdev@vger•kernel.org
On Mon, Mar 06, 2023 at 10:51:35PM +0100, Heiner Kallweit wrote:
> 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 <hkallweit1@gmail•com>
Reviewed-by: Simon Horman <simon.horman@corigine•com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: phy: improve phy_read_poll_timeout
2023-03-06 21:51 [PATCH net-next] net: phy: improve phy_read_poll_timeout Heiner Kallweit
2023-03-07 15:42 ` Simon Horman
@ 2023-03-08 1:56 ` Andrew Lunn
2023-03-08 2:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2023-03-08 1:56 UTC (permalink / raw)
To: Heiner Kallweit
Cc: Russell King - ARM Linux, Paolo Abeni, Jakub Kicinski,
Eric Dumazet, David Miller, netdev@vger•kernel.org
On Mon, Mar 06, 2023 at 10:51:35PM +0100, Heiner Kallweit wrote:
> 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 <hkallweit1@gmail•com>
Reviewed-by: Andrew Lunn <andrew@lunn•ch>
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: phy: improve phy_read_poll_timeout
2023-03-06 21:51 [PATCH net-next] net: phy: improve phy_read_poll_timeout Heiner Kallweit
2023-03-07 15:42 ` Simon Horman
2023-03-08 1:56 ` Andrew Lunn
@ 2023-03-08 2:30 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-08 2:30 UTC (permalink / raw)
To: Heiner Kallweit; +Cc: andrew, linux, pabeni, kuba, edumazet, davem, netdev
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel•org>:
On Mon, 6 Mar 2023 22:51:35 +0100 you wrote:
> 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 <hkallweit1@gmail•com>
>
> [...]
Here is the summary with links:
- [net-next] net: phy: improve phy_read_poll_timeout
https://git.kernel.org/netdev/net-next/c/0194b64578e9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-08 2:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-06 21:51 [PATCH net-next] net: phy: improve phy_read_poll_timeout Heiner Kallweit
2023-03-07 15:42 ` Simon Horman
2023-03-08 1:56 ` Andrew Lunn
2023-03-08 2:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox