de13dcf66336e48621a0d2b3813aa9e9e5fc5e17
[openwrt/staging/pepe2k.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 @@ -716,10 +716,14 @@ static int bcm4908_enet_probe(struct pla
24
25 SET_NETDEV_DEV(netdev, &pdev->dev);
26 mac = of_get_mac_address(dev->of_node);
27 - if (!IS_ERR(mac))
28 + if (!IS_ERR(mac)) {
29 ether_addr_copy(netdev->dev_addr, mac);
30 - else
31 + } else if (PTR_ERR(mac) == -EPROBE_DEFER) {
32 + err = -EPROBE_DEFER;
33 + goto err_dma_free;
34 + } else {
35 eth_hw_addr_random(netdev);
36 + }
37 netdev->netdev_ops = &bcm4908_enet_netdev_ops;
38 netdev->min_mtu = ETH_ZLEN;
39 netdev->mtu = ETH_DATA_LEN;
40 @@ -728,14 +732,17 @@ static int bcm4908_enet_probe(struct pla
41 netif_napi_add(netdev, &enet->rx_ring.napi, bcm4908_enet_poll_rx, NAPI_POLL_WEIGHT);
42
43 err = register_netdev(netdev);
44 - if (err) {
45 - bcm4908_enet_dma_free(enet);
46 - return err;
47 - }
48 + if (err)
49 + goto err_dma_free;
50
51 platform_set_drvdata(pdev, enet);
52
53 return 0;
54 +
55 +err_dma_free:
56 + bcm4908_enet_dma_free(enet);
57 +
58 + return err;
59 }
60
61 static int bcm4908_enet_remove(struct platform_device *pdev)