* [PATCH v2] net: phy: Have __phy_modify return 0 on success
@ 2018-01-12 14:01 Andrew Lunn
2018-01-14 18:04 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrew Lunn @ 2018-01-12 14:01 UTC (permalink / raw)
To: David Miller
Cc: geert, niklas.cassel, Russell King, Florian Fainelli, netdev,
Andrew Lunn
__phy_modify would return the old value of the register before it was
modified. Thus on success, it does not return 0, but a positive value.
Thus functions using phy_modify, which is a wrapper around
__phy_modify, can start returning > 0 on success, rather than 0. As a
result, breakage has been noticed in various places, where 0 was
assumed.
Code inspection does not find any current location where the return of
the old value is currently used. So have __phy_modify return 0 on
success. When there is a real need for the old value, either a new
accessor can be added, or an additional parameter passed.
Fixes: fea23fb591cc ("net: phy: convert read-modify-write to phy_modify()")
Fixes: 2b74e5be17d2 ("net: phy: add phy_modify() accessor")
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
v2: space before :
additional fixes tag
Tested-by
---
drivers/net/phy/phy-core.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index e75989ce8850..4083f00c97a5 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -336,16 +336,15 @@ EXPORT_SYMBOL(phy_write_mmd);
*/
int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set)
{
- int ret, res;
+ int ret;
ret = __phy_read(phydev, regnum);
- if (ret >= 0) {
- res = __phy_write(phydev, regnum, (ret & ~mask) | set);
- if (res < 0)
- ret = res;
- }
+ if (ret < 0)
+ return ret;
- return ret;
+ ret = __phy_write(phydev, regnum, (ret & ~mask) | set);
+
+ return ret < 0 ? ret : 0;
}
EXPORT_SYMBOL_GPL(__phy_modify);
--
2.15.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2] net: phy: Have __phy_modify return 0 on success
2018-01-12 14:01 [PATCH v2] net: phy: Have __phy_modify return 0 on success Andrew Lunn
@ 2018-01-14 18:04 ` Andrew Lunn
2018-01-14 18:29 ` David Miller
2018-01-15 9:06 ` Niklas Cassel
2018-01-15 17:50 ` David Miller
2 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2018-01-14 18:04 UTC (permalink / raw)
To: David Miller; +Cc: geert, niklas.cassel, Russell King, Florian Fainelli, netdev
On Fri, Jan 12, 2018 at 03:01:36PM +0100, Andrew Lunn wrote:
> __phy_modify would return the old value of the register before it was
> modified. Thus on success, it does not return 0, but a positive value.
> Thus functions using phy_modify, which is a wrapper around
> __phy_modify, can start returning > 0 on success, rather than 0. As a
> result, breakage has been noticed in various places, where 0 was
> assumed.
>
> Code inspection does not find any current location where the return of
> the old value is currently used. So have __phy_modify return 0 on
> success. When there is a real need for the old value, either a new
> accessor can be added, or an additional parameter passed.
>
> Fixes: fea23fb591cc ("net: phy: convert read-modify-write to phy_modify()")
> Fixes: 2b74e5be17d2 ("net: phy: add phy_modify() accessor")
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Hi David
Is there any particular reason you have not picked up this patch? Do
you want more testing? An O.K. from Russell?
Thanks
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] net: phy: Have __phy_modify return 0 on success
2018-01-12 14:01 [PATCH v2] net: phy: Have __phy_modify return 0 on success Andrew Lunn
2018-01-14 18:04 ` Andrew Lunn
@ 2018-01-15 9:06 ` Niklas Cassel
2018-01-15 17:50 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2018-01-15 9:06 UTC (permalink / raw)
To: Andrew Lunn; +Cc: David Miller, geert, Russell King, Florian Fainelli, netdev
Tested-by: Niklas Cassel <niklas.cassel@axis.com>
On Fri, Jan 12, 2018 at 03:01:36PM +0100, Andrew Lunn wrote:
> __phy_modify would return the old value of the register before it was
> modified. Thus on success, it does not return 0, but a positive value.
> Thus functions using phy_modify, which is a wrapper around
> __phy_modify, can start returning > 0 on success, rather than 0. As a
> result, breakage has been noticed in various places, where 0 was
> assumed.
>
> Code inspection does not find any current location where the return of
> the old value is currently used. So have __phy_modify return 0 on
> success. When there is a real need for the old value, either a new
> accessor can be added, or an additional parameter passed.
>
> Fixes: fea23fb591cc ("net: phy: convert read-modify-write to phy_modify()")
> Fixes: 2b74e5be17d2 ("net: phy: add phy_modify() accessor")
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> v2: space before :
> additional fixes tag
> Tested-by
> ---
> drivers/net/phy/phy-core.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
> index e75989ce8850..4083f00c97a5 100644
> --- a/drivers/net/phy/phy-core.c
> +++ b/drivers/net/phy/phy-core.c
> @@ -336,16 +336,15 @@ EXPORT_SYMBOL(phy_write_mmd);
> */
> int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set)
> {
> - int ret, res;
> + int ret;
>
> ret = __phy_read(phydev, regnum);
> - if (ret >= 0) {
> - res = __phy_write(phydev, regnum, (ret & ~mask) | set);
> - if (res < 0)
> - ret = res;
> - }
> + if (ret < 0)
> + return ret;
>
> - return ret;
> + ret = __phy_write(phydev, regnum, (ret & ~mask) | set);
> +
> + return ret < 0 ? ret : 0;
> }
> EXPORT_SYMBOL_GPL(__phy_modify);
>
> --
> 2.15.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH v2] net: phy: Have __phy_modify return 0 on success
2018-01-12 14:01 [PATCH v2] net: phy: Have __phy_modify return 0 on success Andrew Lunn
2018-01-14 18:04 ` Andrew Lunn
2018-01-15 9:06 ` Niklas Cassel
@ 2018-01-15 17:50 ` David Miller
2 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2018-01-15 17:50 UTC (permalink / raw)
To: andrew; +Cc: geert, niklas.cassel, rmk+kernel, f.fainelli, netdev
From: Andrew Lunn <andrew@lunn.ch>
Date: Fri, 12 Jan 2018 15:01:36 +0100
> __phy_modify would return the old value of the register before it was
> modified. Thus on success, it does not return 0, but a positive value.
> Thus functions using phy_modify, which is a wrapper around
> __phy_modify, can start returning > 0 on success, rather than 0. As a
> result, breakage has been noticed in various places, where 0 was
> assumed.
>
> Code inspection does not find any current location where the return of
> the old value is currently used. So have __phy_modify return 0 on
> success. When there is a real need for the old value, either a new
> accessor can be added, or an additional parameter passed.
>
> Fixes: fea23fb591cc ("net: phy: convert read-modify-write to phy_modify()")
> Fixes: 2b74e5be17d2 ("net: phy: add phy_modify() accessor")
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> v2: space before :
> additional fixes tag
> Tested-by
Applied to net-next, thanks Andrew.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-01-15 17:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-12 14:01 [PATCH v2] net: phy: Have __phy_modify return 0 on success Andrew Lunn
2018-01-14 18:04 ` Andrew Lunn
2018-01-14 18:29 ` David Miller
2018-01-15 9:06 ` Niklas Cassel
2018-01-15 17:50 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).