diff mbox series

[U-Boot,v2,5/5] net: Move enetaddr env access code to env config instead of net config

Message ID 1522574558-7445-6-git-send-email-alex.kiernan@gmail.com
State Accepted
Commit 9925f1dbc38c0ef7220c6fca5968c708b8e48764
Delegated to: Tom Rini
Headers show
Series Build AM335x when CONFIG_NET isn't defined | expand

Commit Message

Alex Kiernan April 1, 2018, 9:22 a.m. UTC
In order that we can use eth_env_* even when CONFIG_NET isn't set, move
these functions to environment code from net code.

This fixes failures such as:

  board/ti/am335x/built-in.o: In function `board_late_init':
  board/ti/am335x/board.c:752: undefined reference to `eth_env_set_enetaddr'
  u-boot/board/ti/am335x/board.c:766: undefined reference to `eth_env_set_enetaddr'

which caters for use cases such as:

commit f411b5cca48f ("board: am335x: Always set eth/eth1addr environment
variable")

when Ethernet is required in Linux, but not U-Boot.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

Changes in v2:
- Moved enetaddr env access declarations to include/environment.h
- Replace uchar with uint8_t in eth_env_* to avoid dependency on
  include/common.h
- include environment.h where needed to satisfy eth_env_* dependencies

 arch/arm/cpu/arm926ejs/spear/spr_misc.c           |  1 +
 arch/arm/mach-davinci/misc.c                      |  1 +
 arch/arm/mach-omap2/utils.c                       |  1 +
 arch/powerpc/cpu/mpc85xx/fdt.c                    |  1 +
 board/BuR/common/common.c                         |  1 +
 board/CZ.NIC/turris_omnia/turris_omnia.c          |  1 +
 board/LaCie/net2big_v2/net2big_v2.c               |  1 +
 board/LaCie/netspace_v2/netspace_v2.c             |  1 +
 board/amlogic/khadas-vim/khadas-vim.c             |  1 +
 board/amlogic/libretech-cc/libretech-cc.c         |  1 +
 board/amlogic/odroid-c2/odroid-c2.c               |  1 +
 board/amlogic/p212/p212.c                         |  1 +
 board/atmel/common/mac_eeprom.c                   |  1 +
 board/buffalo/lsxl/lsxl.c                         |  1 +
 board/compulab/cl-som-am57x/eth.c                 |  1 +
 board/compulab/cl-som-imx7/cl-som-imx7.c          |  1 +
 board/compulab/cm_fx6/cm_fx6.c                    |  1 +
 board/compulab/cm_t335/cm_t335.c                  |  1 +
 board/compulab/cm_t35/cm_t35.c                    |  1 +
 board/compulab/cm_t3517/cm_t3517.c                |  1 +
 board/compulab/cm_t54/cm_t54.c                    |  1 +
 board/davinci/da8xxevm/da850evm.c                 |  1 +
 board/dhelectronics/dh_imx6/dh_imx6.c             |  1 +
 board/gateworks/gw_ventana/gw_ventana.c           |  1 +
 board/ge/mx53ppd/mx53ppd.c                        |  1 +
 board/kosagi/novena/novena.c                      |  1 +
 board/logicpd/zoom1/zoom1.c                       |  1 +
 board/phytec/pcm051/board.c                       |  1 +
 board/phytec/phycore_rk3288/phycore-rk3288.c      |  1 +
 board/raspberrypi/rpi/rpi.c                       |  1 +
 board/renesas/alt/alt.c                           |  1 +
 board/renesas/blanche/blanche.c                   |  1 +
 board/renesas/gose/gose.c                         |  1 +
 board/renesas/koelsch/koelsch.c                   |  1 +
 board/renesas/lager/lager.c                       |  1 +
 board/renesas/sh7752evb/sh7752evb.c               |  1 +
 board/renesas/sh7753evb/sh7753evb.c               |  1 +
 board/renesas/sh7757lcr/sh7757lcr.c               |  1 +
 board/renesas/silk/silk.c                         |  1 +
 board/renesas/stout/stout.c                       |  1 +
 board/rockchip/tinker_rk3288/tinker-rk3288.c      |  1 +
 board/samtec/vining_2000/vining_2000.c            |  1 +
 board/samtec/vining_fpga/socfpga.c                |  1 +
 board/siemens/common/factoryset.c                 |  1 +
 board/siemens/pxm2/board.c                        |  1 +
 board/silica/pengwyn/board.c                      |  1 +
 board/technologic/ts4800/ts4800.c                 |  1 +
 board/theobroma-systems/puma_rk3399/puma-rk3399.c |  1 +
 board/ti/am43xx/board.c                           |  1 +
 board/ti/ti814x/evm.c                             |  1 +
 board/ti/ti816x/evm.c                             |  1 +
 board/timll/devkit8000/devkit8000.c               |  1 +
 board/toradex/common/tdx-common.c                 |  1 +
 cmd/elf.c                                         |  1 +
 cmd/ethsw.c                                       |  1 +
 cmd/nvedit.c                                      | 30 ++++++++++++++++++++++
 drivers/net/cpsw-common.c                         |  1 +
 drivers/net/fec_mxc.c                             |  1 +
 drivers/net/fsl_mcdmafec.c                        |  1 +
 drivers/net/mcffec.c                              |  1 +
 drivers/net/ne2000_base.c                         |  1 +
 drivers/net/sh_eth.c                              |  1 +
 drivers/usb/gadget/ether.c                        |  1 +
 include/environment.h                             |  4 +++
 include/net.h                                     |  3 ---
 net/eth_common.c                                  | 31 +----------------------
 66 files changed, 97 insertions(+), 33 deletions(-)

Comments

Tom Rini April 9, 2018, 3:04 p.m. UTC | #1
On Sun, Apr 01, 2018 at 09:22:38AM +0000, Alex Kiernan wrote:

> In order that we can use eth_env_* even when CONFIG_NET isn't set, move
> these functions to environment code from net code.
> 
> This fixes failures such as:
> 
>   board/ti/am335x/built-in.o: In function `board_late_init':
>   board/ti/am335x/board.c:752: undefined reference to `eth_env_set_enetaddr'
>   u-boot/board/ti/am335x/board.c:766: undefined reference to `eth_env_set_enetaddr'
> 
> which caters for use cases such as:
> 
> commit f411b5cca48f ("board: am335x: Always set eth/eth1addr environment
> variable")
> 
> when Ethernet is required in Linux, but not U-Boot.
> 
> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/arm/cpu/arm926ejs/spear/spr_misc.c b/arch/arm/cpu/arm926ejs/spear/spr_misc.c
index a02304f..f072f2e 100644
--- a/arch/arm/cpu/arm926ejs/spear/spr_misc.c
+++ b/arch/arm/cpu/arm926ejs/spear/spr_misc.c
@@ -7,6 +7,7 @@ 
 
 #include <common.h>
 #include <command.h>
+#include <environment.h>
 #include <i2c.h>
 #include <net.h>
 #include <linux/mtd/st_smi.h>
diff --git a/arch/arm/mach-davinci/misc.c b/arch/arm/mach-davinci/misc.c
index 461ff77..7b9d961 100644
--- a/arch/arm/mach-davinci/misc.c
+++ b/arch/arm/mach-davinci/misc.c
@@ -10,6 +10,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <i2c.h>
 #include <net.h>
 #include <asm/arch/hardware.h>
diff --git a/arch/arm/mach-omap2/utils.c b/arch/arm/mach-omap2/utils.c
index 7d1ca27..1d39625 100644
--- a/arch/arm/mach-omap2/utils.c
+++ b/arch/arm/mach-omap2/utils.c
@@ -5,6 +5,7 @@ 
  * SPDX-License-Identifier:	GPL-2.0+
  */
 #include <common.h>
+#include <environment.h>
 #include <asm/setup.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/omap_common.h>
diff --git a/arch/powerpc/cpu/mpc85xx/fdt.c b/arch/powerpc/cpu/mpc85xx/fdt.c
index e1fee11..3bdaa5f 100644
--- a/arch/powerpc/cpu/mpc85xx/fdt.c
+++ b/arch/powerpc/cpu/mpc85xx/fdt.c
@@ -8,6 +8,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <linux/libfdt.h>
 #include <fdt_support.h>
 #include <asm/processor.h>
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index d82b8cd..f0a97fa 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -11,6 +11,7 @@ 
  */
 #include <version.h>
 #include <common.h>
+#include <environment.h>
 #include <errno.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
index b03c0a3..c693aae 100644
--- a/board/CZ.NIC/turris_omnia/turris_omnia.c
+++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <i2c.h>
 #include <miiphy.h>
 #include <netdev.h>
diff --git a/board/LaCie/net2big_v2/net2big_v2.c b/board/LaCie/net2big_v2/net2big_v2.c
index f639a37..3e070d2 100644
--- a/board/LaCie/net2big_v2/net2big_v2.c
+++ b/board/LaCie/net2big_v2/net2big_v2.c
@@ -11,6 +11,7 @@ 
 
 #include <common.h>
 #include <command.h>
+#include <environment.h>
 #include <i2c.h>
 #include <asm/mach-types.h>
 #include <asm/arch/cpu.h>
diff --git a/board/LaCie/netspace_v2/netspace_v2.c b/board/LaCie/netspace_v2/netspace_v2.c
index 52f3664..3bd9fa9 100644
--- a/board/LaCie/netspace_v2/netspace_v2.c
+++ b/board/LaCie/netspace_v2/netspace_v2.c
@@ -11,6 +11,7 @@ 
 
 #include <common.h>
 #include <command.h>
+#include <environment.h>
 #include <asm/mach-types.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
diff --git a/board/amlogic/khadas-vim/khadas-vim.c b/board/amlogic/khadas-vim/khadas-vim.c
index 5e19856..83b1b6e 100644
--- a/board/amlogic/khadas-vim/khadas-vim.c
+++ b/board/amlogic/khadas-vim/khadas-vim.c
@@ -7,6 +7,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/gxbb.h>
 #include <asm/arch/mem.h>
diff --git a/board/amlogic/libretech-cc/libretech-cc.c b/board/amlogic/libretech-cc/libretech-cc.c
index 6be6e2a..5795340 100644
--- a/board/amlogic/libretech-cc/libretech-cc.c
+++ b/board/amlogic/libretech-cc/libretech-cc.c
@@ -7,6 +7,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/gxbb.h>
 #include <asm/arch/sm.h>
diff --git a/board/amlogic/odroid-c2/odroid-c2.c b/board/amlogic/odroid-c2/odroid-c2.c
index 0cb5714..8645f22 100644
--- a/board/amlogic/odroid-c2/odroid-c2.c
+++ b/board/amlogic/odroid-c2/odroid-c2.c
@@ -6,6 +6,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/gxbb.h>
 #include <asm/arch/sm.h>
diff --git a/board/amlogic/p212/p212.c b/board/amlogic/p212/p212.c
index 5fde534..7c0abbc 100644
--- a/board/amlogic/p212/p212.c
+++ b/board/amlogic/p212/p212.c
@@ -7,6 +7,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/gxbb.h>
 #include <asm/arch/sm.h>
diff --git a/board/atmel/common/mac_eeprom.c b/board/atmel/common/mac_eeprom.c
index 60ddf00..91b86e0 100644
--- a/board/atmel/common/mac_eeprom.c
+++ b/board/atmel/common/mac_eeprom.c
@@ -7,6 +7,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <i2c_eeprom.h>
 #include <netdev.h>
 
diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c
index 2d01ac2..8ae4207 100644
--- a/board/buffalo/lsxl/lsxl.c
+++ b/board/buffalo/lsxl/lsxl.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <net.h>
 #include <malloc.h>
 #include <netdev.h>
diff --git a/board/compulab/cl-som-am57x/eth.c b/board/compulab/cl-som-am57x/eth.c
index b615fb9..9f9525e 100644
--- a/board/compulab/cl-som-am57x/eth.c
+++ b/board/compulab/cl-som-am57x/eth.c
@@ -10,6 +10,7 @@ 
 
 #include <common.h>
 #include <cpsw.h>
+#include <environment.h>
 #include <miiphy.h>
 #include <asm/gpio.h>
 #include <asm/arch/sys_proto.h>
diff --git a/board/compulab/cl-som-imx7/cl-som-imx7.c b/board/compulab/cl-som-imx7/cl-som-imx7.c
index f8b1cda..dfa81f5 100644
--- a/board/compulab/cl-som-imx7/cl-som-imx7.c
+++ b/board/compulab/cl-som-imx7/cl-som-imx7.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <mmc.h>
 #include <phy.h>
 #include <netdev.h>
diff --git a/board/compulab/cm_fx6/cm_fx6.c b/board/compulab/cm_fx6/cm_fx6.c
index 673de03..c72efc5 100644
--- a/board/compulab/cm_fx6/cm_fx6.c
+++ b/board/compulab/cm_fx6/cm_fx6.c
@@ -12,6 +12,7 @@ 
 #include <ahci.h>
 #include <dm.h>
 #include <dwc_ahsata.h>
+#include <environment.h>
 #include <fsl_esdhc.h>
 #include <miiphy.h>
 #include <mtd_node.h>
diff --git a/board/compulab/cm_t335/cm_t335.c b/board/compulab/cm_t335/cm_t335.c
index 6f6ba49..6eabd38 100644
--- a/board/compulab/cm_t335/cm_t335.c
+++ b/board/compulab/cm_t335/cm_t335.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <errno.h>
 #include <miiphy.h>
 #include <cpsw.h>
diff --git a/board/compulab/cm_t35/cm_t35.c b/board/compulab/cm_t35/cm_t35.c
index d5cfba4..e8f604f 100644
--- a/board/compulab/cm_t35/cm_t35.c
+++ b/board/compulab/cm_t35/cm_t35.c
@@ -13,6 +13,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <status_led.h>
 #include <netdev.h>
 #include <net.h>
diff --git a/board/compulab/cm_t3517/cm_t3517.c b/board/compulab/cm_t3517/cm_t3517.c
index 0ff49dc..e4e3460 100644
--- a/board/compulab/cm_t3517/cm_t3517.c
+++ b/board/compulab/cm_t3517/cm_t3517.c
@@ -7,6 +7,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <status_led.h>
 #include <net.h>
 #include <netdev.h>
diff --git a/board/compulab/cm_t54/cm_t54.c b/board/compulab/cm_t54/cm_t54.c
index 3e6235a..a1aeafb 100644
--- a/board/compulab/cm_t54/cm_t54.c
+++ b/board/compulab/cm_t54/cm_t54.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <fdt_support.h>
 #include <usb.h>
 #include <mmc.h>
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c
index 83c9f29..37a0d72 100644
--- a/board/davinci/da8xxevm/da850evm.c
+++ b/board/davinci/da8xxevm/da850evm.c
@@ -10,6 +10,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <i2c.h>
 #include <net.h>
 #include <netdev.h>
diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c
index b00d0e4..1d8b831 100644
--- a/board/dhelectronics/dh_imx6/dh_imx6.c
+++ b/board/dhelectronics/dh_imx6/dh_imx6.c
@@ -19,6 +19,7 @@ 
 #include <asm/mach-imx/iomux-v3.h>
 #include <asm/mach-imx/mxc_i2c.h>
 #include <asm/mach-imx/sata.h>
+#include <environment.h>
 #include <errno.h>
 #include <fsl_esdhc.h>
 #include <fuse.h>
diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c
index 4ddc7e1..332c506 100644
--- a/board/gateworks/gw_ventana/gw_ventana.c
+++ b/board/gateworks/gw_ventana/gw_ventana.c
@@ -22,6 +22,7 @@ 
 #include <asm/setup.h>
 #include <dm.h>
 #include <dm/platform_data/serial_mxc.h>
+#include <environment.h>
 #include <hwconfig.h>
 #include <i2c.h>
 #include <fdt_support.h>
diff --git a/board/ge/mx53ppd/mx53ppd.c b/board/ge/mx53ppd/mx53ppd.c
index 90dbccc..0010998 100644
--- a/board/ge/mx53ppd/mx53ppd.c
+++ b/board/ge/mx53ppd/mx53ppd.c
@@ -20,6 +20,7 @@ 
 #include <linux/errno.h>
 #include <asm/mach-imx/mxc_i2c.h>
 #include <asm/mach-imx/mx5_video.h>
+#include <environment.h>
 #include <netdev.h>
 #include <i2c.h>
 #include <mmc.h>
diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c
index f0ace03..91bc9c2 100644
--- a/board/kosagi/novena/novena.c
+++ b/board/kosagi/novena/novena.c
@@ -21,6 +21,7 @@ 
 #include <asm/mach-imx/mxc_i2c.h>
 #include <asm/mach-imx/sata.h>
 #include <asm/mach-imx/video.h>
+#include <environment.h>
 #include <fsl_esdhc.h>
 #include <i2c.h>
 #include <input.h>
diff --git a/board/logicpd/zoom1/zoom1.c b/board/logicpd/zoom1/zoom1.c
index e6c2526..fe1183b 100644
--- a/board/logicpd/zoom1/zoom1.c
+++ b/board/logicpd/zoom1/zoom1.c
@@ -16,6 +16,7 @@ 
  */
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <netdev.h>
 #include <twl4030.h>
diff --git a/board/phytec/pcm051/board.c b/board/phytec/pcm051/board.c
index 52ad5b6..c57625b 100644
--- a/board/phytec/pcm051/board.c
+++ b/board/phytec/pcm051/board.c
@@ -10,6 +10,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <errno.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
diff --git a/board/phytec/phycore_rk3288/phycore-rk3288.c b/board/phytec/phycore_rk3288/phycore-rk3288.c
index 47b069e..a1b407d 100644
--- a/board/phytec/phycore_rk3288/phycore-rk3288.c
+++ b/board/phytec/phycore_rk3288/phycore-rk3288.c
@@ -8,6 +8,7 @@ 
 #include <asm/io.h>
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <i2c.h>
 #include <i2c_eeprom.h>
 #include <netdev.h>
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 177f4af..532fbc4 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -8,6 +8,7 @@ 
 #include <inttypes.h>
 #include <config.h>
 #include <dm.h>
+#include <environment.h>
 #include <efi_loader.h>
 #include <fdt_support.h>
 #include <fdt_simplefb.h>
diff --git a/board/renesas/alt/alt.c b/board/renesas/alt/alt.c
index 0bf8160..f2200ef 100644
--- a/board/renesas/alt/alt.c
+++ b/board/renesas/alt/alt.c
@@ -10,6 +10,7 @@ 
 #include <malloc.h>
 #include <dm.h>
 #include <dm/platform_data/serial_sh.h>
+#include <environment.h>
 #include <asm/processor.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
diff --git a/board/renesas/blanche/blanche.c b/board/renesas/blanche/blanche.c
index 574dcda..5dc3073 100644
--- a/board/renesas/blanche/blanche.c
+++ b/board/renesas/blanche/blanche.c
@@ -12,6 +12,7 @@ 
 #include <netdev.h>
 #include <dm.h>
 #include <dm/platform_data/serial_sh.h>
+#include <environment.h>
 #include <asm/processor.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
diff --git a/board/renesas/gose/gose.c b/board/renesas/gose/gose.c
index 54e1269..99d4ba6 100644
--- a/board/renesas/gose/gose.c
+++ b/board/renesas/gose/gose.c
@@ -10,6 +10,7 @@ 
 #include <malloc.h>
 #include <dm.h>
 #include <dm/platform_data/serial_sh.h>
+#include <environment.h>
 #include <asm/processor.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
diff --git a/board/renesas/koelsch/koelsch.c b/board/renesas/koelsch/koelsch.c
index 8fa648e..e7b47ae 100644
--- a/board/renesas/koelsch/koelsch.c
+++ b/board/renesas/koelsch/koelsch.c
@@ -11,6 +11,7 @@ 
 #include <malloc.h>
 #include <dm.h>
 #include <dm/platform_data/serial_sh.h>
+#include <environment.h>
 #include <asm/processor.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
diff --git a/board/renesas/lager/lager.c b/board/renesas/lager/lager.c
index 562be04..3566bcc 100644
--- a/board/renesas/lager/lager.c
+++ b/board/renesas/lager/lager.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <netdev.h>
 #include <dm.h>
diff --git a/board/renesas/sh7752evb/sh7752evb.c b/board/renesas/sh7752evb/sh7752evb.c
index 4a76fb7..5da6f39 100644
--- a/board/renesas/sh7752evb/sh7752evb.c
+++ b/board/renesas/sh7752evb/sh7752evb.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <asm/processor.h>
 #include <asm/io.h>
diff --git a/board/renesas/sh7753evb/sh7753evb.c b/board/renesas/sh7753evb/sh7753evb.c
index ca9e144..8604d88 100644
--- a/board/renesas/sh7753evb/sh7753evb.c
+++ b/board/renesas/sh7753evb/sh7753evb.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <asm/processor.h>
 #include <asm/io.h>
diff --git a/board/renesas/sh7757lcr/sh7757lcr.c b/board/renesas/sh7757lcr/sh7757lcr.c
index 3f970fc..1c598fb 100644
--- a/board/renesas/sh7757lcr/sh7757lcr.c
+++ b/board/renesas/sh7757lcr/sh7757lcr.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <asm/processor.h>
 #include <asm/io.h>
diff --git a/board/renesas/silk/silk.c b/board/renesas/silk/silk.c
index a8de402..9e2080b 100644
--- a/board/renesas/silk/silk.c
+++ b/board/renesas/silk/silk.c
@@ -11,6 +11,7 @@ 
 #include <malloc.h>
 #include <dm.h>
 #include <dm/platform_data/serial_sh.h>
+#include <environment.h>
 #include <asm/processor.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
diff --git a/board/renesas/stout/stout.c b/board/renesas/stout/stout.c
index d681148..3cb16db 100644
--- a/board/renesas/stout/stout.c
+++ b/board/renesas/stout/stout.c
@@ -14,6 +14,7 @@ 
 #include <netdev.h>
 #include <dm.h>
 #include <dm/platform_data/serial_sh.h>
+#include <environment.h>
 #include <asm/processor.h>
 #include <asm/mach-types.h>
 #include <asm/io.h>
diff --git a/board/rockchip/tinker_rk3288/tinker-rk3288.c b/board/rockchip/tinker_rk3288/tinker-rk3288.c
index 790a921..0f2abe2 100644
--- a/board/rockchip/tinker_rk3288/tinker-rk3288.c
+++ b/board/rockchip/tinker_rk3288/tinker-rk3288.c
@@ -6,6 +6,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <i2c_eeprom.h>
 #include <netdev.h>
 
diff --git a/board/samtec/vining_2000/vining_2000.c b/board/samtec/vining_2000/vining_2000.c
index cced08b..0cc8421 100644
--- a/board/samtec/vining_2000/vining_2000.c
+++ b/board/samtec/vining_2000/vining_2000.c
@@ -18,6 +18,7 @@ 
 #include <asm/mach-imx/mxc_i2c.h>
 #include <linux/sizes.h>
 #include <common.h>
+#include <environment.h>
 #include <fsl_esdhc.h>
 #include <mmc.h>
 #include <i2c.h>
diff --git a/board/samtec/vining_fpga/socfpga.c b/board/samtec/vining_fpga/socfpga.c
index 229b12f..14ac7ef 100644
--- a/board/samtec/vining_fpga/socfpga.c
+++ b/board/samtec/vining_fpga/socfpga.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
diff --git a/board/siemens/common/factoryset.c b/board/siemens/common/factoryset.c
index 7fa2673..f3e82d4 100644
--- a/board/siemens/common/factoryset.c
+++ b/board/siemens/common/factoryset.c
@@ -9,6 +9,7 @@ 
 #if !defined(CONFIG_SPL_BUILD)
 
 #include <common.h>
+#include <environment.h>
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
diff --git a/board/siemens/pxm2/board.c b/board/siemens/pxm2/board.c
index 8bbb035..ab54e58 100644
--- a/board/siemens/pxm2/board.c
+++ b/board/siemens/pxm2/board.c
@@ -14,6 +14,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <errno.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
diff --git a/board/silica/pengwyn/board.c b/board/silica/pengwyn/board.c
index 0429e6f..e736afb 100644
--- a/board/silica/pengwyn/board.c
+++ b/board/silica/pengwyn/board.c
@@ -7,6 +7,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/ddr_defs.h>
diff --git a/board/technologic/ts4800/ts4800.c b/board/technologic/ts4800/ts4800.c
index e5bec57..c4dad69 100644
--- a/board/technologic/ts4800/ts4800.c
+++ b/board/technologic/ts4800/ts4800.c
@@ -17,6 +17,7 @@ 
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/clock.h>
 #include <asm/mach-imx/mx5_video.h>
+#include <environment.h>
 #include <mmc.h>
 #include <input.h>
 #include <fsl_esdhc.h>
diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index c6690fa..1d8b605 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -6,6 +6,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <misc.h>
 #include <spl.h>
 #include <syscon.h>
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 715960a..07c0ab0 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <i2c.h>
 #include <linux/errno.h>
 #include <spl.h>
diff --git a/board/ti/ti814x/evm.c b/board/ti/ti814x/evm.c
index cdde6a8..4a0f829 100644
--- a/board/ti/ti814x/evm.c
+++ b/board/ti/ti814x/evm.c
@@ -10,6 +10,7 @@ 
 
 #include <common.h>
 #include <cpsw.h>
+#include <environment.h>
 #include <errno.h>
 #include <spl.h>
 #include <asm/arch/cpu.h>
diff --git a/board/ti/ti816x/evm.c b/board/ti/ti816x/evm.c
index cb40cc5..abc961a 100644
--- a/board/ti/ti816x/evm.c
+++ b/board/ti/ti816x/evm.c
@@ -8,6 +8,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <spl.h>
 #include <netdev.h>
 #include <asm/cache.h>
diff --git a/board/timll/devkit8000/devkit8000.c b/board/timll/devkit8000/devkit8000.c
index 741b3ac..4bbbd81 100644
--- a/board/timll/devkit8000/devkit8000.c
+++ b/board/timll/devkit8000/devkit8000.c
@@ -18,6 +18,7 @@ 
  */
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <twl4030.h>
 #include <asm/io.h>
diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index 6e12d27..d6d3671 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <g_dnl.h>
 #include <linux/libfdt.h>
 
diff --git a/cmd/elf.c b/cmd/elf.c
index 5b59fc6..110e8e0 100644
--- a/cmd/elf.c
+++ b/cmd/elf.c
@@ -16,6 +16,7 @@ 
 #include <common.h>
 #include <command.h>
 #include <elf.h>
+#include <environment.h>
 #include <net.h>
 #include <vxworks.h>
 #ifdef CONFIG_X86
diff --git a/cmd/ethsw.c b/cmd/ethsw.c
index b600965..92a60b4 100644
--- a/cmd/ethsw.c
+++ b/cmd/ethsw.c
@@ -8,6 +8,7 @@ 
 
 #include <common.h>
 #include <command.h>
+#include <environment.h>
 #include <errno.h>
 #include <env_flags.h>
 #include <ethsw.h>
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 4cb25b8..9838678 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -341,6 +341,36 @@  ulong env_get_hex(const char *varname, ulong default_val)
 	return value;
 }
 
+void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr)
+{
+	char *end;
+	int i;
+
+	for (i = 0; i < 6; ++i) {
+		enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
+		if (addr)
+			addr = (*end) ? end + 1 : end;
+	}
+}
+
+int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr)
+{
+	eth_parse_enetaddr(env_get(name), enetaddr);
+	return is_valid_ethaddr(enetaddr);
+}
+
+int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr)
+{
+	char buf[ARP_HLEN_ASCII + 1];
+
+	if (eth_env_get_enetaddr(name, (uint8_t *)buf))
+		return -EEXIST;
+
+	sprintf(buf, "%pM", enetaddr);
+
+	return env_set(name, buf);
+}
+
 #ifndef CONFIG_SPL_BUILD
 static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/drivers/net/cpsw-common.c b/drivers/net/cpsw-common.c
index 0dc83ab..7bd312a 100644
--- a/drivers/net/cpsw-common.c
+++ b/drivers/net/cpsw-common.c
@@ -8,6 +8,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <fdt_support.h>
 #include <asm/io.h>
 #include <cpsw.h>
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index ff7ad91..29af85c 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -10,6 +10,7 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <malloc.h>
 #include <memalign.h>
 #include <miiphy.h>
diff --git a/drivers/net/fsl_mcdmafec.c b/drivers/net/fsl_mcdmafec.c
index 2d89cea..00d905c 100644
--- a/drivers/net/fsl_mcdmafec.c
+++ b/drivers/net/fsl_mcdmafec.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <command.h>
 #include <config.h>
diff --git a/drivers/net/mcffec.c b/drivers/net/mcffec.c
index ebcbed9..505a2d1 100644
--- a/drivers/net/mcffec.c
+++ b/drivers/net/mcffec.c
@@ -9,6 +9,7 @@ 
  */
 
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 
 #include <command.h>
diff --git a/drivers/net/ne2000_base.c b/drivers/net/ne2000_base.c
index fb088e0..421aa20 100644
--- a/drivers/net/ne2000_base.c
+++ b/drivers/net/ne2000_base.c
@@ -74,6 +74,7 @@  Add SNMP
 
 #include <common.h>
 #include <command.h>
+#include <environment.h>
 #include <net.h>
 #include <malloc.h>
 #include <linux/compiler.h>
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c
index 6f48e93..e3416f3 100644
--- a/drivers/net/sh_eth.c
+++ b/drivers/net/sh_eth.c
@@ -11,6 +11,7 @@ 
 
 #include <config.h>
 #include <common.h>
+#include <environment.h>
 #include <malloc.h>
 #include <net.h>
 #include <netdev.h>
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index a80486e..386505d 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -10,6 +10,7 @@ 
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <linux/errno.h>
 #include <linux/netdevice.h>
 #include <linux/usb/ch9.h>
diff --git a/include/environment.h b/include/environment.h
index 7986a24..1b52353 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -314,6 +314,10 @@  int env_load(void);
  */
 int env_save(void);
 
+void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr);
+int eth_env_get_enetaddr(const char *name, uint8_t *enetaddr);
+int eth_env_set_enetaddr(const char *name, const uint8_t *enetaddr);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
diff --git a/include/net.h b/include/net.h
index 455b48f..c339b9d 100644
--- a/include/net.h
+++ b/include/net.h
@@ -238,9 +238,6 @@  void eth_try_another(int first_restart);	/* Change the device */
 void eth_set_current(void);		/* set nterface to ethcur var */
 
 int eth_get_dev_index(void);		/* get the device index */
-void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
-int eth_env_get_enetaddr(const char *name, uchar *enetaddr);
-int eth_env_set_enetaddr(const char *name, const uchar *enetaddr);
 
 /**
  * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
diff --git a/net/eth_common.c b/net/eth_common.c
index 66d0d22..0af91a9 100644
--- a/net/eth_common.c
+++ b/net/eth_common.c
@@ -8,40 +8,11 @@ 
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <miiphy.h>
 #include <net.h>
 #include "eth_internal.h"
 
-void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
-{
-	char *end;
-	int i;
-
-	for (i = 0; i < 6; ++i) {
-		enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
-		if (addr)
-			addr = (*end) ? end + 1 : end;
-	}
-}
-
-int eth_env_get_enetaddr(const char *name, uchar *enetaddr)
-{
-	eth_parse_enetaddr(env_get(name), enetaddr);
-	return is_valid_ethaddr(enetaddr);
-}
-
-int eth_env_set_enetaddr(const char *name, const uchar *enetaddr)
-{
-	char buf[ARP_HLEN_ASCII + 1];
-
-	if (eth_env_get_enetaddr(name, (uchar *)buf))
-		return -EEXIST;
-
-	sprintf(buf, "%pM", enetaddr);
-
-	return env_set(name, buf);
-}
-
 int eth_env_get_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr)
 {