From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Lunn Subject: [PATCH v2] net: phy: Have __phy_modify return 0 on success Date: Fri, 12 Jan 2018 15:01:36 +0100 Message-ID: <1515765696-1286-1-git-send-email-andrew@lunn.ch> Cc: geert@linux-m68k.org, niklas.cassel@axis.com, Russell King , Florian Fainelli , netdev , Andrew Lunn To: David Miller Return-path: Received: from vps0.lunn.ch ([185.16.172.187]:41212 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933582AbeALOCA (ORCPT ); Fri, 12 Jan 2018 09:02:00 -0500 Sender: netdev-owner@vger.kernel.org List-ID: __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 Tested-by: Geert Uytterhoeven Signed-off-by: Andrew Lunn --- 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