[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1558576444-25080-1-git-send-email-fugang.duan@nxp.com>
Date: Thu, 23 May 2019 01:55:23 +0000
From: Andy Duan <fugang.duan@....com>
To: "davem@...emloft.net" <davem@...emloft.net>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"baruch@...s.co.il" <baruch@...s.co.il>,
Andy Duan <fugang.duan@....com>
Subject: [PATCH net,stable 1/1] net: fec: add defer probe for
of_get_mac_address
If MAC address read from nvmem efuse by calling .of_get_mac_address(),
but nvmem efuse is registerred later than the driver, then it
return -EPROBE_DEFER value. So modify the driver to support
defer probe when read MAC address from nvmem efuse.
Signed-off-by: Fugang Duan <fugang.duan@....com>
---
drivers/net/ethernet/freescale/fec_main.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 848defa..a76b609 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1634,7 +1634,7 @@ static int fec_enet_rx_napi(struct napi_struct *napi, int budget)
}
/* ------------------------------------------------------------------------- */
-static void fec_get_mac(struct net_device *ndev)
+static int fec_get_mac(struct net_device *ndev)
{
struct fec_enet_private *fep = netdev_priv(ndev);
struct fec_platform_data *pdata = dev_get_platdata(&fep->pdev->dev);
@@ -1657,6 +1657,8 @@ static void fec_get_mac(struct net_device *ndev)
const char *mac = of_get_mac_address(np);
if (!IS_ERR(mac))
iap = (unsigned char *) mac;
+ else if (PTR_ERR(mac) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
}
}
@@ -1693,7 +1695,7 @@ static void fec_get_mac(struct net_device *ndev)
eth_hw_addr_random(ndev);
netdev_info(ndev, "Using random MAC address: %pM\n",
ndev->dev_addr);
- return;
+ return 0;
}
memcpy(ndev->dev_addr, iap, ETH_ALEN);
@@ -1701,6 +1703,8 @@ static void fec_get_mac(struct net_device *ndev)
/* Adjust MAC if using macaddr */
if (iap == macaddr)
ndev->dev_addr[ETH_ALEN-1] = macaddr[ETH_ALEN-1] + fep->dev_id;
+
+ return 0;
}
/* ------------------------------------------------------------------------- */
@@ -3146,7 +3150,10 @@ static int fec_enet_init(struct net_device *ndev)
memset(cbd_base, 0, bd_size);
/* Get the Ethernet address */
- fec_get_mac(ndev);
+ ret = fec_get_mac(ndev);
+ if (ret)
+ return ret;
+
/* make sure MAC we just acquired is programmed into the hw */
fec_set_mac_address(ndev, NULL);
--
2.7.4
Powered by blists - more mailing lists