From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King Subject: [PATCH RFC 3/4] net: phy: add unlocked accessors Date: Fri, 08 Dec 2017 15:48:53 +0000 Message-ID: References: <20171208154756.GF10595@n2100.armlinux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org To: Andrew Lunn , Florian Fainelli Return-path: Received: from pandora.armlinux.org.uk ([78.32.30.218]:54392 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754237AbdLHPs4 (ORCPT ); Fri, 8 Dec 2017 10:48:56 -0500 In-Reply-To: <20171208154756.GF10595@n2100.armlinux.org.uk> Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: 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. Signed-off-by: Russell King --- include/linux/phy.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/phy.h b/include/linux/phy.h index 71d777fe6c3d..964803bd7324 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -716,6 +716,18 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum) } /** + * __phy_read - convenience function for reading a given PHY register + * @phydev: the phy_device struct + * @regnum: register number to read + * + * The caller must have taken the MDIO bus lock. + */ +static inline int __phy_read(struct phy_device *phydev, u32 regnum) +{ + return __mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, regnum); +} + +/** * phy_write - Convenience function for writing a given PHY register * @phydev: the phy_device struct * @regnum: register number to write @@ -731,6 +743,20 @@ static inline int phy_write(struct phy_device *phydev, u32 regnum, u16 val) } /** + * __phy_write - Convenience function for writing a given PHY register + * @phydev: the phy_device struct + * @regnum: register number to write + * @val: value to write to @regnum + * + * The caller must have taken the MDIO bus lock. + */ +static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val) +{ + return __mdiobus_write(phydev->mdio.bus, phydev->mdio.addr, regnum, + val); +} + +/** * phy_interrupt_is_valid - Convenience function for testing a given PHY irq * @phydev: the phy_device struct * -- 2.7.4