ath79: ag71xx: support probe defferal for getting MAC address
authorRobert Marko <robimarko@gmail.com>
Wed, 19 Jun 2024 09:26:47 +0000 (11:26 +0200)
committerRobert Marko <robimarko@gmail.com>
Thu, 20 Jun 2024 09:11:36 +0000 (11:11 +0200)
Currently, of_get_ethdev_address() return is checked for any return error
code which means that trying to get the MAC from NVMEM cells that is backed
by MTD will fail if it was not probed before ag71xx.

So, lets check the return error code for EPROBE_DEFER and defer the ag71xx
probe in that case until the underlying NVMEM device is live.

Link: https://github.com/openwrt/openwrt/pull/15752
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c

index 8f2a9c772321ac819e8843acb54a4c38f90162e6..f63e93f978a3816eb4e2c6c6b52d995cf366c90c 100644 (file)
@@ -1668,7 +1668,11 @@ static int ag71xx_probe(struct platform_device *pdev)
        ag->stop_desc->ctrl = 0;
        ag->stop_desc->next = (u32) ag->stop_desc_dma;
 
-       if (of_get_ethdev_address(np, dev)) {
+       err = of_get_ethdev_address(np, dev);
+       if (err) {
+               if (err == -EPROBE_DEFER)
+                       return err;
+
                dev_err(&pdev->dev, "invalid MAC address, using random address\n");
                eth_hw_addr_random(dev);
        }