diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2018-01-02 10:58:37 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-01-03 11:00:22 -0500 |
commit | 788f9933db6172801336d0ae2dec5bdc7525389f (patch) | |
tree | bff7e4db796bc371b4f597bb8958e3391637cf0d /drivers | |
parent | 1b2dea2e6a6e3399e88784d57aea80f4fd5e8956 (diff) | |
download | linux-stable-788f9933db6172801336d0ae2dec5bdc7525389f.tar.gz linux-stable-788f9933db6172801336d0ae2dec5bdc7525389f.tar.bz2 linux-stable-788f9933db6172801336d0ae2dec5bdc7525389f.zip |
net: phy: add unlocked accessors
Add unlocked versions of the bus accessors, which allows access to the
bus with all the tracing. These accessors validate that the bus mutex
is held, which is a basic requirement for all mii bus accesses.
Also added is a read-modify-write unlocked accessor with the same
locking requirements.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/phy/phy-core.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c index 2c985c6e2cdd..028c098e9a00 100644 --- a/drivers/net/phy/phy-core.c +++ b/drivers/net/phy/phy-core.c @@ -323,3 +323,28 @@ int phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val) return ret; } EXPORT_SYMBOL(phy_write_mmd); + +/** + * __phy_modify() - Convenience function for modifying a PHY register + * @phydev: a pointer to a &struct phy_device + * @regnum: register number + * @mask: bit mask of bits to clear + * @set: bit mask of bits to set + * + * Unlocked helper function which allows a PHY register to be modified as + * new register value = (old register value & mask) | set + */ +int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set) +{ + int ret, res; + + ret = __phy_read(phydev, regnum); + if (ret >= 0) { + res = __phy_write(phydev, regnum, (ret & ~mask) | set); + if (res < 0) + ret = res; + } + + return ret; +} +EXPORT_SYMBOL_GPL(__phy_modify); |