diff options
author | Andrew Lunn <andrew@lunn.ch> | 2018-01-12 09:01:36 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-15 12:49:30 -0500 |
commit | 9f239fe6a6b9c47b860a577e7334e43464ab7f9e (patch) | |
tree | 0cf98132255be1e1ebc8306281f23e3bb5f86159 | |
parent | 564737f981fb4b4b3266901508bb9b90d9d43de8 (diff) |
net: phy: Have __phy_modify return 0 on success
__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>
Tested-by: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/phy/phy-core.c | 13 |
1 files 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); | |||
336 | */ | 336 | */ |
337 | int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) | 337 | int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) |
338 | { | 338 | { |
339 | int ret, res; | 339 | int ret; |
340 | 340 | ||
341 | ret = __phy_read(phydev, regnum); | 341 | ret = __phy_read(phydev, regnum); |
342 | if (ret >= 0) { | 342 | if (ret < 0) |
343 | res = __phy_write(phydev, regnum, (ret & ~mask) | set); | 343 | return ret; |
344 | if (res < 0) | ||
345 | ret = res; | ||
346 | } | ||
347 | 344 | ||
348 | return ret; | 345 | ret = __phy_write(phydev, regnum, (ret & ~mask) | set); |
346 | |||
347 | return ret < 0 ? ret : 0; | ||
349 | } | 348 | } |
350 | EXPORT_SYMBOL_GPL(__phy_modify); | 349 | EXPORT_SYMBOL_GPL(__phy_modify); |
351 | 350 | ||