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: <20191029174819.3502-3-michael@walle.cc>
Date:   Tue, 29 Oct 2019 18:48:18 +0100
From:   Michael Walle <michael@...le.cc>
To:     linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
        netdev@...r.kernel.org
Cc:     Michael Walle <michael@...le.cc>
Subject: [PATCH 2/3] net: phy: export __phy_{read|write}_page

Also check if the op is actually available. Otherwise return -ENOTSUPP.

Signed-off-by: Michael Walle <michael@...le.cc>
---
 drivers/net/phy/phy-core.c | 24 ++++++++++++++++++++++--
 include/linux/phy.h        |  2 ++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
index 9412669b579c..70f93e405e91 100644
--- a/drivers/net/phy/phy-core.c
+++ b/drivers/net/phy/phy-core.c
@@ -687,15 +687,35 @@ int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
 }
 EXPORT_SYMBOL_GPL(phy_modify_mmd);
 
-static int __phy_read_page(struct phy_device *phydev)
+/**
+ * __phy_read_page - get currently selected page
+ * @phydev: the phy_device struct
+ *
+ * Get the current PHY page. On error, returns a negative errno, otherwise
+ * returns the selected page number.
+ */
+int __phy_read_page(struct phy_device *phydev)
 {
+	if (!phydev->drv->read_page)
+		return -ENOTSUPP;
 	return phydev->drv->read_page(phydev);
 }
+EXPORT_SYMBOL_GPL(__phy_read_page);
 
-static int __phy_write_page(struct phy_device *phydev, int page)
+/**
+ * __phy_write_page - set the current page
+ * @phydev: the phy_device struct
+ * @page: desired page
+ *
+ * Set the current PHY page. On error, returns a negative errno.
+ */
+int __phy_write_page(struct phy_device *phydev, int page)
 {
+	if (!phydev->drv->write_page)
+		return -ENOTSUPP;
 	return phydev->drv->write_page(phydev, page);
 }
+EXPORT_SYMBOL_GPL(__phy_write_page);
 
 /**
  * phy_save_page() - take the bus lock and save the current page
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 9a0e981df502..70eca3cb25ff 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -797,6 +797,8 @@ int __phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
 		     u16 mask, u16 set);
 int phy_modify_mmd(struct phy_device *phydev, int devad, u32 regnum,
 		   u16 mask, u16 set);
+int __phy_read_page(struct phy_device *phydev);
+int __phy_write_page(struct phy_device *phydev, int page);
 
 /**
  * __phy_set_bits - Convenience function for setting bits in a PHY register
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ