netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>, Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH net-next v2 6/7] net: phy: add phy_modify() accessor
Date: Tue, 02 Jan 2018 10:58:53 +0000	[thread overview]
Message-ID: <E1eWKHV-0003iv-BH@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20180102105218.GB21998@n2100.armlinux.org.uk>

Add phy_modify() convenience accessor to complement the mdiobus
counterpart.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phy-core.c | 23 +++++++++++++++++++++++
 include/linux/phy.h        |  1 +
 2 files changed, 24 insertions(+)

diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index 412ed8ff50e2..a2168adea81f 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -306,6 +306,29 @@ int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set)
 }
 EXPORT_SYMBOL_GPL(__phy_modify);
 
+/**
+ * phy_modify - Convenience function for modifying a given PHY register
+ * @phydev: the phy_device struct
+ * @regnum: register number to write
+ * @mask: bit mask of bits to clear
+ * @set: new value of bits set in mask to write to @regnum
+ *
+ * NOTE: MUST NOT be called from interrupt context,
+ * because the bus read/write functions may wait for an interrupt
+ * to conclude the operation.
+ */
+int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set)
+{
+	int ret;
+
+	mutex_lock(&phydev->mdio.bus->mdio_lock);
+	ret = __phy_modify(phydev, regnum, mask, set);
+	mutex_unlock(&phydev->mdio.bus->mdio_lock);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(phy_modify);
+
 static int __phy_read_page(struct phy_device *phydev)
 {
 	return phydev->drv->read_page(phydev);
diff --git a/include/linux/phy.h b/include/linux/phy.h
index f408220d95ec..0ee4ece312da 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -760,6 +760,7 @@ static inline int __phy_write(struct phy_device *phydev, u32 regnum, u16 val)
 }
 
 int __phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
+int phy_modify(struct phy_device *phydev, u32 regnum, u16 mask, u16 set);
 
 /**
  * phy_interrupt_is_valid - Convenience function for testing a given PHY irq
-- 
2.7.4

  parent reply	other threads:[~2018-01-02 10:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-02 10:52 [PATCH net-next v2 0/7] Resolve races in phy accessors Russell King - ARM Linux
2018-01-02 10:58 ` [PATCH net-next v2 1/7] net: mdiobus: add unlocked accessors Russell King
2018-01-02 10:58 ` [PATCH net-next v2 2/7] net: phy: use unlocked accessors for indirect MMD accesses Russell King
2018-01-02 10:58 ` [PATCH net-next v2 3/7] net: phy: add unlocked accessors Russell King
2018-01-02 15:49   ` Andrew Lunn
2018-01-02 10:58 ` [PATCH net-next v2 4/7] net: phy: add paged phy register accessors Russell King
2018-01-02 15:52   ` Andrew Lunn
2018-01-02 10:58 ` [PATCH net-next v2 5/7] net: phy: marvell: fix paged access races Russell King
2018-01-02 16:00   ` Andrew Lunn
2018-01-02 10:58 ` Russell King [this message]
2018-01-02 16:01   ` [PATCH net-next v2 6/7] net: phy: add phy_modify() accessor Andrew Lunn
2018-01-02 10:58 ` [PATCH net-next v2 7/7] net: phy: convert read-modify-write to phy_modify() Russell King
2018-01-02 16:05   ` Andrew Lunn
2018-01-03 16:04 ` [PATCH net-next v2 0/7] Resolve races in phy accessors David Miller
2018-01-03 17:32   ` Russell King - ARM Linux
2018-01-03 18:38     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1eWKHV-0003iv-BH@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).