Commit 8dc0ae90 authored by Moritz Fischer's avatar Moritz Fischer Committed by David S. Miller

net: nixge: Add support for fixed-link configurations

Add support for fixed-link configurations to nixge driver.
Signed-off-by: default avatarMoritz Fischer <mdf@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dd648818
...@@ -1282,9 +1282,9 @@ static int nixge_of_get_resources(struct platform_device *pdev) ...@@ -1282,9 +1282,9 @@ static int nixge_of_get_resources(struct platform_device *pdev)
static int nixge_probe(struct platform_device *pdev) static int nixge_probe(struct platform_device *pdev)
{ {
struct device_node *mn, *phy_node;
struct nixge_priv *priv; struct nixge_priv *priv;
struct net_device *ndev; struct net_device *ndev;
struct device_node *mn;
const u8 *mac_addr; const u8 *mac_addr;
int err; int err;
...@@ -1353,21 +1353,30 @@ static int nixge_probe(struct platform_device *pdev) ...@@ -1353,21 +1353,30 @@ static int nixge_probe(struct platform_device *pdev)
goto unregister_mdio; goto unregister_mdio;
} }
priv->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0);
if (!priv->phy_node) { if (!phy_node && of_phy_is_fixed_link(pdev->dev.of_node)) {
netdev_err(ndev, "not find \"phy-handle\" property\n"); err = of_phy_register_fixed_link(pdev->dev.of_node);
err = -EINVAL; if (err < 0) {
goto unregister_mdio; 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); err = register_netdev(priv->ndev);
if (err) { if (err) {
netdev_err(ndev, "register_netdev() error (%i)\n", err); netdev_err(ndev, "register_netdev() error (%i)\n", err);
goto unregister_mdio; goto free_phy;
} }
return 0; 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: unregister_mdio:
if (priv->mii_bus) if (priv->mii_bus)
mdiobus_unregister(priv->mii_bus); mdiobus_unregister(priv->mii_bus);
...@@ -1385,6 +1394,10 @@ static int nixge_remove(struct platform_device *pdev) ...@@ -1385,6 +1394,10 @@ static int nixge_remove(struct platform_device *pdev)
unregister_netdev(ndev); 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) if (priv->mii_bus)
mdiobus_unregister(priv->mii_bus); mdiobus_unregister(priv->mii_bus);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment