Module Name:    src
Committed By:   jmcneill
Date:           Wed Oct 26 11:31:11 UTC 2022

Modified Files:
        src/sys/arch/arm/xilinx: zynq_cemac.c

Log Message:
Inherit MAC address from Devicetree "local-mac-address" property.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/xilinx/zynq_cemac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/xilinx/zynq_cemac.c
diff -u src/sys/arch/arm/xilinx/zynq_cemac.c:1.3 src/sys/arch/arm/xilinx/zynq_cemac.c:1.4
--- src/sys/arch/arm/xilinx/zynq_cemac.c:1.3	Tue Oct 25 22:49:39 2022
+++ src/sys/arch/arm/xilinx/zynq_cemac.c	Wed Oct 26 11:31:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: zynq_cemac.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $	*/
+/*	$NetBSD: zynq_cemac.c,v 1.4 2022/10/26 11:31:11 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2015  Genetec Corporation.  All rights reserved.
  * Written by Hashimoto Kenichi for Genetec Corporation.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c,v 1.3 2022/10/25 22:49:39 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c,v 1.4 2022/10/26 11:31:11 jmcneill Exp $");
 
 #include "opt_soc.h"
 
@@ -41,6 +41,8 @@ __KERNEL_RCSID(0, "$NetBSD: zynq_cemac.c
 #include <dev/cadence/cemacreg.h>
 #include <dev/cadence/if_cemacvar.h>
 
+#include <net/if_ether.h>
+
 #include <dev/fdt/fdtvar.h>
 
 static const struct device_compatible_entry compat_data[] = {
@@ -61,11 +63,13 @@ cemac_attach(device_t parent, device_t s
 {
 	struct fdt_attach_args * const faa = aux;
 	const int phandle = faa->faa_phandle;
+	prop_dictionary_t prop = device_properties(self);
 	bus_space_handle_t ioh;
 	char intrstr[128];
+	const char *macaddr;
 	bus_addr_t addr;
 	bus_size_t size;
-	int error;
+	int error, len;
 
 	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
 		aprint_error(": couldn't get registers\n");
@@ -90,6 +94,11 @@ cemac_attach(device_t parent, device_t s
 		return;
 	}
 
+	macaddr = fdtbus_get_prop(phandle, "local-mac-address", &len);
+	if (macaddr != NULL && len == ETHER_ADDR_LEN) {
+		prop_dictionary_set_data(prop, "mac-address", macaddr, len);
+	}
+
 	cemac_attach_common(self, faa->faa_bst, ioh, faa->faa_dmat, CEMAC_FLAG_GEM);
 	aprint_normal_dev(self, "interrupting on %s\n", intrstr);
 }

Reply via email to