mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Moritz Fischer <moritz.fischer@ettus.com>
To: netdev@vger.kernel.org
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	alex.williams@ni.com, andrew@lunn.ch, robh+dt@kernel.org,
	davem@davemloft.net, moritz.fischer@ettus.com,
	Moritz Fischer <mdf@kernel.org>
Subject: [PATCH net-next 2/3] net: nixge: Add support for fixed-link configurations
Date: Mon,  4 Feb 2019 09:30:39 -0800	[thread overview]
Message-ID: <20190204173040.5538-3-moritz.fischer@ettus.com> (raw)
In-Reply-To: <20190204173040.5538-1-moritz.fischer@ettus.com>

From: Moritz Fischer <mdf@kernel.org>

Add support for fixed-link configurations to nixge driver.

Signed-off-by: Moritz Fischer <mdf@kernel.org>
---
 drivers/net/ethernet/ni/nixge.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index c8dd1e4c759d..96f7a9818294 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -1282,9 +1282,9 @@ static int nixge_of_get_resources(struct platform_device *pdev)
 
 static int nixge_probe(struct platform_device *pdev)
 {
+	struct device_node *mn, *phy_node;
 	struct nixge_priv *priv;
 	struct net_device *ndev;
-	struct device_node *mn;
 	const u8 *mac_addr;
 	int err;
 
@@ -1353,21 +1353,30 @@ static int nixge_probe(struct platform_device *pdev)
 		goto unregister_mdio;
 	}
 
-	priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
-	if (!priv->phy_node) {
-		netdev_err(ndev, "not find \"phy-handle\" property\n");
-		err = -EINVAL;
-		goto unregister_mdio;
+	phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
+	if (!phy_node && of_phy_is_fixed_link(pdev->dev.of_node)) {
+		err = of_phy_register_fixed_link(pdev->dev.of_node);
+		if (err < 0) {
+			netdev_err(ndev, "broken fixed-link specification\n");
+			goto unregister_mdio;
+		}
+		phy_node = of_node_get(pdev->dev.of_node);
 	}
+	priv->phy_node = phy_node;
 
 	err = register_netdev(priv->ndev);
 	if (err) {
 		netdev_err(ndev, "register_netdev() error (%i)\n", err);
-		goto unregister_mdio;
+		goto free_phy;
 	}
 
 	return 0;
 
+free_phy:
+	if (of_phy_is_fixed_link(pdev->dev.of_node))
+		of_phy_deregister_fixed_link(pdev->dev.of_node);
+	of_node_put(phy_node);
+
 unregister_mdio:
 	if (priv->mii_bus)
 		mdiobus_unregister(priv->mii_bus);
@@ -1385,6 +1394,10 @@ static int nixge_remove(struct platform_device *pdev)
 
 	unregister_netdev(ndev);
 
+	if (of_phy_is_fixed_link(pdev->dev.of_node))
+		of_phy_deregister_fixed_link(pdev->dev.of_node);
+	of_node_put(priv->phy_node);
+
 	if (priv->mii_bus)
 		mdiobus_unregister(priv->mii_bus);
 
-- 
2.20.1


  parent reply	other threads:[~2019-02-04 17:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 17:30 [PATCH net-next 0/3] nixge: Fixed-link support Moritz Fischer
2019-02-04 17:30 ` [PATCH net-next 1/3] net: nixge: Make mdio child node optional Moritz Fischer
2019-02-04 17:30 ` Moritz Fischer [this message]
2019-02-04 17:30 ` [PATCH net-next 3/3] dt-bindings: net: Add fixed-link support Moritz Fischer
2019-02-05 18:34 ` [PATCH net-next 0/3] nixge: Fixed-link support David Miller

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=20190204173040.5538-3-moritz.fischer@ettus.com \
    --to=moritz.fischer@ettus.com \
    --cc=alex.williams@ni.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@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

all inboxes | Powered by JetHome®