diff mbox

[U-Boot,10/14] fdt: fixup_eth: Remove code duplication with a function

Message ID 20161125153032.14617-11-oliver@schinagl.nl
State Superseded
Delegated to: Joe Hershberger
Headers show

Commit Message

Olliver Schinagl Nov. 25, 2016, 3:30 p.m. UTC
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@schinagl.nl>
---
 common/fdt_support.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

Comments

Joe Hershberger Nov. 30, 2016, 8:23 p.m. UTC | #1
On Fri, Nov 25, 2016 at 9:30 AM, Olliver Schinagl <oliver@schinagl.nl> wrote:
> 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@schinagl.nl>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

diff --git a/common/fdt_support.c b/common/fdt_support.c
index 89e6e47..20a3dd9 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -467,8 +467,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_LEN];
 	const char *path;
 	unsigned char mac_addr[ARP_HLEN];
@@ -503,16 +503,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);