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.
---
v2: use dev_err_probe.
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 ) +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)
Signature · 1 line
2.54.0
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, · line 1257
Quoted 7 lines
+++
b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.cdrivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1
-1@@ -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 ;
That breaks the reverse christmas tree. Otherwise this looks O.K.
Andrew
---
pw-bot: cr
Justin Chen
maintainerQuoted 43 lines · Rosen Penev
of_get_ethdev_addresscan returnEPROBE_DEFERwhen using nvmem. To handle this, encode the error withERR_PTRfor minimal changes. Adjust the only place usingbcmasp_interface_create.Signed-off-by Rosen Penev <[email protected]>---
v2: usedev_err_probe.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 +1
-1@@ -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);
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, · line 1318
Quoted 5 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +2
-0@@ -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 );
Do we need to hit unwind here? i.e. goto err_deregister_fixed_link.
Thanks,
Justin
Quoted 12 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1
-1if (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)
Quoted 49 lines · Justin Chen
Quoted 45 lines · Rosen Penev
of_get_ethdev_addresscan returnEPROBE_DEFERwhen using nvmem. To handle this, encode the error withERR_PTRfor minimal changes. Adjust the only place usingbcmasp_interface_create.Signed-off-by Rosen Penev <[email protected]>---
v2: usedev_err_probe.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 +1
-1@@ -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, }
Quoted 5 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c struct bcmasp_intf *bcmasp_interface_create(struct bcmasp_priv *priv, · line 1318
Quoted 3 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +2
-0ret =of_get_ethdev_address (ndev_dn, ndev); +if (ret == -EPROBE_DEFER ) +return ERR_PTR (-EPROBE_DEFER );Do we need to hit unwind here? i.e. goto
err_deregister_fixed_link.
Yes we do. In other news I just sent another v2 by accident. Guess I'll wait to send a v4...
Quoted 17 lines
Thanks,
JustinQuoted 12 lines
drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +1
-1if (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)