lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231220155518.15692-3-kabel@kernel.org>
Date: Wed, 20 Dec 2023 16:55:05 +0100
From: Marek Behún <kabel@...nel.org>
To: netdev@...r.kernel.org,
	Andrew Lunn <andrew@...n.ch>,
	"David S. Miller" <davem@...emloft.net>,
	Jakub Kicinski <kuba@...nel.org>,
	Paolo Abeni <pabeni@...hat.com>
Cc: Russell King <rmk+kernel@...linux.org.uk>,
	Alexander Couzens <lynxis@...0.eu>,
	Daniel Golle <daniel@...rotopia.org>,
	Heiner Kallweit <hkallweit1@...il.com>,
	Willy Liu <willy.liu@...ltek.com>,
	Ioana Ciornei <ioana.ciornei@....com>,
	Marek Mojík <marek.mojik@....cz>,
	Maximilián Maliar <maximilian.maliar@....cz>,
	Marek Behún <kabel@...nel.org>
Subject: [PATCH net-next 02/15] net: phy: export indirect MMD register accessors

Export mmd_phy_read_indirect() and mmd_phy_write_indirect(), the
indirect MMD accessors, so that the functions can be used from the
.read_mmd / .write_mmd phy_driver methods.

Add a __ prefix to these functions.

Signed-off-by: Marek Behún <kabel@...nel.org>
---
 drivers/net/phy/phy-core.c | 14 ++++++++------
 include/linux/phy.h        | 10 ++++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index 9318b65cca95..150020cfa593 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -546,8 +546,8 @@ static int mmd_phy_indirect(struct mii_bus *bus, int phy_addr, int devad,
 			       devad | MII_MMD_CTRL_NOINCR);
 }
 
-static int mmd_phy_read_indirect(struct mii_bus *bus, int phy_addr, int devad,
-				 u32 regnum)
+int __mmd_phy_read_indirect(struct mii_bus *bus, int phy_addr, int devad,
+			    u32 regnum)
 {
 	int ret;
 
@@ -558,9 +558,10 @@ static int mmd_phy_read_indirect(struct mii_bus *bus, int phy_addr, int devad,
 	/* Read the content of the MMD's selected register */
 	return __mdiobus_read(bus, phy_addr, MII_MMD_DATA);
 }
+EXPORT_SYMBOL(__mmd_phy_read_indirect);
 
-static int mmd_phy_write_indirect(struct mii_bus *bus, int phy_addr, int devad,
-				  u32 regnum, u16 val)
+int __mmd_phy_write_indirect(struct mii_bus *bus, int phy_addr, int devad,
+			     u32 regnum, u16 val)
 {
 	int ret;
 
@@ -571,6 +572,7 @@ static int mmd_phy_write_indirect(struct mii_bus *bus, int phy_addr, int devad,
 	/* Write the data into MMD's selected register */
 	return __mdiobus_write(bus, phy_addr, MII_MMD_DATA, val);
 }
+EXPORT_SYMBOL(__mmd_phy_write_indirect);
 
 static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
 			int devad, u32 regnum)
@@ -578,7 +580,7 @@ static int mmd_phy_read(struct mii_bus *bus, int phy_addr, bool is_c45,
 	if (is_c45)
 		return __mdiobus_c45_read(bus, phy_addr, devad, regnum);
 
-	return mmd_phy_read_indirect(bus, phy_addr, devad, regnum);
+	return __mmd_phy_read_indirect(bus, phy_addr, devad, regnum);
 }
 
 static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
@@ -587,7 +589,7 @@ static int mmd_phy_write(struct mii_bus *bus, int phy_addr, bool is_c45,
 	if (is_c45)
 		return __mdiobus_c45_write(bus, phy_addr, devad, regnum, val);
 
-	return mmd_phy_write_indirect(bus, phy_addr, devad, regnum, val);
+	return __mmd_phy_write_indirect(bus, phy_addr, devad, regnum, val);
 }
 
 /**
diff --git a/include/linux/phy.h b/include/linux/phy.h
index e9e85d347587..65b79b155f3a 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -1358,6 +1358,16 @@ int phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum);
 	__ret; \
 })
 
+/*
+ * __mmd_phy_read_indirect, __mmd_phy_write_indirect - Convenience functions for
+ * indirectly accessing MMD registers via clause 22 registers 13 and 14. Can be
+ * used in phy_driver's .read_mmd and .write_mmd methods.
+ */
+int __mmd_phy_read_indirect(struct mii_bus *bus, int phy_addr, int devad,
+			    u32 regnum);
+int __mmd_phy_write_indirect(struct mii_bus *bus, int phy_addr, int devad,
+			     u32 regnum, u16 val);
+
 /*
  * __phy_read_mmd - Convenience function for reading a register
  * from an MMD on a given PHY.
-- 
2.41.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ