1cf761838c517e98efcc6e2d3577274d5baadbea
[openwrt/staging/robimarko.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 @@ -720,6 +720,8 @@ static int bcm4908_enet_probe(struct pla
24
25 SET_NETDEV_DEV(netdev, &pdev->dev);
26 err = of_get_mac_address(dev->of_node, netdev->dev_addr);
27 + if (err == -EPROBE_DEFER)
28 + goto err_dma_free;
29 if (err)
30 eth_hw_addr_random(netdev);
31 netdev->netdev_ops = &bcm4908_enet_netdev_ops;
32 @@ -730,14 +732,17 @@ static int bcm4908_enet_probe(struct pla
33 netif_napi_add(netdev, &enet->rx_ring.napi, bcm4908_enet_poll_rx, NAPI_POLL_WEIGHT);
34
35 err = register_netdev(netdev);
36 - if (err) {
37 - bcm4908_enet_dma_free(enet);
38 - return err;
39 - }
40 + if (err)
41 + goto err_dma_free;
42
43 platform_set_drvdata(pdev, enet);
44
45 return 0;
46 +
47 +err_dma_free:
48 + bcm4908_enet_dma_free(enet);
49 +
50 + return err;
51 }
52
53 static int bcm4908_enet_remove(struct platform_device *pdev)