From 29cfe6f4fb7d187f65564764a0ecf2caf9d8ed58 Mon Sep 17 00:00:00 2001 From: Timur Tabi Date: Fri, 16 Feb 2007 12:01:29 -0600 Subject: [POWERPC] add of_get_mac_address and update fsl_soc.c to use it Add function of_get_mac_address(), which obtains the best MAC address to use from the device tree by checking various properties in order. The order is: 'mac-address', then 'local-mac-address', then 'address'. It skips properties that contain invalid MAC addresses, which were probably not initialized by U-Boot. Update gfar_of_init() and fs_enet_of_init() in fsl_soc.c to call of_get_mac_address(). Signed-off-by: Timur Tabi Signed-off-by: Paul Mackerras --- arch/powerpc/sysdev/fsl_soc.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'arch/powerpc/sysdev/fsl_soc.c') diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index 34161bc5a02..d20f02927f7 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c @@ -233,14 +233,7 @@ static int __init gfar_of_init(void) goto err; } - mac_addr = get_property(np, "local-mac-address", NULL); - if (mac_addr == NULL) - mac_addr = get_property(np, "mac-address", NULL); - if (mac_addr == NULL) { - /* Obsolete */ - mac_addr = get_property(np, "address", NULL); - } - + mac_addr = of_get_mac_address(np); if (mac_addr) memcpy(gfar_data.mac_addr, mac_addr, 6); @@ -646,8 +639,9 @@ static int __init fs_enet_of_init(void) goto unreg; } - mac_addr = get_property(np, "mac-address", NULL); - memcpy(fs_enet_data.macaddr, mac_addr, 6); + mac_addr = of_get_mac_address(np); + if (mac_addr) + memcpy(fs_enet_data.macaddr, mac_addr, 6); ph = get_property(np, "phy-handle", NULL); phy = of_find_node_by_phandle(*ph); @@ -931,8 +925,9 @@ static int __init fs_enet_of_init(void) goto err; r[0].name = enet_regs; - mac_addr = (void *)get_property(np, "mac-address", NULL); - memcpy(fs_enet_data.macaddr, mac_addr, 6); + mac_addr = of_get_mac_address(np); + if (mac_addr) + memcpy(fs_enet_data.macaddr, mac_addr, 6); ph = (phandle *) get_property(np, "phy-handle", NULL); if (ph != NULL) -- cgit v1.2.3