From: Martin Blumenstingl Date: Sat, 27 Jul 2019 19:21:37 +0000 (+0200) Subject: net: stmmac: manage errors returned by of_get_mac_address() X-Git-Tag: v5.2.11~116 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=edd7585d6751c993327a9eff6f56136c3baa4b21;p=users%2Fdwmw2%2Flinux.git net: stmmac: manage errors returned by of_get_mac_address() [ Upstream commit 195b2919ccd7ffcaf6b6bbcb39444a53ab8308c7 ] Commit d01f449c008a ("of_net: add NVMEM support to of_get_mac_address") added support for reading the MAC address from an nvmem-cell. This required changing the logic to return an error pointer upon failure. If stmmac is loaded before the nvmem provider driver then of_get_mac_address() return an error pointer with -EPROBE_DEFER. Propagate this error so the stmmac driver will be probed again after the nvmem provider driver is loaded. Default to a random generated MAC address in case of any other error, instead of using the error pointer as MAC address. Fixes: d01f449c008a ("of_net: add NVMEM support to of_get_mac_address") Signed-off-by: Martin Blumenstingl Reviewed-by: Neil Armstrong Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 0f0f4b31eb7ec..9b5218a8c15bc 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -385,6 +385,13 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) return ERR_PTR(-ENOMEM); *mac = of_get_mac_address(np); + if (IS_ERR(*mac)) { + if (PTR_ERR(*mac) == -EPROBE_DEFER) + return ERR_CAST(*mac); + + *mac = NULL; + } + plat->interface = of_get_phy_mode(np); /* Get max speed of operation from device tree */