From: Richard Cochran <richardcochran@gmail.com>
To: netdev@vger.kernel.org
Cc: devicetree@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
David Miller <davem@davemloft.net>,
Florian Fainelli <f.fainelli@gmail.com>,
Jacob Keller <jacob.e.keller@intel.com>,
Mark Rutland <mark.rutland@arm.com>,
Miroslav Lichvar <mlichvar@redhat.com>,
Rob Herring <robh+dt@kernel.org>,
Willem de Bruijn <willemb@google.com>
Subject: [PATCH V2 net-next 4/5] net: mdio: of: Register discovered MII time stampers.
Date: Sun, 7 Oct 2018 10:38:22 -0700 [thread overview]
Message-ID: <20181007173823.21590-5-richardcochran@gmail.com> (raw)
When parsing a PHY node, register its time stamper, if any, and attach
the instance to the PHY device.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
drivers/net/phy/phy_device.c | 3 +++
drivers/of/of_mdio.c | 26 ++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index a454432d166f..c24bce9b7270 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -833,6 +833,9 @@ EXPORT_SYMBOL(phy_device_register);
*/
void phy_device_remove(struct phy_device *phydev)
{
+ if (phydev->mii_ts)
+ unregister_mii_timestamper(phydev->mii_ts);
+
device_del(&phydev->mdio.dev);
/* Assert the reset signal */
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index f76c10ecc616..7699f167e4a9 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -44,14 +44,38 @@ static int of_get_phy_id(struct device_node *device, u32 *phy_id)
return -EINVAL;
}
+struct mii_timestamper *of_find_mii_timestamper(struct device_node *node)
+{
+ struct of_phandle_args args;
+ unsigned int port = 0;
+ int err;
+
+ err = of_parse_phandle_with_args(node, "timestamper",
+ "#phandle-cells", 0, &args);
+ if (err == -ENOENT)
+ return NULL;
+ else if (err)
+ return ERR_PTR(err);
+
+ if (args.args_count >= 1)
+ port = args.args[0];
+
+ return register_mii_timestamper(args.np, port);
+}
+
static int of_mdiobus_register_phy(struct mii_bus *mdio,
struct device_node *child, u32 addr)
{
+ struct mii_timestamper *mii_ts;
struct phy_device *phy;
bool is_c45;
int rc;
u32 phy_id;
+ mii_ts = of_find_mii_timestamper(child);
+ if (IS_ERR(mii_ts))
+ return PTR_ERR(mii_ts);
+
is_c45 = of_device_is_compatible(child,
"ethernet-phy-ieee802.3-c45");
@@ -97,6 +121,8 @@ static int of_mdiobus_register_phy(struct mii_bus *mdio,
return rc;
}
+ phy->mii_ts = mii_ts;
+
dev_dbg(&mdio->dev, "registered phy %s at address %i\n",
child->name, addr);
return 0;
--
2.11.0
next reply other threads:[~2018-10-07 17:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-07 17:38 Richard Cochran [this message]
2018-10-07 18:14 ` [PATCH V2 net-next 4/5] net: mdio: of: Register discovered MII time stampers Florian Fainelli
2018-10-07 18:17 ` Andrew Lunn
2018-10-07 19:26 ` Richard Cochran
2018-10-07 19:57 ` Andrew Lunn
2018-10-07 19:23 ` Richard Cochran
2018-10-07 18:19 ` Andrew Lunn
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=20181007173823.21590-5-richardcochran@gmail.com \
--to=richardcochran@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=jacob.e.keller@intel.com \
--cc=mark.rutland@arm.com \
--cc=mlichvar@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=willemb@google.com \
/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).