Re: [PATCHv2 net-next] net: bcmasp: handle EPROBE_DEFER for MAC retrieval

Rosen Penev
2026-04-29T03:36:17Z

On Tue, Apr 28, 2026 at 10:43 AM Justin Chen <justin.chen@broadcom.com> wrote:
>
>
>
> On 4/27/26 6:43 PM, Rosen Penev wrote:
> > 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 <rosenp@gmail.com>
> > ---
> > 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(-)
> >
> > diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c
> > index 972474893a6b..e9b11b956344 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) {
> > - 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);
> > 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);
>
> 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...
>
> Thanks,
> Justin
>
> > 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)
>