of_get_ethdev_address can return EPROBE_DEFER when using nvmem. To handle this, encode the error with ERR_PTR for minimal changes. Adjust the only place using bcmasp_interface_create. Signed-off-by: Rosen Penev --- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 4 ++-- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c index 972474893a6b..31a9560c4aee 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -1333,10 +1333,10 @@ static int bcmasp_probe(struct platform_device *pdev) i = 0; for_each_available_child_of_node_scoped(ports_node, intf_node) { intf = bcmasp_interface_create(priv, intf_node, i); - if (!intf) { + if (IS_ERR(intf)) { dev_err(dev, "Cannot create eth interface %d\n", i); of_node_put(ports_node); - ret = -EINVAL; + ret = PTR_ERR(intf); goto err_cleanup; } list_add_tail(&intf->list, &priv->intfs); diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index ec63f50a849e..caf0e408e2f7 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -1254,7 +1254,7 @@ struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, struct device *dev = &priv->pdev->dev; struct bcmasp_intf *intf; struct net_device *ndev; - int ch, port, ret; + int ch, port, ret = -EINVAL; if (of_property_read_u32(ndev_dn, "reg", &port)) { dev_warn(dev, "%s: invalid port number\n", ndev_dn->name); @@ -1314,6 +1314,8 @@ struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, } ret = of_get_ethdev_address(ndev_dn, ndev); + if (ret == -EPROBE_DEFER) + return ERR_PTR(-EPROBE_DEFER); if (ret) { netdev_warn(ndev, "using random Ethernet MAC\n"); eth_hw_addr_random(ndev); @@ -1340,7 +1342,7 @@ struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, err_free_netdev: free_netdev(ndev); err: - return NULL; + return ERR_PTR(ret); } void bcmasp_interface_destroy(struct bcmasp_intf *intf) -- 2.54.0