[U-Boot] [PATCHv6 16/28] fdt: fixup_eth: Remove code duplication with a function

Olliver Schinagl oliver at schinagl.nl
Mon May 15 08:02:32 UTC 2017


In fdt_support.c we use a loop to parse the mac address string from the
fdt blob, net.h has a function for this however, so lets use it.

Also, rename the variable from tmp to something more descriptive.

Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
---
 common/fdt_support.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index d462bf0642..4d05465232 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -469,8 +469,8 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
 
 void fdt_fixup_ethernet(void *fdt)
 {
-	int i, j, prop;
-	char *tmp, *end;
+	int i, prop;
+	char *fdt_eth_addr;
 	char mac[ETH_ENETADDR_ENV_NAME_LEN];
 	const char *path;
 	unsigned char mac_addr[ARP_HLEN];
@@ -509,16 +509,11 @@ void fdt_fixup_ethernet(void *fdt)
 			} else {
 				continue;
 			}
-			tmp = getenv(mac);
-			if (!tmp)
+			fdt_eth_addr = getenv(mac);
+			if (!fdt_eth_addr)
 				continue;
 
-			for (j = 0; j < 6; j++) {
-				mac_addr[j] = tmp ?
-					      simple_strtoul(tmp, &end, 16) : 0;
-				if (tmp)
-					tmp = (*end) ? end + 1 : end;
-			}
+			eth_parse_enetaddr(fdt_eth_addr, mac_addr);
 
 			do_fixup_by_path(fdt, path, "mac-address",
 					 &mac_addr, 6, 0);
-- 
2.11.0



More information about the U-Boot mailing list