Message ID | 20201016101858.11374-1-alexander.sverdlin@nokia.com (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Netdev Maintainers |
Headers | show |
> + 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); Setting dev->netdev_ops to NULL to indicate an error is pretty odd. But this is staging. How about cleaning this up. of_phy_register_fixed_link() returns an -errno which you should return. Andrew
> --- a/drivers/staging/octeon/ethernet.c > +++ b/drivers/staging/octeon/ethernet.c > @@ -13,6 +13,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> > @@ -892,6 +893,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) { > -- > 2.10.2 I would also expect a call to of_phy_deregister_fixed_link() somewhere in the driver. Andrew
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index cfb673a..0bf54584 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -147,12 +147,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) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 204f0b1..5dea6e9 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -13,6 +13,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> @@ -892,6 +893,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) {