From: Michael Walle <michael@walle.cc>
To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
netdev@vger.kernel.org
Cc: Michael Walle <michael@walle.cc>
Subject: [PATCH 2/3] net: phy: export __phy_{read|write}_page
Date: Tue, 29 Oct 2019 18:48:18 +0100 [thread overview]
Message-ID: <20191029174819.3502-3-michael@walle.cc> (raw)
In-Reply-To: <20191029174819.3502-1-michael@walle.cc>
Also check if the op is actually available. Otherwise return -ENOTSUPP.
Signed-off-by: Michael Walle <michael@walle.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
next prev parent reply other threads:[~2019-10-29 17:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-29 17:48 [PATCH 0/3] net: phy: initialize PHYs via device tree properties Michael Walle
2019-10-29 17:48 ` [PATCH 1/3] dt-bindings: net: phy: Add reg-init property Michael Walle
2019-10-29 17:48 ` Michael Walle [this message]
2019-10-29 17:48 ` [PATCH 3/3] net: phy: Use device tree properties to initialize any PHYs Michael Walle
2019-10-29 17:59 ` [PATCH 0/3] net: phy: initialize PHYs via device tree properties Florian Fainelli
2019-10-29 18:25 ` Andrew Lunn
2019-10-29 20:54 ` Michael Walle
2019-10-29 20:59 ` Florian Fainelli
2019-10-30 13:19 ` Michael Walle
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=20191029174819.3502-3-michael@walle.cc \
--to=michael@walle.cc \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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).