Re: [PATCH v5 3/5] net: of_net: Derive MAC addresses from a unique device ID

From: Andrew Lunn

Date: Tue Dec 01 2026 - 08:06:24 EST


On Tue, Dec 01, 2026 at 08:17:03AM +0400, Alexey Charkov wrote:
> On Tue, Dec 1, 2026 at 5:30 AM Andrew Lunn <andrew@xxxxxxx> wrote:
> >
> > > @@ -142,7 +239,11 @@ int of_get_mac_address(struct device_node *np, u8 *addr)
> > > if (!ret)
> > > return 0;
> > >
> > > - return of_get_mac_address_nvmem(np, addr);
> > > + ret = of_get_mac_address_nvmem(np, addr);
> > > + if (!ret || ret == -EPROBE_DEFER)
> > > + return ret;
> >
> > You need to be careful here. There might be devices which currently
> > work because they return EPROBE_DEFER here and try again later.
>
> But that's exactly why I'm catching EPROBE_DEFER and returning it
> immediately, so that the driver core can retry once the NVMEM cell
> appears, instead of falling through to the next case. Am I missing
> anything?
>
> > Also, none of the other sources of the MAC address in this function
> > special case it.
>
> I don't think any of the others can defer, because they don't rely on
> an external provider. While NVMEM relies on the nvmem driver, which
> might be a module.

Ah, this function is not great. Generally we consider real errors as
fatal and return them. EIO, ETIMEDOUT, EINVAL etc indicate something
has gone wrong. EPROBE_DEFER would also fall into that class. Errors
like ENODEV would indicate the property does not exist, and we should
try the next.

However, this code does not do that. All errors are ignored, and the
next source is tried.

So your change is correct, in this context. And it is probably too
late to add proper error handling.

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew