mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
net: ethernet: mtk_eth_soc: handle probe deferral
[ Upstream commit1d6d537dc5] Move the call to of_get_ethdev_address to mtk_add_mac which is part of the probe function and can hence itself return -EPROBE_DEFER should of_get_ethdev_address return -EPROBE_DEFER. This allows us to entirely get rid of the mtk_init function. The problem of of_get_ethdev_address returning -EPROBE_DEFER surfaced in situations in which the NVMEM provider holding the MAC address has not yet be loaded at the time mtk_eth_soc is initially probed. In this case probing of mtk_eth_soc should be deferred instead of falling back to use a random MAC address, so once the NVMEM provider becomes available probing can be repeated. Fixes:656e705243("net-next: mediatek: add support for MT7623 ethernet") Signed-off-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6924f3c898
commit
855643c8d2
@@ -3425,23 +3425,6 @@ static int mtk_hw_deinit(struct mtk_eth *eth)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init mtk_init(struct net_device *dev)
|
|
||||||
{
|
|
||||||
struct mtk_mac *mac = netdev_priv(dev);
|
|
||||||
struct mtk_eth *eth = mac->hw;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = of_get_ethdev_address(mac->of_node, dev);
|
|
||||||
if (ret) {
|
|
||||||
/* If the mac address is invalid, use random mac address */
|
|
||||||
eth_hw_addr_random(dev);
|
|
||||||
dev_err(eth->dev, "generated random MAC address %pM\n",
|
|
||||||
dev->dev_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void mtk_uninit(struct net_device *dev)
|
static void mtk_uninit(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct mtk_mac *mac = netdev_priv(dev);
|
struct mtk_mac *mac = netdev_priv(dev);
|
||||||
@@ -3789,7 +3772,6 @@ static const struct ethtool_ops mtk_ethtool_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct net_device_ops mtk_netdev_ops = {
|
static const struct net_device_ops mtk_netdev_ops = {
|
||||||
.ndo_init = mtk_init,
|
|
||||||
.ndo_uninit = mtk_uninit,
|
.ndo_uninit = mtk_uninit,
|
||||||
.ndo_open = mtk_open,
|
.ndo_open = mtk_open,
|
||||||
.ndo_stop = mtk_stop,
|
.ndo_stop = mtk_stop,
|
||||||
@@ -3845,6 +3827,17 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
|
|||||||
mac->hw = eth;
|
mac->hw = eth;
|
||||||
mac->of_node = np;
|
mac->of_node = np;
|
||||||
|
|
||||||
|
err = of_get_ethdev_address(mac->of_node, eth->netdev[id]);
|
||||||
|
if (err == -EPROBE_DEFER)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
/* If the mac address is invalid, use random mac address */
|
||||||
|
eth_hw_addr_random(eth->netdev[id]);
|
||||||
|
dev_err(eth->dev, "generated random MAC address %pM\n",
|
||||||
|
eth->netdev[id]->dev_addr);
|
||||||
|
}
|
||||||
|
|
||||||
memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
|
memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip));
|
||||||
mac->hwlro_ip_cnt = 0;
|
mac->hwlro_ip_cnt = 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user