mirror of
https://github.com/Ysurac/openmptcprouter.git
synced 2025-03-09 15:40:20 +00:00
Update RPI patches
This commit is contained in:
parent
cc24592e6c
commit
50323f4caa
14 changed files with 1499 additions and 43 deletions
|
@ -0,0 +1,104 @@
|
|||
From f816dc53e35dd06cb0c3b36d6883d7fe7f8dbae6 Mon Sep 17 00:00:00 2001
|
||||
From: Russell King <rmk+kernel@armlinux.org.uk>
|
||||
Date: Tue, 2 Jan 2018 10:58:37 +0000
|
||||
Subject: [PATCH 324/340] net: phy: add unlocked accessors
|
||||
|
||||
commit 788f9933db6172801336d0ae2dec5bdc7525389f upstream.
|
||||
|
||||
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>
|
||||
---
|
||||
drivers/net/phy/phy-core.c | 25 +++++++++++++++++++++++++
|
||||
include/linux/phy.h | 28 ++++++++++++++++++++++++++++
|
||||
2 files changed, 53 insertions(+)
|
||||
|
||||
diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
|
||||
index 83d32644cb4d..37c039da0c16 100644
|
||||
--- a/drivers/net/phy/phy-core.c
|
||||
+++ b/drivers/net/phy/phy-core.c
|
||||
@@ -280,3 +280,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);
|
||||
diff --git a/include/linux/phy.h b/include/linux/phy.h
|
||||
index dca9e926b88f..a8118cc313ea 100644
|
||||
--- a/include/linux/phy.h
|
||||
+++ b/include/linux/phy.h
|
||||
@@ -713,6 +713,18 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum)
|
||||
return mdiobus_read(phydev->mdio.bus, phydev->mdio.addr, 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
|
||||
@@ -728,6 +740,22 @@ 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_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);
|
||||
+}
|
||||
+
|
||||
+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
|
||||
* @phydev: the phy_device struct
|
||||
--
|
||||
2.16.1
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue