Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ixp4xx_eth: Set MAC address from device tree

If there is a MAC address specified in the device tree, then
use it. This is already perfectly legal to specify in accordance
with the generic ethernet-controller.yaml schema.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Linus Walleij and committed by
David S. Miller
877d4e3c b3ba206c

+9 -1
+9 -1
drivers/net/ethernet/xscale/ixp4xx_eth.c
··· 29 29 #include <linux/net_tstamp.h> 30 30 #include <linux/of.h> 31 31 #include <linux/of_mdio.h> 32 + #include <linux/of_net.h> 32 33 #include <linux/phy.h> 33 34 #include <linux/platform_device.h> 34 35 #include <linux/ptp_classify.h> ··· 157 156 u8 phy; /* MII PHY ID, 0 - 31 */ 158 157 u8 rxq; /* configurable, currently 0 - 31 only */ 159 158 u8 txreadyq; 160 - u8 hwaddr[6]; 159 + u8 hwaddr[ETH_ALEN]; 161 160 u8 npe; /* NPE instance used by this interface */ 162 161 bool has_mdio; /* If this instance has an MDIO bus */ 163 162 }; ··· 1388 1387 struct of_phandle_args npe_spec; 1389 1388 struct device_node *mdio_np; 1390 1389 struct eth_plat_info *plat; 1390 + u8 mac[ETH_ALEN]; 1391 1391 int ret; 1392 1392 1393 1393 plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL); ··· 1429 1427 return NULL; 1430 1428 } 1431 1429 plat->txreadyq = queue_spec.args[0]; 1430 + 1431 + ret = of_get_mac_address(np, mac); 1432 + if (!ret) { 1433 + dev_info(dev, "Setting macaddr from DT %pM\n", mac); 1434 + memcpy(plat->hwaddr, mac, ETH_ALEN); 1435 + } 1432 1436 1433 1437 return plat; 1434 1438 }