staging: octeon: repair "fixed-link" support
authorAlexander Sverdlin <alexander.sverdlin@nokia.com>
Fri, 16 Oct 2020 10:18:57 +0000 (12:18 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Nov 2020 09:24:01 +0000 (10:24 +0100)
commit 179f5dc36b0a1aa31538d7d8823deb65c39847b3 upstream.

The PHYs must be registered once in device probe function, not in device
open callback because it's only possible to register them once.

Fixes: a25e278020bf ("staging: octeon: support fixed-link phys")
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Cc: stable <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20201016101858.11374-1-alexander.sverdlin@nokia.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/octeon/ethernet-mdio.c
drivers/staging/octeon/ethernet.c

index 691e4a51ace43197766e55f9aca471918270b2ec..99f45012bc3f879a7d272b2f5fe904a6175f66b4 100644 (file)
@@ -155,12 +155,6 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
 
        phy_node = of_parse_phandle(priv->of_node, "phy-handle", 0);
        if (!phy_node && of_phy_is_fixed_link(priv->of_node)) {
-               int rc;
-
-               rc = of_phy_register_fixed_link(priv->of_node);
-               if (rc)
-                       return rc;
-
                phy_node = of_node_get(priv->of_node);
        }
        if (!phy_node)
index 12354440a334a35dc330414fc81214b83dedcf5c..7601b800de077fc2c6b4e3af8ffead3b6f27b99d 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/phy.h>
 #include <linux/slab.h>
 #include <linux/interrupt.h>
+#include <linux/of_mdio.h>
 #include <linux/of_net.h>
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
@@ -880,6 +881,14 @@ static int cvm_oct_probe(struct platform_device *pdev)
                                break;
                        }
 
+                       if (priv->of_node && of_phy_is_fixed_link(priv->of_node)) {
+                               if (of_phy_register_fixed_link(priv->of_node)) {
+                                       netdev_err(dev, "Failed to register fixed link for interface %d, port %d\n",
+                                                  interface, priv->port);
+                                       dev->netdev_ops = NULL;
+                               }
+                       }
+
                        if (!dev->netdev_ops) {
                                free_netdev(dev);
                        } else if (register_netdev(dev) < 0) {