ath79: ag71xx: make of_get_mac_address probe defer aware
authorPetr Štetiar <ynezz@true.cz>
Tue, 30 Apr 2019 11:24:20 +0000 (13:24 +0200)
committerPetr Štetiar <ynezz@true.cz>
Fri, 3 May 2019 06:59:24 +0000 (08:59 +0200)
of_get_mac_address now uses NVMEM under the hood, so it could now return
EPROBE_DEFER and it needs to be handled, which means, that it needs to
be propagated back to the device driver subsystem in order to be handled
as designed.

While at it, remove superfluous call of is_valid_ether_addr, as the MAC
address returned by of_get_mac_address was already checked by
is_valid_ether_addr internally.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
target/linux/ath79/files/drivers/net/ethernet/atheros/ag71xx/ag71xx_main.c

index 8cff56a11a66f9c90e75c4d67acfd2e1cb965005..0cf955a54ae44b094c37e553054d48fd9cd9c0be 100644 (file)
@@ -1468,9 +1468,11 @@ static int ag71xx_probe(struct platform_device *pdev)
        ag->stop_desc->next = (u32) ag->stop_desc_dma;
 
        mac_addr = of_get_mac_address(np);
-       if (mac_addr)
+       if (PTR_ERR(mac_addr) == -EPROBE_DEFER) {
+               return -EPROBE_DEFER;
+       } else if (!IS_ERR_OR_NULL(mac_addr)) {
                memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
-       if (!mac_addr || !is_valid_ether_addr(dev->dev_addr)) {
+       } else {
                dev_err(&pdev->dev, "invalid MAC address, using random address\n");
                eth_random_addr(dev->dev_addr);
        }