702b7641fdf6641933c32c26f1ab21b3bf092ba8
[openwrt/staging/blocktrron.git] /
1 From e93a766da57fff3273bcb618edf5dfca1fb86b89 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Thu, 15 Sep 2022 15:30:13 +0200
4 Subject: [PATCH] net: broadcom: bcm4908_enet: handle -EPROBE_DEFER when
5 getting MAC
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Reading MAC from OF may return -EPROBE_DEFER if underlaying NVMEM device
11 isn't ready yet. In such case pass that error code up and "wait" to be
12 probed later.
13
14 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
15 Link: https://lore.kernel.org/r/20220915133013.2243-1-zajec5@gmail.com
16 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
17 ---
18 drivers/net/ethernet/broadcom/bcm4908_enet.c | 13 +++++++++----
19 1 file changed, 9 insertions(+), 4 deletions(-)
20
21 --- a/drivers/net/ethernet/broadcom/bcm4908_enet.c
22 +++ b/drivers/net/ethernet/broadcom/bcm4908_enet.c
23 @@ -714,7 +714,9 @@ static int bcm4908_enet_probe(struct pla
24 return err;
25
26 SET_NETDEV_DEV(netdev, &pdev->dev);
27 - of_get_mac_address(dev->of_node, netdev->dev_addr);
28 + err = of_get_mac_address(dev->of_node, netdev->dev_addr);
29 + if (err == -EPROBE_DEFER)
30 + goto err_dma_free;
31 if (!is_valid_ether_addr(netdev->dev_addr))
32 eth_hw_addr_random(netdev);
33 netdev->netdev_ops = &bcm4908_enet_netdev_ops;
34 @@ -725,14 +727,17 @@ static int bcm4908_enet_probe(struct pla
35 netif_napi_add(netdev, &enet->rx_ring.napi, bcm4908_enet_poll_rx, NAPI_POLL_WEIGHT);
36
37 err = register_netdev(netdev);
38 - if (err) {
39 - bcm4908_enet_dma_free(enet);
40 - return err;
41 - }
42 + if (err)
43 + goto err_dma_free;
44
45 platform_set_drvdata(pdev, enet);
46
47 return 0;
48 +
49 +err_dma_free:
50 + bcm4908_enet_dma_free(enet);
51 +
52 + return err;
53 }
54
55 static int bcm4908_enet_remove(struct platform_device *pdev)