Skip to content

Commit 877d4e3

Browse files
Linus Walleijdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b3ba206 commit 877d4e3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/net/ethernet/xscale/ixp4xx_eth.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/net_tstamp.h>
3030
#include <linux/of.h>
3131
#include <linux/of_mdio.h>
32+
#include <linux/of_net.h>
3233
#include <linux/phy.h>
3334
#include <linux/platform_device.h>
3435
#include <linux/ptp_classify.h>
@@ -156,7 +157,7 @@ struct eth_plat_info {
156157
u8 phy; /* MII PHY ID, 0 - 31 */
157158
u8 rxq; /* configurable, currently 0 - 31 only */
158159
u8 txreadyq;
159-
u8 hwaddr[6];
160+
u8 hwaddr[ETH_ALEN];
160161
u8 npe; /* NPE instance used by this interface */
161162
bool has_mdio; /* If this instance has an MDIO bus */
162163
};
@@ -1387,6 +1388,7 @@ static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev)
13871388
struct of_phandle_args npe_spec;
13881389
struct device_node *mdio_np;
13891390
struct eth_plat_info *plat;
1391+
u8 mac[ETH_ALEN];
13901392
int ret;
13911393

13921394
plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
@@ -1428,6 +1430,12 @@ static struct eth_plat_info *ixp4xx_of_get_platdata(struct device *dev)
14281430
}
14291431
plat->txreadyq = queue_spec.args[0];
14301432

1433+
ret = of_get_mac_address(np, mac);
1434+
if (!ret) {
1435+
dev_info(dev, "Setting macaddr from DT %pM\n", mac);
1436+
memcpy(plat->hwaddr, mac, ETH_ALEN);
1437+
}
1438+
14311439
return plat;
14321440
}
14331441

0 commit comments

Comments
 (0)