Skip to content

Commit

Permalink
net: phy: Have __phy_modify return 0 on success
Browse files Browse the repository at this point in the history
__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: fea23fb ("net: phy: convert read-modify-write to phy_modify()")
Fixes: 2b74e5b ("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>
  • Loading branch information
Andrew Lunn authored and David S. Miller committed Jan 15, 2018
1 parent 564737f commit 9f239fe
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions drivers/net/phy/phy-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 9f239fe

Please sign in to comment.