Re: [net-next PATCH 3/3] net: phy: add support for PHY package MMD read/write

From: Florian Fainelli
Date: Sat Nov 25 2023 - 19:52:54 EST




On 11/25/2023 4:37 PM, Christian Marangi wrote:
Some PHY in PHY package may require to read/write MMD regs to correctly
configure the PHY package.

Add support for these additional required function in both lock and no
lock variant.

Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>
---
include/linux/phy.h | 74 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)

diff --git a/include/linux/phy.h b/include/linux/phy.h
index 984bca9a82f4..1799133c8387 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2067,6 +2067,80 @@ static inline int __phy_package_write(struct phy_device *phydev,
return __mdiobus_write(phydev->mdio.bus, addr, regnum, val);
}
+static inline int phy_package_read_mmd(struct phy_device *phydev,
+ unsigned int addr_offset, int devad,
+ u32 regnum)
+{
+ struct phy_package_shared *shared = phydev->shared;
+ struct mii_bus *bus = phydev->mdio.bus;
+ int addr, val;
+
+ if (!shared || shared->base_addr + addr_offset > PHY_MAX_ADDR)
+ return -EIO;

You might be off by one here, should not that >= PHY_MAX_ADDR here and below?
--
Florian