net: bcmasp: handle EPROBE_DEFER for MAC retrieval
Subsystems (3)
PATCH v2 1/1 net: bcmasp: handle EPROBE_DEFER for MAC retrieval
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 <[email protected]>
---
v2: use goto after of_get_mac_address probe deferral
drivers/net/ethernet/broadcom/asp2/bcmasp.c | 6 +++--- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/asp2/bcmasp.c +3 -3
@@ -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) { -dev_err (dev,"Cannot create eth interface %d\n" , i); +if (IS_ERR (intf)) {of_node_put (ports_node); - ret = -EINVAL ; + ret =dev_err_probe (dev,PTR_ERR (intf),"Cannot create eth interface %d\n" , + i); goto err_cleanup; }list_add_tail (&intf->list, &priv->intfs);
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +4 -2
@@ -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 ) + goto err_deregister_fixed_link;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