diff mbox

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

Message ID 20170515080244.21345-17-oliver@schinagl.nl
State Changes Requested
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Commit Message

Olliver Schinagl May 15, 2017, 8:02 a.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 May 30, 2017, 9:14 p.m. UTC | #1
On Mon, May 15, 2017 at 3:02 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 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);