Skip to contentSkip to conversation

env: Move environment code to use location drivers

PATCH Superseded Simon Glass 1 participant 30 messages Jul 31, 2017 Page 1 of 2

Subsystems (45)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover env: Move environment code to use location drivers

The environment code is ripe for improvement in various ways. It has lots of duplication and inconsistencies between how things work with different environment locations. It does not properly use Kconfig. Error checking and handling is patchy.

This series makes a start at improving things:

- moves the rest of the CONFIG_ENV_IS_IN_... options to Kconfig
- introduces the concept of a location driver for the environment
- drops some of the duplicated code
- improves error handling a little (more to be done here)
- moves code into a new env/ directory

There is still much more to do:
- complete Kconfig conversion (e.g. CONFIG_ENV_SIZE)
- unify environment settings so that all locations support the same options
- try to rationalise the redundancy code (can we create a common implementation used by all drivers?)
- allow environment in multiple locations (e.g. as a fallback)
- figure out why CONFIG_ENV_IS_IN_FLASH enables the environment in flash even in SPL, which other locations do not
- move environment functions from common.h to environment.h

Changes in v4:
- Update the commit message to comment on special cases
- Adjust implementation of env_get_char_spec() to avoid recursion
- Fix incorrect setting of env_valid in env_init_new()
- Add changes for edison also
- Reduce patch to only change setenv(), not any related function
- Split out changes to setenv_ulong(), etc. into a new patch
- Add new patch to rename eth_setenv_enetaddr()
- Reduce patch to only change getenv() and getenv_f()
- Update comment message to mention use of getenv() in condition context
- Add new patch to rename eth_getenv_enetaddr()
- Add new patch to rename some other genenv()-related functions

Changes in v3:
- Rebase to master
- Rebase to master, dropping patches already applied

Changes in v2:
- Add conditions for the am335x_hs_evm board with SPL
- Add new patch to rename setenv() and friends to env_set()
- Add new patch to rename setenv() and friends to env_set()
- Add new patch to rename getenv() and friends to env_get()
- Add new patch to rename getenv_hex(), getenv_yesno(), getenv_ulong()
- Add new patch to rename getenv() and friends to env_get()
- Rebase to master

Simon Glass (29):
Makefile: Rename 'env' target to 'environ'
Move environment files from common/ to env/
env: Move help from README to Kconfig
env: common: Make env_get_addr/get_char_memory() static
env: common: Drop env_get_addr()
env: common: Factor out the common env_valid check
env: common: Drop env_get_char_init()
env: common: Drop env_get_char_memory()
env: Add an enum for environment state
env: Rename nand env_location to nand_env_location
env: Create a location driver for each location
env: Add a new implementation of environment access
env: Switch over to use environment location drivers
env: Drop common init() functions
env: Drop the env_name_spec global
env: Drop unused env_ptr variables
env: Drop env_init_new()
env: Drop env_get_char_spec()
env: Drop env_relocate_spec() in favour of env_load()
env: Drop saveenv() in favour of env_save()
env: Rename setenv() to env_set()
env: Rename common functions related to setenv()
env: Rename eth_setenv_enetaddr() to eth_env_set_enetaddr()
env: Rename getenv/_f() to env_get()
env: Rename getenv_hex(), getenv_yesno(), getenv_ulong()
env: Rename eth_getenv_enetaddr() to eth_env_get_enetaddr()
env: Rename some other getenv()-related functions
env: Adjust the get_char() method to return an int
env: Adjust the load() method to return an error

 Kconfig                                            |   2 +
 Makefile                                           |   5 +-
 README                                             |   2 +-
 api/api.c                                          |   6 +-
 arch/arc/lib/bootm.c                               |   2 +-
 arch/arm/cpu/armv7/vf610/generic.c                 |   2 +-
 arch/arm/cpu/armv8/fsl-layerscape/soc.c            |   2 +-
 arch/arm/lib/bootm.c                               |   6 +-
 arch/arm/lib/semihosting.c                         |   2 +-
 arch/arm/mach-davinci/misc.c                       |   4 +-
 arch/arm/mach-imx/mx6/opos6ul.c                    |   2 +-
 arch/arm/mach-imx/mx7/soc.c                        |   4 +-
 arch/arm/mach-imx/video.c                          |   2 +-
 arch/arm/mach-keystone/ddr3.c                      |   2 +-
 arch/arm/mach-keystone/keystone.c                  |   2 +-
 arch/arm/mach-kirkwood/cpu.c                       |   4 +-
 arch/arm/mach-omap2/boot-common.c                  |   5 +-
 arch/arm/mach-omap2/utils.c                        |  20 +-
 arch/arm/mach-rockchip/rk3036-board.c              |   4 +-
 arch/arm/mach-rockchip/rk322x-board.c              |   4 +-
 arch/arm/mach-rockchip/rk3288-board.c              |   4 +-
 arch/arm/mach-socfpga/misc_gen5.c                  |   4 +-
 arch/arm/mach-tegra/board2.c                       |   4 +-
 arch/arm/mach-tegra/tegra186/nvtboot_board.c       |   6 +-
 arch/arm/mach-uniphier/board_late_init.c           |  12 +-
 arch/arm/mach-uniphier/mmc-first-dev.c             |   2 +-
 arch/m68k/lib/bootm.c                              |   3 +-
 arch/microblaze/lib/bootm.c                        |   2 +-
 arch/mips/lib/bootm.c                              |   6 +-
 arch/nds32/lib/bootm.c                             |   4 +-
 arch/nios2/lib/bootm.c                             |   2 +-
 arch/powerpc/cpu/mpc85xx/cpu_init.c                |  10 +-
 arch/powerpc/cpu/mpc85xx/fdt.c                     |   4 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c      |   2 +-
 arch/powerpc/cpu/mpc85xx/mp.c                      |   2 +-
 arch/powerpc/lib/bootm.c                           |  11 +-
 arch/sh/cpu/u-boot.lds                             |   4 +-
 arch/sh/lib/bootm.c                                |   2 +-
 arch/sh/lib/zimageboot.c                           |   2 +-
 arch/x86/lib/zimage.c                              |   8 +-
 arch/xtensa/lib/bootm.c                            |   2 +-
 board/Arcturus/ucp1020/cmd_arc.c                   |  20 +-
 board/Arcturus/ucp1020/spl.c                       |   3 +-
 board/Arcturus/ucp1020/ucp1020.c                   |  20 +-
 board/Barix/ipam390/ipam390.c                      |   2 +-
 board/BuR/brppt1/board.c                           |   2 +-
 board/BuR/brxre1/board.c                           |  22 +-
 board/BuR/common/common.c                          |  56 +--
 board/BuS/eb_cpu5282/eb_cpu5282.c                  |   8 +-
 board/CZ.NIC/turris_omnia/turris_omnia.c           |   8 +-
 board/CarMediaLab/flea3/flea3.c                    |   2 +-
 board/LaCie/net2big_v2/net2big_v2.c                |   4 +-
 board/LaCie/netspace_v2/netspace_v2.c              |   4 +-
 board/Synology/ds414/cmd_syno.c                    |   6 +-
 board/amazon/kc1/kc1.c                             |   4 +-
 board/amlogic/odroid-c2/odroid-c2.c                |   8 +-
 board/aries/ma5d4evk/ma5d4evk.c                    |   2 +-
 board/aristainetos/aristainetos-v2.c               |   8 +-
 board/armltd/integrator/integrator.c               |   2 +-
 board/atmel/sama5d2_xplained/sama5d2_xplained.c    |   4 +-
 board/atmel/sama5d3xek/sama5d3xek.c                |   2 +-
 board/bachmann/ot1200/ot1200.c                     |   4 +-
 board/birdland/bav335x/board.c                     |  12 +-
 board/bluegiga/apx4devkit/apx4devkit.c             |   4 +-
 board/bluewater/gurnard/gurnard.c                  |   6 +-
 board/bosch/shc/board.c                            |  10 +-
 board/boundary/nitrogen6x/nitrogen6x.c             |  14 +-
 board/broadcom/bcm23550_w1d/bcm23550_w1d.c         |   2 +-
 board/broadcom/bcm28155_ap/bcm28155_ap.c           |   2 +-
 board/buffalo/lsxl/lsxl.c                          |   4 +-
 board/cadence/xtfpga/xtfpga.c                      |   4 +-
 board/ccv/xpress/xpress.c                          |   2 +-
 board/compulab/cl-som-am57x/eth.c                  |   6 +-
 board/compulab/cm_fx6/cm_fx6.c                     |  12 +-
 board/compulab/cm_t335/cm_t335.c                   |   4 +-
 board/compulab/cm_t35/cm_t35.c                     |   4 +-
 board/compulab/cm_t3517/cm_t3517.c                 |   4 +-
 board/compulab/cm_t54/cm_t54.c                     |   6 +-
 board/compulab/common/omap3_display.c              |   4 +-
 board/congatec/cgtqmx6eval/cgtqmx6eval.c           |   8 +-
 board/cssi/MCR3000/MCR3000.c                       |   2 +-
 board/davinci/da8xxevm/da850evm.c                  |   6 +-
 board/davinci/da8xxevm/omapl138_lcdk.c             |   6 +-
 board/el/el6x/el6x.c                               |   2 +-
 board/engicam/common/board.c                       |  14 +-
 board/engicam/geam6ul/geam6ul.c                    |   2 +-
 board/engicam/icorem6/icorem6.c                    |   4 +-
 board/engicam/icorem6_rqs/icorem6_rqs.c            |   4 +-
 board/engicam/isiotmx6ul/isiotmx6ul.c              |   4 +-
 board/esd/meesc/meesc.c                            |   7 +-
 board/freescale/b4860qds/b4860qds.c                |   8 +-
 board/freescale/b4860qds/spl.c                     |   3 +-
 board/freescale/bsc9131rdb/bsc9131rdb.c            |   4 +-
 board/freescale/bsc9132qds/bsc9132qds.c            |   4 +-
 board/freescale/c29xpcie/c29xpcie.c                |   4 +-
 board/freescale/c29xpcie/spl.c                     |   3 +-
 board/freescale/common/cmd_esbc_validate.c         |   2 +-
 board/freescale/common/fsl_chain_of_trust.c        |   4 +-
 board/freescale/common/sys_eeprom.c                |   4 +-
 board/freescale/common/vid.c                       |   4 +-
 board/freescale/corenet_ds/corenet_ds.c            |   4 +-
 board/freescale/ls2080aqds/eth.c                   |   6 +-
 board/freescale/ls2080aqds/ls2080aqds.c            |   2 +-
 board/freescale/ls2080ardb/ls2080ardb.c            |   2 +-
 board/freescale/mpc8323erdb/mpc8323erdb.c          |   2 +-
 board/freescale/mpc837xemds/pci.c                  |   2 +-
 board/freescale/mpc837xerdb/mpc837xerdb.c          |   2 +-
 board/freescale/mpc8572ds/mpc8572ds.c              |   4 +-
 board/freescale/mx31ads/u-boot.lds                 |   2 +-
 board/freescale/mx51evk/mx51evk_video.c            |   2 +-
 board/freescale/mx53loco/mx53loco.c                |   4 +-
 board/freescale/mx53loco/mx53loco_video.c          |   2 +-
 board/freescale/mx6sabreauto/mx6sabreauto.c        |   8 +-
 board/freescale/mx6sabresd/mx6sabresd.c            |   8 +-
 board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c  |   6 +-
 board/freescale/mx6ullevk/mx6ullevk.c              |   4 +-
 board/freescale/p1010rdb/p1010rdb.c                |   4 +-
 board/freescale/p1010rdb/spl.c                     |   3 +-
 board/freescale/p1022ds/p1022ds.c                  |   4 +-
 board/freescale/p1022ds/spl.c                      |   3 +-
 board/freescale/p1023rdb/p1023rdb.c                |   4 +-
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c        |   7 +-
 board/freescale/p1_p2_rdb_pc/spl.c                 |   3 +-
 board/freescale/p1_twr/p1_twr.c                    |   4 +-
 board/freescale/p2041rdb/p2041rdb.c                |   4 +-
 board/freescale/qemu-ppce500/qemu-ppce500.c        |   4 +-
 board/freescale/t102xqds/spl.c                     |   3 +-
 board/freescale/t102xqds/t102xqds.c                |   4 +-
 board/freescale/t102xrdb/spl.c                     |   3 +-
 board/freescale/t102xrdb/t102xrdb.c                |   4 +-
 board/freescale/t1040qds/t1040qds.c                |   4 +-
 board/freescale/t104xrdb/spl.c                     |   3 +-
 board/freescale/t104xrdb/t104xrdb.c                |   4 +-
 board/freescale/t208xqds/spl.c                     |   3 +-
 board/freescale/t208xqds/t208xqds.c                |   4 +-
 board/freescale/t208xrdb/spl.c                     |   3 +-
 board/freescale/t208xrdb/t208xrdb.c                |   4 +-
 board/freescale/t4qds/spl.c                        |   3 +-
 board/freescale/t4qds/t4240emu.c                   |   4 +-
 board/freescale/t4qds/t4240qds.c                   |   6 +-
 board/freescale/t4rdb/spl.c                        |   3 +-
 board/freescale/t4rdb/t4240rdb.c                   |   4 +-
 board/gateworks/gw_ventana/common.c                |   2 +-
 board/gateworks/gw_ventana/gw_ventana.c            |  64 +--
 board/gateworks/gw_ventana/gw_ventana_spl.c        |   6 +-
 board/gdsys/a38x/keyprogram.c                      |   4 +-
 board/gdsys/mpc8308/hrcon.c                        |   2 +-
 board/gdsys/mpc8308/strider.c                      |   2 +-
 board/gdsys/p1022/controlcenterd-id.c              |  10 +-
 board/gdsys/p1022/controlcenterd.c                 |   6 +-
 board/grinn/chiliboard/board.c                     |   8 +-
 board/grinn/liteboard/board.c                      |   6 +-
 board/gumstix/pepper/board.c                       |   4 +-
 board/highbank/highbank.c                          |   6 +-
 board/htkw/mcx/mcx.c                               |   2 +-
 board/intel/edison/edison.c                        |  15 +-
 board/isee/igep003x/board.c                        |  10 +-
 board/isee/igep00x0/igep00x0.c                     |   4 +-
 board/keymile/common/common.c                      |  26 +-
 board/keymile/common/ivm.c                         |  10 +-
 board/keymile/km83xx/km83xx.c                      |   8 +-
 board/keymile/km_arm/km_arm.c                      |   6 +-
 board/keymile/kmp204x/kmp204x.c                    |   8 +-
 board/kosagi/novena/novena.c                       |   4 +-
 board/lg/sniper/sniper.c                           |   4 +-
 board/liebherr/mccmon6/mccmon6.c                   |   6 +-
 board/logicpd/imx6/imx6logic.c                     |   6 +-
 board/logicpd/omap3som/omap3logic.c                |   4 +-
 board/logicpd/zoom1/zoom1.c                        |   4 +-
 board/micronas/vct/vct.c                           |   2 +-
 board/nokia/rx51/rx51.c                            |  10 +-
 board/overo/overo.c                                |  44 +--
 board/phytec/pcm051/board.c                        |   4 +-
 board/qualcomm/dragonboard410c/dragonboard410c.c   |   2 +-
 board/raspberrypi/rpi/rpi.c                        |  28 +-
 board/renesas/alt/alt.c                            |   2 +-
 board/renesas/blanche/blanche.c                    |   4 +-
 board/renesas/ecovec/ecovec.c                      |   2 +-
 board/renesas/gose/gose.c                          |   2 +-
 board/renesas/koelsch/koelsch.c                    |   2 +-
 board/renesas/lager/lager.c                        |   2 +-
 board/renesas/porter/porter.c                      |   2 +-
 board/renesas/sh7752evb/sh7752evb.c                |   4 +-
 board/renesas/sh7753evb/sh7753evb.c                |   4 +-
 board/renesas/sh7757lcr/sh7757lcr.c                |   6 +-
 board/renesas/silk/silk.c                          |   2 +-
 board/renesas/stout/stout.c                        |   2 +-
 board/rockchip/kylin_rk3036/kylin_rk3036.c         |   2 +-
 board/rockchip/tinker_rk3288/tinker-rk3288.c       |   2 +-
 board/samsung/common/exynos5-dt.c                  |   2 +-
 board/samsung/common/misc.c                        |  14 +-
 board/samsung/odroid/odroid.c                      |   2 +-
 board/samsung/trats/trats.c                        |   2 +-
 board/samsung/universal_c210/universal.c           |   2 +-
 board/samtec/vining_2000/vining_2000.c             |  10 +-
 board/samtec/vining_fpga/socfpga.c                 |  18 +-
 board/siemens/common/board.c                       |   4 +-
 board/siemens/common/factoryset.c                  |   8 +-
 board/siemens/common/factoryset.h                  |   2 +-
 board/siemens/draco/board.c                        |   8 +-
 board/siemens/pxm2/board.c                         |   6 +-
 board/siemens/rut/board.c                          |   4 +-
 board/siemens/taurus/taurus.c                      |  47 +--
 board/silica/pengwyn/board.c                       |   4 +-
 board/socrates/socrates.c                          |   4 +-
 board/solidrun/mx6cuboxi/mx6cuboxi.c               |   8 +-
 board/spear/common/spr_misc.c                      |  12 +-
 board/st/stm32f429-discovery/stm32f429-discovery.c |   4 +-
 board/sunxi/board.c                                |  18 +-
 board/syteco/zmx25/zmx25.c                         |   6 +-
 board/tcl/sl50/board.c                             |  14 +-
 board/technexion/twister/twister.c                 |   2 +-
 board/technologic/ts4800/ts4800.c                  |   2 +-
 board/teejet/mt_ventoux/mt_ventoux.c               |   4 +-
 board/theobroma-systems/puma_rk3399/puma-rk3399.c  |  12 +-
 board/ti/am335x/board.c                            |  16 +-
 board/ti/am43xx/board.c                            |  10 +-
 board/ti/am57xx/board.c                            |  22 +-
 board/ti/beagle/beagle.c                           |  38 +-
 board/ti/common/board_detect.c                     |  18 +-
 board/ti/dra7xx/evm.c                              |  14 +-
 board/ti/evm/evm.c                                 |   4 +-
 board/ti/ks2_evm/board.c                           |  12 +-
 board/ti/ks2_evm/board_k2g.c                       |   4 +-
 board/ti/panda/panda.c                             |   4 +-
 board/ti/ti814x/evm.c                              |   4 +-
 board/ti/ti816x/evm.c                              |   4 +-
 board/timll/devkit8000/devkit8000.c                |   4 +-
 board/toradex/apalis_imx6/apalis_imx6.c            |   9 +-
 board/toradex/colibri_imx6/colibri_imx6.c          |   2 +-
 board/toradex/colibri_vf/colibri_vf.c              |   2 +-
 board/toradex/common/tdx-cfg-block.c               |   2 +-
 board/toradex/common/tdx-common.c                  |  10 +-
 board/tqc/tqma6/tqma6.c                            |   2 +-
 board/udoo/neo/neo.c                               |   2 +-
 board/udoo/udoo.c                                  |   4 +-
 board/varisys/common/sys_eeprom.c                  |   6 +-
 board/varisys/cyrus/cyrus.c                        |   4 +-
 board/vscom/baltos/board.c                         |   8 +-
 board/wandboard/wandboard.c                        |   8 +-
 .../work-microwave/work_92105/work_92105_display.c |   2 +-
 board/xes/common/board.c                           |   6 +-
 board/xilinx/zynq/board.c                          |  12 +-
 board/xilinx/zynqmp/zynqmp.c                       |   6 +-
 cmd/bdinfo.c                                       |   6 +-
 cmd/bootm.c                                        |   4 +-
 cmd/bootmenu.c                                     |   4 +-
 cmd/cbfs.c                                         |   2 +-
 cmd/cramfs.c                                       |  10 +-
 cmd/elf.c                                          |  32 +-
 cmd/fdt.c                                          |  30 +-
 cmd/fpga.c                                         |   4 +-
 cmd/gpt.c                                          |   6 +-
 cmd/ini.c                                          |   6 +-
 cmd/itest.c                                        |   2 +-
 cmd/jffs2.c                                        |   6 +-
 cmd/load.c                                         |  16 +-
 cmd/log.c                                          |   6 +-
 cmd/lzmadec.c                                      |   2 +-
 cmd/md5sum.c                                       |   4 +-
 cmd/mtdparts.c                                     |  44 +--
 cmd/mvebu/bubt.c                                   |   2 +-
 cmd/nand.c                                         |  12 +-
 cmd/net.c                                          |  40 +-
 cmd/nvedit.c                                       |  38 +-
 cmd/part.c                                         |   8 +-
 cmd/pxe.c                                          |  39 +-
 cmd/qfw.c                                          |   6 +-
 cmd/reiser.c                                       |   8 +-
 cmd/setexpr.c                                      |  10 +-
 cmd/source.c                                       |   2 +-
 cmd/tpm.c                                          |   4 +-
 cmd/trace.c                                        |  18 +-
 cmd/unzip.c                                        |   2 +-
 cmd/ximg.c                                         |   6 +-
 cmd/zfs.c                                          |   6 +-
 cmd/zip.c                                          |   2 +-
 common/Kconfig                                     | 429 ---------------------
 common/Makefile                                    |  49 +--
 common/autoboot.c                                  |  24 +-
 common/board_f.c                                   |   4 +-
 common/board_r.c                                   |  22 +-
 common/bootm.c                                     |  18 +-
 common/bootm_os.c                                  |  12 +-
 common/bootretry.c                                 |   2 +-
 common/cli.c                                       |   2 +-
 common/cli_hush.c                                  |  16 +-
 common/cli_simple.c                                |   4 +-
 common/console.c                                   |  14 +-
 common/fb_mmc.c                                    |   2 +-
 common/fdt_support.c                               |   6 +-
 common/hash.c                                      |   4 +-
 common/hwconfig.c                                  |   6 +-
 common/image-android.c                             |   4 +-
 common/image-fdt.c                                 |   6 +-
 common/image.c                                     |  32 +-
 common/lcd.c                                       |   2 +-
 common/main.c                                      |   4 +-
 common/spl/Kconfig                                 |   4 +-
 common/spl/spl_dfu.c                               |   4 +-
 common/spl/spl_ext.c                               |   4 +-
 common/spl/spl_fat.c                               |   4 +-
 common/spl/spl_net.c                               |   4 +-
 common/splash.c                                    |   2 +-
 common/splash_source.c                             |   6 +-
 common/update.c                                    |  11 +-
 common/usb_hub.c                                   |   2 +-
 common/usb_kbd.c                                   |   6 +-
 disk/part.c                                        |   2 +-
 disk/part_amiga.c                                  |   4 +-
 doc/README.enetaddr                                |  10 +-
 drivers/bootcount/bootcount_env.c                  |  11 +-
 drivers/ddr/fsl/fsl_ddr_gen4.c                     |   2 +-
 drivers/ddr/fsl/interactive.c                      |   8 +-
 drivers/ddr/fsl/options.c                          |   6 +-
 drivers/dfu/dfu.c                                  |   6 +-
 drivers/dfu/dfu_mmc.c                              |   2 +-
 drivers/input/i8042.c                              |   2 +-
 drivers/input/input.c                              |   2 +-
 drivers/mtd/cfi_flash.c                            |   2 +-
 drivers/mtd/dataflash.c                            |   7 +-
 drivers/net/dc2114x.c                              |   2 +-
 drivers/net/fec_mxc.c                              |   4 +-
 drivers/net/fm/b4860.c                             |   2 +-
 drivers/net/fm/fdt.c                               |   2 +-
 drivers/net/fm/fm.c                                |   2 +-
 drivers/net/fsl-mc/mc.c                            |  10 +-
 drivers/net/fsl_mcdmafec.c                         |   4 +-
 drivers/net/ftgmac100.c                            |   2 +-
 drivers/net/ftmac100.c                             |   2 +-
 drivers/net/lan91c96.c                             |   4 +-
 drivers/net/mcffec.c                               |   8 +-
 drivers/net/ne2000_base.c                          |   6 +-
 drivers/net/netconsole.c                           |  14 +-
 drivers/net/phy/micrel.c                           |   2 +-
 drivers/net/sandbox-raw.c                          |   4 +-
 drivers/net/sh_eth.c                               |   2 +-
 drivers/pci/fsl_pci_init.c                         |   4 +-
 drivers/pci/pci.c                                  |   4 +-
 drivers/pci/pci_common.c                           |   2 +-
 drivers/rtc/m41t60.c                               |   2 +-
 drivers/scsi/scsi.c                                |   2 +-
 drivers/serial/usbtty.c                            |   9 +-
 drivers/usb/gadget/designware_udc.c                |   2 +-
 drivers/usb/gadget/ether.c                         |  14 +-
 drivers/usb/gadget/f_dfu.c                         |   2 +-
 drivers/usb/gadget/f_fastboot.c                    |   6 +-
 drivers/usb/host/ehci-fsl.c                        |   2 +-
 drivers/video/ati_radeon_fb.c                      |   3 +-
 drivers/video/cfb_console.c                        |   2 +-
 drivers/video/ct69000.c                            |   3 +-
 drivers/video/mb862xx.c                            |   3 +-
 drivers/video/mx3fb.c                              |   2 +-
 drivers/video/mxsfb.c                              |   2 +-
 drivers/video/videomodes.c                         |   5 +-
 env/Kconfig                                        | 428 ++++++++++++++++++++
 env/Makefile                                       |  57 +++
 common/env_attr.c => env/attr.c                    |   0
 common/env_callback.c => env/callback.c            |   2 +-
 common/env_common.c => env/common.c                |  46 +--
 common/env_dataflash.c => env/dataflash.c          |  33 +-
 common/env_eeprom.c => env/eeprom.c                |  61 ++-
 common/env_embedded.c => env/embedded.c            |   0
 env/env.c                                          | 151 ++++++++
 common/env_ext4.c => env/ext4.c                    |  28 +-
 common/env_fat.c => env/fat.c                      |  48 ++-
 common/env_flags.c => env/flags.c                  |   6 +-
 common/env_flash.c => env/flash.c                  |  92 +++--
 common/env_mmc.c => env/mmc.c                      |  59 ++-
 common/env_nand.c => env/nand.c                    |  71 ++--
 common/env_nowhere.c => env/nowhere.c              |  22 +-
 common/env_nvram.c => env/nvram.c                  |  26 +-
 common/env_onenand.c => env/onenand.c              |  24 +-
 common/env_remote.c => env/remote.c                |  24 +-
 common/env_sata.c => env/sata.c                    |  37 +-
 common/env_sf.c => env/sf.c                        |  76 ++--
 common/env_ubi.c => env/ubi.c                      |  41 +-
 fs/fs.c                                            |  14 +-
 fs/ubifs/ubifs.c                                   |   2 +-
 include/_exports.h                                 |   4 +-
 include/asm-generic/global_data.h                  |   4 +-
 include/common.h                                   |  94 ++++-
 include/configs/M5208EVBE.h                        |   4 +-
 include/configs/M5235EVB.h                         |   2 +-
 include/configs/M5249EVB.h                         |   4 +-
 include/configs/M5253DEMO.h                        |   4 +-
 include/configs/M5253EVBE.h                        |   2 +-
 include/configs/M5272C3.h                          |   4 +-
 include/configs/M5275EVB.h                         |   4 +-
 include/configs/M5282EVB.h                         |   2 +-
 include/configs/M53017EVB.h                        |   2 +-
 include/configs/M5329EVB.h                         |   4 +-
 include/configs/M5373EVB.h                         |   4 +-
 include/configs/amcore.h                           |   4 +-
 include/configs/astro_mcf5373l.h                   |   2 +-
 include/configs/cobra5272.h                        |   4 +-
 include/configs/tam3517-common.h                   |   2 +-
 include/dataflash.h                                |   2 +-
 include/environment.h                              | 133 ++++++-
 include/exports.h                                  |   4 +-
 include/image.h                                    |   8 +-
 include/net.h                                      |  12 +-
 include/search.h                                   |   2 +-
 lib/fdtdec.c                                       |   2 +-
 lib/smbios.c                                       |   2 +-
 lib/uuid.c                                         |   2 +-
 net/arp.c                                          |   2 +-
 net/bootp.c                                        |  14 +-
 net/dns.c                                          |   2 +-
 net/eth-uclass.c                                   |  10 +-
 net/eth_common.c                                   |  34 +-
 net/eth_internal.h                                 |   4 +-
 net/eth_legacy.c                                   |   8 +-
 net/link_local.c                                   |   2 +-
 net/net.c                                          |  14 +-
 net/net_rand.h                                     |   2 +-
 net/tftp.c                                         |  10 +-
 post/post.c                                        |   2 +-
 scripts/Makefile.spl                               |   4 +-
 test/command_ut.c                                  |  16 +-
 test/dm/eth.c                                      | 108 +++---
 tools/Makefile                                     |   4 +-
 tools/env/fw_env.c                                 |   2 +-
 tools/env/fw_env.h                                 |   4 +-
 tools/env/fw_env_main.c                            |   8 +-
 425 files changed, 2567 insertions(+), 2197 deletions(-)
 create mode 100644 env/Kconfig
 create mode 100644 env/Makefile
 rename common/env_attr.c => env/attr.c (100%)
 rename common/env_callback.c => env/callback.c (98%)
 rename common/env_common.c => env/common.c (89%)
 rename common/env_dataflash.c => env/dataflash.c (75%)
 rename common/env_eeprom.c => env/eeprom.c (86%)
 rename common/env_embedded.c => env/embedded.c (100%)
 create mode 100644 env/env.c
 rename common/env_ext4.c => env/ext4.c (91%)
 rename common/env_fat.c => env/fat.c (75%)
 rename common/env_flags.c => env/flags.c (99%)
 rename common/env_flash.c => env/flash.c (80%)
 rename common/env_mmc.c => env/mmc.c (90%)
 rename common/env_nand.c => env/nand.c (87%)
 rename common/env_nowhere.c => env/nowhere.c (58%)
 rename common/env_nvram.c => env/nvram.c (86%)
 rename common/env_onenand.c => env/onenand.c (89%)
 rename common/env_remote.c => env/remote.c (73%)
 rename common/env_sata.c => env/sata.c (84%)
 rename common/env_sf.c => env/sf.c (87%)
 rename common/env_ubi.c => env/ubi.c (91%)
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#1 lore raw

PATCH v4 1/29 Makefile: Rename 'env' target to 'environ'

This target stops us using 'env' as a subdirectory. It is not mentioned in the help so seems to be an internal target. Rename it.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
index 78a5f73687..5b16965585 100644
@@ -1463,14 +1463,14 @@ checkarmreloc: u-boot
 		false; \
 	fi
 
-env: scripts_basic
+environ: scripts_basic
 	$(Q)$(MAKE) $(build)=tools/$@
 
 tools-only: scripts_basic $(version_h) $(timestamp_h)
 	$(Q)$(MAKE) $(build)=tools
 
 tools-all: export HOST_TOOLS_ALL=y
-tools-all: env tools ;
+tools-all: environ tools ;
 
 cross_tools: export CROSS_BUILD_TOOLS=y
 cross_tools: tools ;
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#2 lore raw

PATCH v4 2/29 Move environment files from common/ to env/

In reply to Simon Glass

About a quarter of the files in common/ relate to the environment. It seems better to put these into their own subdirectory and remove the prefix.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 Kconfig                                   |   2 +
 Makefile                                  |   1 +
 arch/sh/cpu/u-boot.lds                    |   4 +-
 board/freescale/mx31ads/u-boot.lds        |   2 +-
 common/Kconfig                            | 429 ------------------------------
 common/Makefile                           |  49 +---
 env/Kconfig                               | 428 +++++++++++++++++++++++++++++
 env/Makefile                              |  57 ++++
 common/env_attr.c => env/attr.c           |   0
 common/env_callback.c => env/callback.c   |   0
 common/env_common.c => env/common.c       |   0
 common/env_dataflash.c => env/dataflash.c |   0
 common/env_eeprom.c => env/eeprom.c       |   0
 common/env_embedded.c => env/embedded.c   |   0
 common/env_ext4.c => env/ext4.c           |   0
 common/env_fat.c => env/fat.c             |   0
 common/env_flags.c => env/flags.c         |   0
 common/env_flash.c => env/flash.c         |   0
 common/env_mmc.c => env/mmc.c             |   0
 common/env_nand.c => env/nand.c           |   0
 common/env_nowhere.c => env/nowhere.c     |   0
 common/env_nvram.c => env/nvram.c         |   0
 common/env_onenand.c => env/onenand.c     |   0
 common/env_remote.c => env/remote.c       |   0
 common/env_sata.c => env/sata.c           |   0
 common/env_sf.c => env/sf.c               |   0
 common/env_ubi.c => env/ubi.c             |   0
 include/configs/M5208EVBE.h               |   4 +-
 include/configs/M5235EVB.h                |   2 +-
 include/configs/M5249EVB.h                |   4 +-
 include/configs/M5253DEMO.h               |   4 +-
 include/configs/M5253EVBE.h               |   2 +-
 include/configs/M5272C3.h                 |   4 +-
 include/configs/M5275EVB.h                |   4 +-
 include/configs/M5282EVB.h                |   2 +-
 include/configs/M53017EVB.h               |   2 +-
 include/configs/M5329EVB.h                |   4 +-
 include/configs/M5373EVB.h                |   4 +-
 include/configs/amcore.h                  |   4 +-
 include/configs/astro_mcf5373l.h          |   2 +-
 include/configs/cobra5272.h               |   4 +-
 scripts/Makefile.spl                      |   4 +-
 tools/Makefile                            |   4 +-
 43 files changed, 519 insertions(+), 507 deletions(-)
 create mode 100644 env/Kconfig
 create mode 100644 env/Makefile
 rename common/env_attr.c => env/attr.c (100%)
 rename common/env_callback.c => env/callback.c (100%)
 rename common/env_common.c => env/common.c (100%)
 rename common/env_dataflash.c => env/dataflash.c (100%)
 rename common/env_eeprom.c => env/eeprom.c (100%)
 rename common/env_embedded.c => env/embedded.c (100%)
 rename common/env_ext4.c => env/ext4.c (100%)
 rename common/env_fat.c => env/fat.c (100%)
 rename common/env_flags.c => env/flags.c (100%)
 rename common/env_flash.c => env/flash.c (100%)
 rename common/env_mmc.c => env/mmc.c (100%)
 rename common/env_nand.c => env/nand.c (100%)
 rename common/env_nowhere.c => env/nowhere.c (100%)
 rename common/env_nvram.c => env/nvram.c (100%)
 rename common/env_onenand.c => env/onenand.c (100%)
 rename common/env_remote.c => env/remote.c (100%)
 rename common/env_sata.c => env/sata.c (100%)
 rename common/env_sf.c => env/sf.c (100%)
 rename common/env_ubi.c => env/ubi.c (100%)
Kconfig +2 -0
index c1451bceda..5ca3854b23 100644
@@ -368,6 +368,8 @@ source "disk/Kconfig"
 
 source "dts/Kconfig"
 
+source "env/Kconfig"
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
Makefile +1 -0
index 5b16965585..e95b658570 100644
@@ -690,6 +690,7 @@ libs-y += drivers/usb/phy/
 libs-y += drivers/usb/ulpi/
 libs-y += cmd/
 libs-y += common/
+libs-y += env/
 libs-$(CONFIG_API) += api/
 libs-$(CONFIG_HAS_POST) += post/
 libs-y += test/
arch/sh/cpu/u-boot.lds +2 -2
index bbf9ff485f..7fc91bc4aa 100644
@@ -33,9 +33,9 @@ SECTIONS
 		KEEP(CONFIG_BOARDDIR/lowlevel_init.o	(.text .spiboot1.text))
 		KEEP(*(.spiboot2.text))
 		. = ALIGN(8192);
-		common/env_embedded.o	(.ppcenv)
+		env/embedded.o	(.ppcenv)
 		. = ALIGN(8192);
-		common/env_embedded.o	(.ppcenvr)
+		env/embedded.o	(.ppcenvr)
 		. = ALIGN(8192);
 		*(.text)
 		. = ALIGN(4);
board/freescale/mx31ads/u-boot.lds +1 -1
index 8a4a8a2f07..71a63f188e 100644
@@ -30,7 +30,7 @@ SECTIONS
 	  drivers/mtd/built-in.o		(.text*)
 
 	  . = DEFINED(env_offset) ? env_offset : .;
-	  common/env_embedded.o(.text*)
+	  env/embedded.o(.text*)
 
 	  *(.text*)
 	}
common/Kconfig +0 -429

435 lines not on this page · raw message

common/Makefile +1 -48

77 lines not on this page · raw message

env/Kconfig new file +428 -0

428 lines not on this page · raw message

env/Makefile new file +57 -0

57 lines not on this page · raw message

env/attr.c renamed from common/env_attr.c +0 -0
similarity index 100%
rename from common/env_attr.c
rename to env/attr.c
env/callback.c renamed from common/env_callback.c +0 -0
similarity index 100%
rename from common/env_callback.c
rename to env/callback.c
env/common.c renamed from common/env_common.c +0 -0
similarity index 100%
rename from common/env_common.c
rename to env/common.c
env/dataflash.c renamed from common/env_dataflash.c +0 -0
similarity index 100%
rename from common/env_dataflash.c
rename to env/dataflash.c
env/eeprom.c renamed from common/env_eeprom.c +0 -0
similarity index 100%
rename from common/env_eeprom.c
rename to env/eeprom.c
env/embedded.c renamed from common/env_embedded.c +0 -0
similarity index 100%
rename from common/env_embedded.c
rename to env/embedded.c
env/ext4.c renamed from common/env_ext4.c +0 -0
similarity index 100%
rename from common/env_ext4.c
rename to env/ext4.c
env/fat.c renamed from common/env_fat.c +0 -0
similarity index 100%
rename from common/env_fat.c
rename to env/fat.c
env/flags.c renamed from common/env_flags.c +0 -0
similarity index 100%
rename from common/env_flags.c
rename to env/flags.c
env/flash.c renamed from common/env_flash.c +0 -0
similarity index 100%
rename from common/env_flash.c
rename to env/flash.c
env/mmc.c renamed from common/env_mmc.c +0 -0
similarity index 100%
rename from common/env_mmc.c
rename to env/mmc.c
env/nand.c renamed from common/env_nand.c +0 -0
similarity index 100%
rename from common/env_nand.c
rename to env/nand.c
env/nowhere.c renamed from common/env_nowhere.c +0 -0
similarity index 100%
rename from common/env_nowhere.c
rename to env/nowhere.c
env/nvram.c renamed from common/env_nvram.c +0 -0
similarity index 100%
rename from common/env_nvram.c
rename to env/nvram.c
env/onenand.c renamed from common/env_onenand.c +0 -0
similarity index 100%
rename from common/env_onenand.c
rename to env/onenand.c
env/remote.c renamed from common/env_remote.c +0 -0
similarity index 100%
rename from common/env_remote.c
rename to env/remote.c
env/sata.c renamed from common/env_sata.c +0 -0
similarity index 100%
rename from common/env_sata.c
rename to env/sata.c
env/sf.c renamed from common/env_sf.c +0 -0
similarity index 100%
rename from common/env_sf.c
rename to env/sf.c
env/ubi.c renamed from common/env_ubi.c +0 -0
similarity index 100%
rename from common/env_ubi.c
rename to env/ubi.c
include/configs/M5208EVBE.h +2 -2
index 0fbf457cdc..c56cbd9f54 100644
@@ -161,8 +161,8 @@
 #define CONFIG_ENV_SECT_SIZE		0x2000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /* Cache Configuration */
 #define CONFIG_SYS_CACHELINE_SIZE	16
include/configs/M5235EVB.h +1 -1
index 57328c6269..c3fdc0b106 100644
@@ -179,7 +179,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o (.text);
+	env/embedded.o(.text);
 
 #ifdef NORFLASH_PS32BIT
 #	define CONFIG_ENV_OFFSET		(0x8000)
include/configs/M5249EVB.h +2 -2
index f6027e231f..df0733e6c2 100644
@@ -85,8 +85,8 @@
 #define CONFIG_SYS_INIT_SP_OFFSET	CONFIG_SYS_GBL_DATA_OFFSET
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 #define CONFIG_ENV_OFFSET		0x4000	/* Address of Environment Sector*/
 #define CONFIG_ENV_SIZE		0x2000	/* Total Size of Environment Sector	*/
include/configs/M5253DEMO.h +2 -2
index 2bdfe80ef5..da8333ac6f 100644
@@ -29,8 +29,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /*
  * Command line configuration.
include/configs/M5253EVBE.h +1 -1
index 0722ea19e3..5a2f0e204f 100644
@@ -31,7 +31,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o      (.text)
+	env/embedded.o(.text)
 
 /*
  * BOOTP options
include/configs/M5272C3.h +2 -2
index e6bd7f3609..f5693d8178 100644
@@ -39,8 +39,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 /*
  * BOOTP options
include/configs/M5275EVB.h +2 -2
index 6bcd6b6f2e..339a03c7b1 100644
@@ -40,8 +40,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 /*
  * BOOTP options
include/configs/M5282EVB.h +1 -1
index cc703aac19..3f2d9a9bac 100644
@@ -32,7 +32,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o (.text*);
+	env/embedded.o(.text*);
 
 /*
  * BOOTP options
include/configs/M53017EVB.h +1 -1
index d50c874fe1..a0c9dd904d 100644
@@ -185,7 +185,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o       (.text*)
+	env/embedded.o(.text*)
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
include/configs/M5329EVB.h +2 -2
index 45cdf9da15..d6b5531833 100644
@@ -189,8 +189,8 @@
 #define CONFIG_ENV_SECT_SIZE	0x2000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
include/configs/M5373EVB.h +2 -2
index 26639fc41f..07dfe7aec3 100644
@@ -189,8 +189,8 @@
 #define CONFIG_ENV_SECT_SIZE	0x2000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /*-----------------------------------------------------------------------
  * Cache Configuration
include/configs/amcore.h +2 -2
index 0a40746112..5f8b6c5518 100644
@@ -93,8 +93,8 @@
 #define CONFIG_ENV_SECT_SIZE		0x1000
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text*);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text*);
 
 /* memory map space for linux boot data */
 #define CONFIG_SYS_BOOTMAPSZ		(8 << 20)
include/configs/astro_mcf5373l.h +1 -1
index 7e373a2ca4..985d77d126 100644
@@ -300,7 +300,7 @@
 
 #define LDS_BOARD_TEXT \
 	. = DEFINED(env_offset) ? env_offset : .; \
-	common/env_embedded.o       (.text*)
+	env/embedded.o(.text*)
 
 #if ENABLE_JFFS
 /* JFFS Partition offset set */
include/configs/cobra5272.h +2 -2
index a3b7b219b3..c1c3013dc3 100644
@@ -102,8 +102,8 @@
 #endif
 
 #define LDS_BOARD_TEXT \
-        . = DEFINED(env_offset) ? env_offset : .; \
-        common/env_embedded.o (.text);
+	. = DEFINED(env_offset) ? env_offset : .; \
+	env/embedded.o(.text);
 
 /*
  * BOOTP options
scripts/Makefile.spl +2 -2
index ac3c2c7f13..f25a8bf725 100644
@@ -69,10 +69,10 @@ libs-y += common/init/
 
 # Special handling for a few options which support SPL/TPL
 ifeq ($(CONFIG_TPL_BUILD),y)
-libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/
+libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
 libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/
 else
-libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/
+libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
 libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
 endif
 
tools/Makefile +2 -2
index 0743677dc8..a1790ebd59 100644
@@ -37,7 +37,7 @@ hostprogs-$(CONFIG_VIDEO_LOGO) += bmp_logo
 HOSTCFLAGS_bmp_logo.o := -pedantic
 
 hostprogs-$(CONFIG_BUILD_ENVCRC) += envcrc
-envcrc-objs := envcrc.o lib/crc32.o common/env_embedded.o lib/sha1.o
+envcrc-objs := envcrc.o lib/crc32.o env/embedded.o lib/sha1.o
 
 hostprogs-$(CONFIG_CMD_NET) += gen_eth_addr
 HOSTCFLAGS_gen_eth_addr.o := -pedantic
@@ -225,7 +225,7 @@ HOSTCFLAGS_sha256.o := -pedantic
 quiet_cmd_wrap = WRAP    $@
 cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@
 
-$(obj)/lib/%.c $(obj)/common/%.c:
+$(obj)/lib/%.c $(obj)/common/%.c $(obj)/env/%.c:
 	$(call cmd,wrap)
 
 clean-dirs := lib common
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#3 lore raw

PATCH v4 3/29 env: Move help from README to Kconfig

In reply to Simon Glass

The CONFIG_ENV_IS_IN_... options which have already been converted to Kconfig only have a small amount of help. Move the rest of it over from the README.

(The v1 patch of this was nak'ed[1]. Please ignore this patch if not wanted)

[1] http://patchwork.ozlabs.org/patch/794040/

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/Kconfig | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)
env/Kconfig +21 -21
index 6e885f85a6..402ace3327 100644
@@ -80,35 +80,35 @@ config ENV_IS_IN_FAT
 	bool "Environment is in a FAT filesystem"
 	depends on !CHAIN_OF_TRUST
 	help
-         Define this if you want to use the FAT file system for the environment.
+	  Define this if you want to use the FAT file system for the environment.
 
-         - FAT_ENV_INTERFACE:
+	  - FAT_ENV_INTERFACE:
 
-         Define this to a string that is the name of the block device.
+	  Define this to a string that is the name of the block device.
 
-         - FAT_ENV_DEVICE_AND_PART:
+	  - FAT_ENV_DEVICE_AND_PART:
 
-         Define this to a string to specify the partition of the device. It can
-         be as following:
+	  Define this to a string to specify the partition of the device. It can
+	  be as following:
 
-           "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
-               - "D:P": device D partition P. Error occurs if device D has no
-                        partition table.
-               - "D:0": device D.
-               - "D" or "D:": device D partition 1 if device D has partition
-                              table, or the whole device D if has no partition
-                              table.
-               - "D:auto": first partition in device D with bootable flag set.
-                           If none, first valid partition in device D. If no
-                           partition table then means device D.
+	  "D:P", "D:0", "D", "D:" or "D:auto" (D, P are integers. And P >= 1)
+	  - "D:P": device D partition P. Error occurs if device D has no
+	    partition table.
+	  - "D:0": device D.
+	  - "D" or "D:": device D partition 1 if device D has partition
+	    table, or the whole device D if has no partition
+	    table.
+	  - "D:auto": first partition in device D with bootable flag set.
+	    If none, first valid partition in device D. If no
+	    partition table then means device D.
 
-         - FAT_ENV_FILE:
+	  - FAT_ENV_FILE:
 
-         It's a string of the FAT file name. This file use to store the
-         environment.
+	  It's a string of the FAT file name. This file use to store the
+	  environment.
 
-         - CONFIG_FAT_WRITE:
-         This must be enabled. Otherwise it cannot save the environment file.
+	  - CONFIG_FAT_WRITE:
+	  This must be enabled. Otherwise it cannot save the environment file.
 
 config ENV_IS_IN_FLASH
 	bool "Environment in flash memory"
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#4 lore raw

PATCH v4 4/29 env: common: Make env_get_addr/get_char_memory() static

In reply to Simon Glass

These functions are not used outside this file. Make them static and order them to avoid forward declarations.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c          | 18 +++++++++---------
 include/environment.h |  4 ----
 2 files changed, 9 insertions(+), 13 deletions(-)
env/common.c +9 -9
index d9c0c4e3f3..5a17e52615 100644
@@ -41,7 +41,15 @@ static uchar env_get_char_init(int index)
 		return default_environment[index];
 }
 
-uchar env_get_char_memory(int index)
+static const uchar *env_get_addr(int index)
+{
+	if (gd->env_valid)
+		return (uchar *)(gd->env_addr + index);
+	else
+		return &default_environment[index];
+}
+
+static uchar env_get_char_memory(int index)
 {
 	return *env_get_addr(index);
 }
@@ -55,14 +63,6 @@ uchar env_get_char(int index)
 		return env_get_char_init(index);
 }
 
-const uchar *env_get_addr(int index)
-{
-	if (gd->env_valid)
-		return (uchar *)(gd->env_addr + index);
-	else
-		return &default_environment[index];
-}
-
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
include/environment.h +0 -4
index d86230a2e9..5f2064bf23 100644
@@ -202,10 +202,6 @@ extern struct hsearch_data env_htab;
 /* Function that returns a character from the environment */
 unsigned char env_get_char(int);
 
-/* Function that returns a pointer to a value from the environment */
-const unsigned char *env_get_addr(int);
-unsigned char env_get_char_memory(int index);
-
 /* Function that updates CRC of the enironment */
 void env_crc_update(void);
 
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#5 lore raw

PATCH v4 5/29 env: common: Drop env_get_addr()

In reply to Simon Glass

This function is not used anywhere other than env_get_char(). Move the code into that function.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
env/common.c +3 -8
index 5a17e52615..2e94dd71e2 100644
@@ -41,17 +41,12 @@ static uchar env_get_char_init(int index)
 		return default_environment[index];
 }
 
-static const uchar *env_get_addr(int index)
+static uchar env_get_char_memory(int index)
 {
 	if (gd->env_valid)
-		return (uchar *)(gd->env_addr + index);
+		return *(uchar *)(gd->env_addr + index);
 	else
-		return &default_environment[index];
-}
-
-static uchar env_get_char_memory(int index)
-{
-	return *env_get_addr(index);
+		return default_environment[index];
 }
 
 uchar env_get_char(int index)
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#6 lore raw

PATCH v4 6/29 env: common: Factor out the common env_valid check

In reply to Simon Glass

The check for gd->env_valid is used in both the 'if' and 'else' part of env_get_char(). Move it into that function instead for simplicity. Drop that code from the two leaf functions.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
env/common.c +6 -11
index 2e94dd71e2..bfa8cfb143 100644
@@ -34,25 +34,20 @@ __weak uchar env_get_char_spec(int index)
 
 static uchar env_get_char_init(int index)
 {
-	/* if crc was bad, use the default environment */
-	if (gd->env_valid)
-		return env_get_char_spec(index);
-	else
-		return default_environment[index];
+	return env_get_char_spec(index);
 }
 
 static uchar env_get_char_memory(int index)
 {
-	if (gd->env_valid)
-		return *(uchar *)(gd->env_addr + index);
-	else
-		return default_environment[index];
+	return *(uchar *)(gd->env_addr + index);
 }
 
 uchar env_get_char(int index)
 {
-	/* if relocated to RAM */
-	if (gd->flags & GD_FLG_RELOC)
+	/* if env is not set up, or crc was bad, use the default environment */
+	if (!gd->env_valid)
+		return default_environment[index];
+	else if (gd->flags & GD_FLG_RELOC)  /* if relocated to RAM */
 		return env_get_char_memory(index);
 	else
 		return env_get_char_init(index);
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#7 lore raw

PATCH v4 7/29 env: common: Drop env_get_char_init()

In reply to Simon Glass

This function does nothing but call env_get_char_spec(). Drop it and adjust its only caller.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
env/common.c +1 -6
index bfa8cfb143..f0ffe4ed73 100644
@@ -32,11 +32,6 @@ __weak uchar env_get_char_spec(int index)
 	return *((uchar *)(gd->env_addr + index));
 }
 
-static uchar env_get_char_init(int index)
-{
-	return env_get_char_spec(index);
-}
-
 static uchar env_get_char_memory(int index)
 {
 	return *(uchar *)(gd->env_addr + index);
@@ -50,7 +45,7 @@ uchar env_get_char(int index)
 	else if (gd->flags & GD_FLG_RELOC)  /* if relocated to RAM */
 		return env_get_char_memory(index);
 	else
-		return env_get_char_init(index);
+		return env_get_char_spec(index);
 }
 
 /*
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#8 lore raw

PATCH v4 8/29 env: common: Drop env_get_char_memory()

In reply to Simon Glass

This function is the same as env_get_char_spec() apart from dropping the brackets. Drop the brackets from env_get_char_spec() and use that instead of env_get_char_memory().

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c | 7 -------
 1 file changed, 7 deletions(-)
env/common.c +0 -7
index f0ffe4ed73..842c0f7fd1 100644
@@ -28,11 +28,6 @@ struct hsearch_data env_htab = {
 };
 
 __weak uchar env_get_char_spec(int index)
-{
-	return *((uchar *)(gd->env_addr + index));
-}
-
-static uchar env_get_char_memory(int index)
 {
 	return *(uchar *)(gd->env_addr + index);
 }
@@ -42,8 +37,6 @@ uchar env_get_char(int index)
 	/* if env is not set up, or crc was bad, use the default environment */
 	if (!gd->env_valid)
 		return default_environment[index];
-	else if (gd->flags & GD_FLG_RELOC)  /* if relocated to RAM */
-		return env_get_char_memory(index);
 	else
 		return env_get_char_spec(index);
 }
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#9 lore raw

PATCH v4 9/29 env: Add an enum for environment state

In reply to Simon Glass

At present we have three states for the environment, numbered 0, 1 and 2. Add an enum to record this to avoid open-coded values.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/Arcturus/ucp1020/spl.c       |  3 ++-
 board/freescale/b4860qds/spl.c     |  3 ++-
 board/freescale/c29xpcie/spl.c     |  3 ++-
 board/freescale/p1010rdb/spl.c     |  3 ++-
 board/freescale/p1022ds/spl.c      |  3 ++-
 board/freescale/p1_p2_rdb_pc/spl.c |  3 ++-
 board/freescale/t102xqds/spl.c     |  3 ++-
 board/freescale/t102xrdb/spl.c     |  3 ++-
 board/freescale/t104xrdb/spl.c     |  3 ++-
 board/freescale/t208xqds/spl.c     |  3 ++-
 board/freescale/t208xrdb/spl.c     |  3 ++-
 board/freescale/t4qds/spl.c        |  3 ++-
 board/freescale/t4rdb/spl.c        |  3 ++-
 env/dataflash.c                    |  2 +-
 env/eeprom.c                       | 30 +++++++++++++++---------------
 env/ext4.c                         |  2 +-
 env/fat.c                          |  2 +-
 env/flash.c                        | 22 +++++++++++-----------
 env/mmc.c                          | 10 +++++-----
 env/nand.c                         | 29 +++++++++++++++--------------
 env/nvram.c                        |  2 +-
 env/onenand.c                      |  4 ++--
 env/remote.c                       |  2 +-
 env/sata.c                         |  2 +-
 env/sf.c                           | 26 +++++++++++++-------------
 env/ubi.c                          |  6 +++---
 include/asm-generic/global_data.h  |  2 +-
 include/environment.h              |  7 +++++++
 28 files changed, 104 insertions(+), 83 deletions(-)
board/Arcturus/ucp1020/spl.c +2 -1
index cd484fc44b..b5e7a5db06 100644
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -99,7 +100,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
board/freescale/b4860qds/spl.c +2 -1
index 60d7f0d48a..b1824b07a2 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
@@ -101,7 +102,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #endif
 
 	i2c_init_all();
board/freescale/c29xpcie/spl.c +2 -1
index 94093f11a8..28541a72cb 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -63,7 +64,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/p1010rdb/spl.c +2 -1
index 2cebc2c002..001308874e 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -87,7 +88,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 			    gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
board/freescale/p1022ds/spl.c +2 -1
index a117dc3a2c..94b357d446 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -100,7 +101,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 			    (uchar *)CONFIG_ENV_ADDR);
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
board/freescale/p1_p2_rdb_pc/spl.c +2 -1
index ca7ba5754e..c1d4c36b06 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <ns16550.h>
 #include <malloc.h>
 #include <mmc.h>
@@ -92,7 +93,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 	nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
 			    (uchar *)CONFIG_ENV_ADDR);
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 #else
 	env_relocate();
 #endif
board/freescale/t102xqds/spl.c +2 -1
index b987ecea1d..3aa19e6715 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -138,7 +139,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/t102xrdb/spl.c +2 -1
index dc6d9eeef6..ca1e49ffa7 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -125,7 +126,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/t104xrdb/spl.c +2 -1
index 2e43307b2d..4fb9323873 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -119,7 +120,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 			       (uchar *)CONFIG_ENV_ADDR);
 #endif
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/t208xqds/spl.c +2 -1
index d7d716b690..36961dc9b0 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -124,7 +125,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/t208xrdb/spl.c +2 -1
index b43140148b..f0cc34d788 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <malloc.h>
 #include <ns16550.h>
 #include <nand.h>
@@ -94,7 +95,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/t4qds/spl.c +2 -1
index 9ecdaedda3..750f155493 100644
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
@@ -129,7 +130,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 #endif
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
board/freescale/t4rdb/spl.c +2 -1
index 5feab1cfcd..932954e93d 100644
@@ -8,6 +8,7 @@
 
 #include <common.h>
 #include <console.h>
+#include <environment.h>
 #include <asm/spl.h>
 #include <malloc.h>
 #include <ns16550.h>
@@ -87,7 +88,7 @@ void board_init_r(gd_t *gd, ulong dest_addr)
 			   (uchar *)CONFIG_ENV_ADDR);
 
 	gd->env_addr  = (ulong)(CONFIG_ENV_ADDR);
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	i2c_init_all();
 
env/dataflash.c +1 -1
index 034e323169..c140b74c98 100644
@@ -78,7 +78,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
env/eeprom.c +15 -15
index 5f63a6cd4a..ac6b30fa8f 100644
@@ -71,7 +71,7 @@ uchar env_get_char_spec(int index)
 	unsigned int off = CONFIG_ENV_OFFSET;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		off = CONFIG_ENV_OFFSET_REDUND;
 #endif
 	eeprom_bus_read(CONFIG_SYS_DEF_EEPROM_ADDR,
@@ -128,21 +128,21 @@ void env_relocate_spec(void)
 		gd->env_addr	= 0;
 		gd->env_valid	= 0;
 	} else if (crc_ok[0] && !crc_ok[1]) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (!crc_ok[0] && crc_ok[1]) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/* both ok - check serial */
 		if (flags[0] == ACTIVE_FLAG && flags[1] == OBSOLETE_FLAG)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (flags[0] == OBSOLETE_FLAG && flags[1] == ACTIVE_FLAG)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (flags[0] == 0xFF && flags[1] == 0)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (flags[1] == 0xFF && flags[0] == 0)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else /* flags are equal - almost impossible */
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 
 #else /* CONFIG_ENV_OFFSET_REDUND */
@@ -170,7 +170,7 @@ void env_relocate_spec(void)
 	}
 
 	if (crc == new) {
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else {
 		gd->env_valid	= 0;
 	}
@@ -178,7 +178,7 @@ void env_relocate_spec(void)
 
 	off = CONFIG_ENV_OFFSET;
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		off = CONFIG_ENV_OFFSET_REDUND;
 #endif
 
@@ -205,7 +205,7 @@ int saveenv(void)
 		return rc;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 1) {
+	if (gd->env_valid == ENV_VALID) {
 		off	= CONFIG_ENV_OFFSET_REDUND;
 		off_red	= CONFIG_ENV_OFFSET;
 	}
@@ -222,10 +222,10 @@ int saveenv(void)
 				 off_red + offsetof(env_t, flags),
 				 (uchar *)&flag_obsolete, 1);
 
-		if (gd->env_valid == 1)
-			gd->env_valid = 2;
+		if (gd->env_valid == ENV_VALID)
+			gd->env_valid = ENV_REDUND;
 		else
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 #endif
 	return rc;
@@ -240,6 +240,6 @@ int saveenv(void)
 int env_init(void)
 {
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 	return 0;
 }
env/ext4.c +1 -1
index adefa7dc99..7bb4ce7cff 100644
@@ -41,7 +41,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
env/fat.c +1 -1
index 75616d4c5b..5a2131a5a9 100644
@@ -29,7 +29,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
env/flash.c +11 -11
index 004e8849a7..dcf3cd2c62 100644
@@ -75,28 +75,28 @@ int env_init(void)
 
 	if (crc1_ok && !crc2_ok) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (!crc1_ok && crc2_ok) {
 		gd->env_addr	= addr2;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (!crc1_ok && !crc2_ok) {
 		gd->env_addr	= addr_default;
 		gd->env_valid	= 0;
 	} else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (flag1 == OBSOLETE_FLAG && flag2 == ACTIVE_FLAG) {
 		gd->env_addr	= addr2;
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 	} else if (flag1 == flag2) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 2;
+		gd->env_valid	= ENV_REDUND;
 	} else if (flag1 == 0xFF) {
 		gd->env_addr	= addr1;
-		gd->env_valid	= 2;
+		gd->env_valid	= ENV_REDUND;
 	} else if (flag2 == 0xFF) {
 		gd->env_addr	= addr2;
-		gd->env_valid	= 2;
+		gd->env_valid	= ENV_REDUND;
 	}
 
 	return 0;
@@ -211,7 +211,7 @@ int env_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr	= (ulong)&(env_ptr->data);
-		gd->env_valid	= 1;
+		gd->env_valid	= ENV_VALID;
 		return 0;
 	}
 
@@ -309,7 +309,7 @@ void env_relocate_spec(void)
 	    crc32(0, flash_addr_new->data, ENV_SIZE) == flash_addr_new->crc) {
 		char flag = OBSOLETE_FLAG;
 
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		flash_sect_protect(0, (ulong)flash_addr_new, end_addr_new);
 		flash_write(&flag,
 			    (ulong)&(flash_addr_new->flags),
@@ -321,7 +321,7 @@ void env_relocate_spec(void)
 	    (flash_addr->flags & ACTIVE_FLAG) == ACTIVE_FLAG) {
 		char flag = ACTIVE_FLAG;
 
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		flash_sect_protect(0, (ulong)flash_addr, end_addr);
 		flash_write(&flag,
 			    (ulong)&(flash_addr->flags),
@@ -329,7 +329,7 @@ void env_relocate_spec(void)
 		flash_sect_protect(1, (ulong)flash_addr, end_addr);
 	}
 
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		puts("*** Warning - some problems detected "
 		     "reading environment; recovered successfully\n\n");
 #endif /* CONFIG_ENV_ADDR_REDUND */
env/mmc.c +5 -5
index bb760a00ed..e387202e71 100644
@@ -86,7 +86,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 1;
+	gd->env_valid	= ENV_VALID;
 
 	return 0;
 }
@@ -180,7 +180,7 @@ int saveenv(void)
 		goto fini;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		copy = 1;
 #endif
 
@@ -200,7 +200,7 @@ int saveenv(void)
 	ret = 0;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+	gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
 #endif
 
 fini:
@@ -265,10 +265,10 @@ void env_relocate_spec(void)
 		ret = 1;
 		goto fini;
 	} else if (!read1_fail && read2_fail) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 		env_import((char *)tmp_env1, 1);
 	} else if (read1_fail && !read2_fail) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		env_import((char *)tmp_env2, 1);
 	} else {
 		env_import_redund((char *)tmp_env1, (char *)tmp_env2);
env/nand.c +15 -14
index 760f6859e3..90f274bf8a 100644
@@ -84,37 +84,37 @@ int env_init(void)
 
 		return 0;
 	} else if (crc1_ok && !crc2_ok) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	}
 #ifdef CONFIG_ENV_OFFSET_REDUND
 	else if (!crc1_ok && crc2_ok) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/* both ok - check serial */
 		if (tmp_env1->flags == 255 && tmp_env2->flags == 0)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else if (tmp_env2->flags == 255 && tmp_env1->flags == 0)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (tmp_env1->flags > tmp_env2->flags)
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 		else if (tmp_env2->flags > tmp_env1->flags)
-			gd->env_valid = 2;
+			gd->env_valid = ENV_REDUND;
 		else /* flags are equal - almost impossible */
-			gd->env_valid = 1;
+			gd->env_valid = ENV_VALID;
 	}
 
-	if (gd->env_valid == 2)
+	if (gd->env_valid == ENV_REDUND)
 		env_ptr = tmp_env2;
 	else
 #endif
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		env_ptr = tmp_env1;
 
 	gd->env_addr = (ulong)env_ptr->data;
 
 #else /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */
 	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 1;
+	gd->env_valid	= ENV_VALID;
 #endif /* ENV_IS_EMBEDDED || CONFIG_NAND_ENV_DST */
 
 	return 0;
@@ -217,14 +217,15 @@ int saveenv(void)
 		return ret;
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-	env_idx = (gd->env_valid == 1);
+	env_idx = (gd->env_valid == ENV_VALID);
 #endif
 
 	ret = erase_and_write_env(&location[env_idx], (u_char *)env_new);
 #ifdef CONFIG_ENV_OFFSET_REDUND
 	if (!ret) {
 		/* preset other copy for next write */
-		gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+		gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID :
+				ENV_REDUND;
 		return ret;
 	}
 
@@ -342,10 +343,10 @@ void env_relocate_spec(void)
 		set_default_env("!bad env area");
 		goto done;
 	} else if (!read1_fail && read2_fail) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 		env_import((char *)tmp_env1, 1);
 	} else if (read1_fail && !read2_fail) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 		env_import((char *)tmp_env2, 1);
 	} else {
 		env_import_redund((char *)tmp_env1, (char *)tmp_env2);
env/nvram.c +1 -1
index 524f07d5f8..d046c9393c 100644
@@ -104,7 +104,7 @@ int env_init(void)
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr	= (ulong)&env_ptr->data;
 #endif
-		gd->env_valid	= 1;
+		gd->env_valid = ENV_VALID;
 	} else {
 		gd->env_addr	= (ulong)&default_environment[0];
 		gd->env_valid	= 0;
env/onenand.c +2 -2
index cc3d670de8..d7ad45a0e5 100644
@@ -60,7 +60,7 @@ void env_relocate_spec(void)
 
 	rc = env_import(buf, 1);
 	if (rc)
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 }
 
 int saveenv(void)
@@ -110,7 +110,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
env/remote.c +1 -1
index eb977ee1fe..e003e02fb9 100644
@@ -29,7 +29,7 @@ int env_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr = (ulong)&(env_ptr->data);
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 		return 0;
 	}
 
env/sata.c +1 -1
index b0cee35a60..64589117f2 100644
@@ -37,7 +37,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
env/sf.c +13 -13
index 45f441a042..1da3549138 100644
@@ -93,7 +93,7 @@ int saveenv(void)
 		return ret;
 	env_new.flags	= ACTIVE_FLAG;
 
-	if (gd->env_valid == 1) {
+	if (gd->env_valid == ENV_VALID) {
 		env_new_offset = CONFIG_ENV_OFFSET_REDUND;
 		env_offset = CONFIG_ENV_OFFSET;
 	} else {
@@ -145,7 +145,7 @@ int saveenv(void)
 
 	puts("done\n");
 
-	gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+	gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
 
 	printf("Valid environment: %d\n", (int)gd->env_valid);
 
@@ -198,30 +198,30 @@ void env_relocate_spec(void)
 		set_default_env("!bad CRC");
 		goto err_read;
 	} else if (crc1_ok && !crc2_ok) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (!crc1_ok && crc2_ok) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else if (tmp_env1->flags == ACTIVE_FLAG &&
 		   tmp_env2->flags == OBSOLETE_FLAG) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (tmp_env1->flags == OBSOLETE_FLAG &&
 		   tmp_env2->flags == ACTIVE_FLAG) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else if (tmp_env1->flags == tmp_env2->flags) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (tmp_env1->flags == 0xFF) {
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	} else if (tmp_env2->flags == 0xFF) {
-		gd->env_valid = 2;
+		gd->env_valid = ENV_REDUND;
 	} else {
 		/*
 		 * this differs from code in env_flash.c, but I think a sane
 		 * default path is desirable.
 		 */
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 	}
 
-	if (gd->env_valid == 1)
+	if (gd->env_valid == ENV_VALID)
 		ep = tmp_env1;
 	else
 		ep = tmp_env2;
@@ -324,7 +324,7 @@ void env_relocate_spec(void)
 
 	ret = env_import(buf, 1);
 	if (ret)
-		gd->env_valid = 1;
+		gd->env_valid = ENV_VALID;
 
 err_read:
 	spi_flash_free(env_flash);
@@ -338,7 +338,7 @@ int env_init(void)
 {
 	/* SPI flash isn't usable before relocation */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
env/ubi.c +3 -3
index 95b527ddca..542371df8f 100644
@@ -26,7 +26,7 @@ int env_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = 1;
+	gd->env_valid = ENV_VALID;
 
 	return 0;
 }
@@ -48,7 +48,7 @@ int saveenv(void)
 		return 1;
 	}
 
-	if (gd->env_valid == 1) {
+	if (gd->env_valid == ENV_VALID) {
 		puts("Writing to redundant UBI... ");
 		if (ubi_volume_write(CONFIG_ENV_UBI_VOLUME_REDUND,
 				     (void *)env_new, CONFIG_ENV_SIZE)) {
@@ -70,7 +70,7 @@ int saveenv(void)
 
 	puts("done\n");
 
-	gd->env_valid = gd->env_valid == 2 ? 1 : 2;
+	gd->env_valid = gd->env_valid == ENV_REDUND ? ENV_VALID : ENV_REDUND;
 
 	return 0;
 }
include/asm-generic/global_data.h +1 -1
index 86bf6565f6..8b32d514c3 100644
@@ -49,7 +49,7 @@ typedef struct global_data {
 	unsigned long precon_buf_idx;	/* Pre-Console buffer index */
 #endif
 	unsigned long env_addr;		/* Address  of Environment struct */
-	unsigned long env_valid;	/* Checksum of Environment valid? */
+	unsigned long env_valid;	/* Environment valid? enum env_valid */
 
 	unsigned long ram_top;		/* Top address of RAM used by U-Boot */
 	unsigned long relocaddr;	/* Start address of U-Boot in RAM */
include/environment.h +7 -0
index 5f2064bf23..ad2331c90b 100644
@@ -197,6 +197,13 @@ extern uint mmc_get_env_part(struct mmc *mmc);
 #include <env_flags.h>
 #include <search.h>
 
+/* Value for environment validity */
+enum env_valid {
+	ENV_INVALID,	/* No valid environment */
+	ENV_VALID,	/* First or only environment is valid */
+	ENV_REDUND,	/* Redundant environment is valid */
+};
+
 extern struct hsearch_data env_htab;
 
 /* Function that returns a character from the environment */
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#10 lore raw

PATCH v4 10/29 env: Rename nand env_location to nand_env_location

In reply to Simon Glass

We want to use this name for all environment drivers. Update the nand driver to use a more specific name.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/nand.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
env/nand.c +3 -3
index 90f274bf8a..d1b8b26999 100644
@@ -158,12 +158,12 @@ static int writeenv(size_t offset, u_char *buf)
 	return 0;
 }
 
-struct env_location {
+struct nand_env_location {
 	const char *name;
 	const nand_erase_options_t erase_opts;
 };
 
-static int erase_and_write_env(const struct env_location *location,
+static int erase_and_write_env(const struct nand_env_location *location,
 		u_char *env_new)
 {
 	struct mtd_info *mtd;
@@ -189,7 +189,7 @@ int saveenv(void)
 	int	ret = 0;
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int	env_idx = 0;
-	static const struct env_location location[] = {
+	static const struct nand_env_location location[] = {
 		{
 			.name = "NAND",
 			.erase_opts = {
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#11 lore raw

PATCH v4 11/29 env: Create a location driver for each location

In reply to Simon Glass

Set up a location driver for each supported environment location. At present this just points to the global functions and is not used. A later patch will switch this over to use private functions in each driver.

There are several special cases here in various drivers to handle peculiarities of certain boards:

1. Some boards define CONFIG_ENV_IS_IN_FAT and CONFIG_SPL_ENV_SUPPORT but do not actually load the environment in SPL. The env load code was optimised out before but with the driver, it is not. Therefore a special case is added to env/fat.c. The correct fix (depending on board testing might be to disable CONFIG_SPL_ENV_SUPPORT.

2. A similar situations happens with CONFIG_ENV_IS_IN_FLASH. Some boards do not actually load the environment in SPL, so to reduce code size we need to drop that code. A similar fix may be possible with these boards, or it may be possible to adjust the environment CONFIG settings.

Added to the above is that the CONFIG_SPL_ENV_SUPPORT option does not apply when the environment is in flash.

Obviously the above has been discovered through painful and time-consuming trial and error. Hopefully board maintainers can take a look and figure out what is actually needed.

---

Changes in v4:
- Update the commit message to comment on special cases

Changes in v3: None
Changes in v2:
- Add conditions for the am335x_hs_evm board with SPL

 env/dataflash.c       |  8 ++++++
 env/eeprom.c          |  8 ++++++
 env/ext4.c            |  8 ++++++
 env/fat.c             | 30 ++++++++++++++++++++--
 env/flash.c           | 39 +++++++++++++++++++++++++---
 env/mmc.c             | 10 ++++++++
 env/nand.c            | 12 ++++++++-
 env/nowhere.c         |  6 +++++
 env/nvram.c           | 10 ++++++++
 env/onenand.c         |  8 ++++++
 env/remote.c          |  8 ++++++
 env/sata.c            |  8 ++++++
 env/sf.c              | 20 +++++++++++++++
 env/ubi.c             |  8 ++++++
 include/environment.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 246 insertions(+), 7 deletions(-)
env/dataflash.c +8 -0
index c140b74c98..9c59d8e63a 100644
@@ -82,3 +82,11 @@ int env_init(void)
 
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(dataflash) = {
+	.location	= ENVL_DATAFLASH,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/eeprom.c +8 -0
index ac6b30fa8f..78569b286b 100644
@@ -243,3 +243,11 @@ int env_init(void)
 	gd->env_valid = ENV_VALID;
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(eeprom) = {
+	.location	= ENVL_EEPROM,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/ext4.c +8 -0
index 7bb4ce7cff..c6a84925d9 100644
@@ -127,3 +127,11 @@ void env_relocate_spec(void)
 err_env_relocate:
 	set_default_env(NULL);
 }
+
+U_BOOT_ENV_LOCATION(ext4) = {
+	.location	= ENVL_EXT4,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/fat.c +28 -2
index 5a2131a5a9..8f5fff81ad 100644
@@ -19,6 +19,18 @@
 #include <fat.h>
 #include <mmc.h>
 
+#ifdef CONFIG_SPL_BUILD
+/* TODO(sjg at chromium.org): Figure out why this is needed */
+# if !defined(CONFIG_TARGET_AM335X_EVM) || defined(CONFIG_SPL_OS_BOOT)
+#  define LOADENV
+# endif
+#else
+# define LOADENV
+# if defined(CONFIG_CMD_SAVEENV)
+#  define CMD_SAVEENV
+# endif
+#endif
+
 char *env_name_spec = "FAT";
 
 env_t *env_ptr;
@@ -34,7 +46,7 @@ int env_init(void)
 	return 0;
 }
 
-#ifdef CONFIG_CMD_SAVEENV
+#ifdef CMD_SAVEENV
 int saveenv(void)
 {
 	env_t	env_new;
@@ -72,8 +84,9 @@ int saveenv(void)
 	puts("done\n");
 	return 0;
 }
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CMD_SAVEENV */
 
+#ifdef LOADENV
 void env_relocate_spec(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -108,3 +121,16 @@ void env_relocate_spec(void)
 err_env_relocate:
 	set_default_env(NULL);
 }
+#endif /* LOADENV */
+
+U_BOOT_ENV_LOCATION(fat) = {
+	.location	= ENVL_FAT,
+	.get_char	= env_get_char_spec,
+#ifdef LOADENV
+	.load		= env_relocate_spec,
+#endif
+#ifdef CMD_SAVEENV
+	.save		= env_save_ptr(saveenv),
+#endif
+	.init		= env_init,
+};
env/flash.c +35 -4
index dcf3cd2c62..cf068d11ee 100644
@@ -20,10 +20,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
-#define CMD_SAVEENV
-#elif defined(CONFIG_ENV_ADDR_REDUND)
-#error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
+#ifndef CONFIG_SPL_BUILD
+# if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_FLASH)
+#  define CMD_SAVEENV
+# elif defined(CONFIG_ENV_ADDR_REDUND)
+#  error CONFIG_ENV_ADDR_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_FLASH
+# endif
 #endif
 
 #if defined(CONFIG_ENV_SIZE_REDUND) &&	\
@@ -31,6 +33,18 @@ DECLARE_GLOBAL_DATA_PTR;
 #error CONFIG_ENV_SIZE_REDUND should not be less then CONFIG_ENV_SIZE
 #endif
 
+/* TODO(sjg at chromium.org): Figure out all these special cases */
+#if (!defined(CONFIG_MICROBLAZE) && !defined(CONFIG_ARCH_ZYNQ) && \
+	!defined(CONFIG_TARGET_MCCMON6) && !defined(CONFIG_TARGET_X600) && \
+	!defined(CONFIG_TARGET_EDMINIV2)) || \
+	!defined(CONFIG_SPL_BUILD)
+#define LOADENV
+#endif
+
+#if !defined(CONFIG_TARGET_X600) || !defined(CONFIG_SPL_BUILD)
+#define INITENV
+#endif
+
 char *env_name_spec = "Flash";
 
 #ifdef ENV_IS_EMBEDDED
@@ -58,6 +72,7 @@ static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
 
 
 #ifdef CONFIG_ENV_ADDR_REDUND
+#ifdef INITENV
 int env_init(void)
 {
 	int crc1_ok = 0, crc2_ok = 0;
@@ -101,6 +116,7 @@ int env_init(void)
 
 	return 0;
 }
+#endif
 
 #ifdef CMD_SAVEENV
 int saveenv(void)
@@ -207,6 +223,7 @@ done:
 
 #else /* ! CONFIG_ENV_ADDR_REDUND */
 
+#ifdef INITENV
 int env_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
@@ -219,6 +236,7 @@ int env_init(void)
 	gd->env_valid	= 0;
 	return 0;
 }
+#endif
 
 #ifdef CMD_SAVEENV
 int saveenv(void)
@@ -336,3 +354,16 @@ void env_relocate_spec(void)
 
 	env_import((char *)flash_addr, 1);
 }
+
+U_BOOT_ENV_LOCATION(flash) = {
+	.location	= ENVL_FLASH,
+#ifdef LOADENV
+	.load		= env_relocate_spec,
+#endif
+#ifdef CMD_SAVEENV
+	.save		= env_save_ptr(saveenv),
+#endif
+#ifdef INITENV
+	.init		= env_init,
+#endif
+};
env/mmc.c +10 -0
index e387202e71..0d1e8077d3 100644
@@ -324,3 +324,13 @@ err:
 #endif
 }
 #endif /* CONFIG_ENV_OFFSET_REDUND */
+
+U_BOOT_ENV_LOCATION(mmc) = {
+	.location	= ENVL_MMC,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+#ifndef CONFIG_SPL_BUILD
+	.save		= env_save_ptr(saveenv),
+#endif
+	.init		= env_init,
+};
env/nand.c +11 -1
index d1b8b26999..07edabab79 100644
@@ -24,7 +24,8 @@
 #include <search.h>
 #include <errno.h>
 
-#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND)
+#if defined(CONFIG_CMD_SAVEENV) && defined(CONFIG_CMD_NAND) && \
+		!defined(CONFIG_SPL_BUILD)
 #define CMD_SAVEENV
 #elif defined(CONFIG_ENV_OFFSET_REDUND)
 #error CONFIG_ENV_OFFSET_REDUND must have CONFIG_CMD_SAVEENV & CONFIG_CMD_NAND
@@ -394,3 +395,12 @@ void env_relocate_spec(void)
 #endif /* ! ENV_IS_EMBEDDED */
 }
 #endif /* CONFIG_ENV_OFFSET_REDUND */
+
+U_BOOT_ENV_LOCATION(nand) = {
+	.location	= ENVL_NAND,
+	.load		= env_relocate_spec,
+#if defined(CMD_SAVEENV)
+	.save		= env_save_ptr(saveenv),
+#endif
+	.init		= env_init,
+};
env/nowhere.c +6 -0
index bdc1ed5e67..c58d299308 100644
@@ -33,3 +33,9 @@ int env_init(void)
 
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(nowhere) = {
+	.location	= ENVL_NOWHERE,
+	.load		= env_relocate_spec,
+	.init		= env_init,
+};
env/nvram.c +10 -0
index d046c9393c..4f45eae73e 100644
@@ -112,3 +112,13 @@ int env_init(void)
 
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(nvram) = {
+	.location	= ENVL_NVRAM,
+#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
+	.get_char	= env_get_char_spec,
+#endif
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/onenand.c +8 -0
index d7ad45a0e5..d4dfc02a46 100644
@@ -114,3 +114,11 @@ int env_init(void)
 
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(onenand) = {
+	.location	= ENVL_ONENAND,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/remote.c +8 -0
index e003e02fb9..c221d55c4f 100644
@@ -56,3 +56,11 @@ void env_relocate_spec(void)
 	env_import((char *)env_ptr, 1);
 #endif
 }
+
+U_BOOT_ENV_LOCATION(remote) = {
+	.location	= ENVL_REMOTE,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/sata.c +8 -0
index 64589117f2..f7b159a347 100644
@@ -125,3 +125,11 @@ void env_relocate_spec(void)
 
 	env_import(buf, 1);
 }
+
+U_BOOT_ENV_LOCATION(sata) = {
+	.location	= ENVL_ESATA,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
env/sf.c +20 -0
index 1da3549138..8f81cf5e40 100644
@@ -32,9 +32,15 @@
 # define CONFIG_ENV_SPI_MODE	CONFIG_SF_DEFAULT_MODE
 #endif
 
+#ifndef CONFIG_SPL_BUILD
+#define CMD_SAVEENV
+#endif
+
 #ifdef CONFIG_ENV_OFFSET_REDUND
+#ifdef CMD_SAVEENV
 static ulong env_offset		= CONFIG_ENV_OFFSET;
 static ulong env_new_offset	= CONFIG_ENV_OFFSET_REDUND;
+#endif
 
 #define ACTIVE_FLAG	1
 #define OBSOLETE_FLAG	0
@@ -77,6 +83,7 @@ static int setup_flash_device(void)
 }
 
 #if defined(CONFIG_ENV_OFFSET_REDUND)
+#ifdef CMD_SAVEENV
 int saveenv(void)
 {
 	env_t	env_new;
@@ -155,6 +162,7 @@ int saveenv(void)
 
 	return ret;
 }
+#endif /* CMD_SAVEENV */
 
 void env_relocate_spec(void)
 {
@@ -240,6 +248,7 @@ out:
 	free(tmp_env2);
 }
 #else
+#ifdef CMD_SAVEENV
 int saveenv(void)
 {
 	u32	saved_size, saved_offset, sector;
@@ -299,6 +308,7 @@ int saveenv(void)
 
 	return ret;
 }
+#endif /* CMD_SAVEENV */
 
 void env_relocate_spec(void)
 {
@@ -342,3 +352,13 @@ int env_init(void)
 
 	return 0;
 }
+
+U_BOOT_ENV_LOCATION(sf) = {
+	.location	= ENVL_SPI_FLASH,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+#ifdef CMD_SAVEENV
+	.save		= env_save_ptr(saveenv),
+#endif
+	.init		= env_init,
+};
env/ubi.c +8 -0
index 542371df8f..d91fdbaa4a 100644
@@ -177,3 +177,11 @@ void env_relocate_spec(void)
 	env_import(buf, 1);
 }
 #endif /* CONFIG_SYS_REDUNDAND_ENVIRONMENT */
+
+U_BOOT_ENV_LOCATION(ubi) = {
+	.location	= ENVL_UBI,
+	.get_char	= env_get_char_spec,
+	.load		= env_relocate_spec,
+	.save		= env_save_ptr(saveenv),
+	.init		= env_init,
+};
include/environment.h +70 -0

76 lines not on this page · raw message

Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#12 lore raw

PATCH v4 12/29 env: Add a new implementation of environment access

In reply to Simon Glass

We plan to move to a environment access via drivers for each location where the environment can be stored. Add an implementation for this. So far it is not used, but will be pressed into service in a future patch.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/Makefile |   2 +-
 env/env.c    | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100644 env/env.c
env/Makefile +1 -1
index 4c1bdcfdf4..8df5b9d4c9 100644
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y += common.o
+obj-y += common.o env.o
 
 ifndef CONFIG_SPL_BUILD
 obj-y += attr.o
env/env.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#13 lore raw

PATCH v4 13/29 env: Switch over to use environment location drivers

In reply to Simon Glass

Move over to use a the master implementation of the location drivers, with each method calling out to the appropriate driver.

---

Changes in v4:
- Adjust implementation of env_get_char_spec() to avoid recursion

Changes in v3: None
Changes in v2: None

 env/dataflash.c | 16 ++++++++--------
 env/eeprom.c    | 16 ++++++++--------
 env/env.c       | 20 ++++++++++++++++++++
 env/ext4.c      | 13 ++++++-------
 env/fat.c       | 13 ++++++-------
 env/flash.c     | 34 ++++++++++++++++++----------------
 env/mmc.c       | 19 +++++++++----------
 env/nand.c      | 14 +++++++-------
 env/nowhere.c   |  8 ++++----
 env/nvram.c     | 16 ++++++++--------
 env/onenand.c   | 13 ++++++-------
 env/remote.c    | 13 ++++++-------
 env/sata.c      | 13 ++++++-------
 env/sf.c        | 17 ++++++++---------
 env/ubi.c       | 17 ++++++++---------
 15 files changed, 128 insertions(+), 114 deletions(-)
env/dataflash.c +8 -8
index 9c59d8e63a..6d95d6409b 100644
@@ -18,7 +18,7 @@ env_t *env_ptr;
 
 char *env_name_spec = "dataflash";
 
-uchar env_get_char_spec(int index)
+static unsigned char env_dataflash_get_char(int index)
 {
 	uchar c;
 
@@ -27,7 +27,7 @@ uchar env_get_char_spec(int index)
 	return c;
 }
 
-void env_relocate_spec(void)
+static void env_dataflash_load(void)
 {
 	ulong crc, new = 0;
 	unsigned off;
@@ -54,7 +54,7 @@ void env_relocate_spec(void)
 #error No support for redundant environment on dataflash yet!
 #endif
 
-int saveenv(void)
+static int env_dataflash_save(void)
 {
 	env_t env_new;
 	int ret;
@@ -74,7 +74,7 @@ int saveenv(void)
  * We are still running from ROM, so data use is limited.
  * Use a (moderately small) buffer on the stack
  */
-int env_init(void)
+int env_dataflash_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -85,8 +85,8 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(dataflash) = {
 	.location	= ENVL_DATAFLASH,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.get_char	= env_dataflash_get_char,
+	.load		= env_dataflash_load,
+	.save		= env_save_ptr(env_dataflash_save),
+	.init		= env_dataflash_init,
 };
env/eeprom.c +8 -8
index 78569b286b..eb69f75f7b 100644
@@ -65,7 +65,7 @@ static int eeprom_bus_write(unsigned dev_addr, unsigned offset,
 	return rcode;
 }
 
-uchar env_get_char_spec(int index)
+static uchar env_eeprom_get_char(int index)
 {
 	uchar c;
 	unsigned int off = CONFIG_ENV_OFFSET;
@@ -80,7 +80,7 @@ uchar env_get_char_spec(int index)
 	return c;
 }
 
-void env_relocate_spec(void)
+static void env_eeprom_load(void)
 {
 	char buf_env[CONFIG_ENV_SIZE];
 	unsigned int off = CONFIG_ENV_OFFSET;
@@ -188,7 +188,7 @@ void env_relocate_spec(void)
 	env_import(buf_env, 1);
 }
 
-int saveenv(void)
+static int env_eeprom_save(void)
 {
 	env_t	env_new;
 	int	rc;
@@ -237,7 +237,7 @@ int saveenv(void)
  * We are still running from ROM, so data use is limited.
  * Use a (moderately small) buffer on the stack
  */
-int env_init(void)
+static int env_eeprom_init(void)
 {
 	gd->env_addr = (ulong)&default_environment[0];
 	gd->env_valid = ENV_VALID;
@@ -246,8 +246,8 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(eeprom) = {
 	.location	= ENVL_EEPROM,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.get_char	= env_eeprom_get_char,
+	.load		= env_eeprom_load,
+	.save		= env_save_ptr(env_eeprom_save),
+	.init		= env_eeprom_init,
 };
env/env.c +20 -0
index 9f0a04c33c..d327f9cdff 100644
@@ -143,3 +143,23 @@ int env_init_new(void)
 
 	return 0;
 }
+
+unsigned char env_get_char_spec(int index)
+{
+	return *(uchar *)(gd->env_addr + index);
+}
+
+void env_relocate_spec(void)
+{
+	env_load();
+}
+
+int saveenv(void)
+{
+	return env_save();
+}
+
+int env_init(void)
+{
+	return env_init_new();
+}
env/ext4.c +6 -7
index c6a84925d9..aa69219021 100644
@@ -37,7 +37,7 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
+static int env_ext4_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -47,7 +47,7 @@ int env_init(void)
 }
 
 #ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_ext4_save(void)
 {
 	env_t	env_new;
 	struct blk_desc *dev_desc = NULL;
@@ -88,7 +88,7 @@ int saveenv(void)
 }
 #endif /* CONFIG_CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static void env_ext4_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *dev_desc = NULL;
@@ -130,8 +130,7 @@ err_env_relocate:
 
 U_BOOT_ENV_LOCATION(ext4) = {
 	.location	= ENVL_EXT4,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.load		= env_ext4_load,
+	.save		= env_save_ptr(env_ext4_save),
+	.init		= env_ext4_init,
 };
env/fat.c +6 -7
index 8f5fff81ad..f7abfdb952 100644
@@ -37,7 +37,7 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
+static int env_fat_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -47,7 +47,7 @@ int env_init(void)
 }
 
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_fat_save(void)
 {
 	env_t	env_new;
 	struct blk_desc *dev_desc = NULL;
@@ -87,7 +87,7 @@ int saveenv(void)
 #endif /* CMD_SAVEENV */
 
 #ifdef LOADENV
-void env_relocate_spec(void)
+static void env_fat_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *dev_desc = NULL;
@@ -125,12 +125,11 @@ err_env_relocate:
 
 U_BOOT_ENV_LOCATION(fat) = {
 	.location	= ENVL_FAT,
-	.get_char	= env_get_char_spec,
 #ifdef LOADENV
-	.load		= env_relocate_spec,
+	.load		= env_fat_load,
 #endif
 #ifdef CMD_SAVEENV
-	.save		= env_save_ptr(saveenv),
+	.save		= env_save_ptr(env_fat_save),
 #endif
-	.init		= env_init,
+	.init		= env_fat_init,
 };
env/flash.c +18 -16
index cf068d11ee..6ec9b61883 100644
@@ -50,30 +50,30 @@ char *env_name_spec = "Flash";
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = &environment;
 
-static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
+static __maybe_unused env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
 
 #else /* ! ENV_IS_EMBEDDED */
 
 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
-static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
+static __maybe_unused env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
 #endif /* ENV_IS_EMBEDDED */
 
-#if defined(CMD_SAVEENV) || defined(CONFIG_ENV_ADDR_REDUND)
 /* CONFIG_ENV_ADDR is supposed to be on sector boundary */
-static ulong end_addr = CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1;
-#endif
+static ulong __maybe_unused end_addr =
+		CONFIG_ENV_ADDR + CONFIG_ENV_SECT_SIZE - 1;
 
 #ifdef CONFIG_ENV_ADDR_REDUND
-static env_t *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;
+
+static env_t __maybe_unused *flash_addr_new = (env_t *)CONFIG_ENV_ADDR_REDUND;
 
 /* CONFIG_ENV_ADDR_REDUND is supposed to be on sector boundary */
-static ulong end_addr_new = CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
+static ulong __maybe_unused end_addr_new =
+		CONFIG_ENV_ADDR_REDUND + CONFIG_ENV_SECT_SIZE - 1;
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
-
 #ifdef CONFIG_ENV_ADDR_REDUND
 #ifdef INITENV
-int env_init(void)
+static int env_flash_init(void)
 {
 	int crc1_ok = 0, crc2_ok = 0;
 
@@ -119,7 +119,7 @@ int env_init(void)
 #endif
 
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_flash_save(void)
 {
 	env_t	env_new;
 	char	*saved_data = NULL;
@@ -224,7 +224,7 @@ done:
 #else /* ! CONFIG_ENV_ADDR_REDUND */
 
 #ifdef INITENV
-int env_init(void)
+static int env_flash_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr	= (ulong)&(env_ptr->data);
@@ -239,7 +239,7 @@ int env_init(void)
 #endif
 
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_flash_save(void)
 {
 	env_t	env_new;
 	int	rc = 1;
@@ -309,7 +309,8 @@ done:
 
 #endif /* CONFIG_ENV_ADDR_REDUND */
 
-void env_relocate_spec(void)
+#ifdef LOADENV
+static void env_flash_load(void)
 {
 #ifdef CONFIG_ENV_ADDR_REDUND
 	if (gd->env_addr != (ulong)&(flash_addr->data)) {
@@ -354,16 +355,17 @@ void env_relocate_spec(void)
 
 	env_import((char *)flash_addr, 1);
 }
+#endif /* LOADENV */
 
 U_BOOT_ENV_LOCATION(flash) = {
 	.location	= ENVL_FLASH,
 #ifdef LOADENV
-	.load		= env_relocate_spec,
+	.load		= env_flash_load,
 #endif
 #ifdef CMD_SAVEENV
-	.save		= env_save_ptr(saveenv),
+	.save		= env_save_ptr(env_flash_save),
 #endif
 #ifdef INITENV
-	.init		= env_init,
+	.init		= env_flash_init,
 #endif
 };
env/mmc.c +9 -10
index 0d1e8077d3..d63feea2b8 100644
@@ -82,7 +82,7 @@ __weak int mmc_get_env_dev(void)
 	return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-int env_init(void)
+static int env_mmc_init(void)
 {
 	/* use default */
 	gd->env_addr	= (ulong)&default_environment[0];
@@ -145,7 +145,7 @@ static void fini_mmc_for_env(struct mmc *mmc)
 #endif
 }
 
-#ifdef CONFIG_CMD_SAVEENV
+#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_SPL_BUILD)
 static inline int write_env(struct mmc *mmc, unsigned long size,
 			    unsigned long offset, const void *buffer)
 {
@@ -160,7 +160,7 @@ static inline int write_env(struct mmc *mmc, unsigned long size,
 	return (n == blk_cnt) ? 0 : -1;
 }
 
-int saveenv(void)
+static int env_mmc_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int dev = mmc_get_env_dev();
@@ -207,7 +207,7 @@ fini:
 	fini_mmc_for_env(mmc);
 	return ret;
 }
-#endif /* CONFIG_CMD_SAVEENV */
+#endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */
 
 static inline int read_env(struct mmc *mmc, unsigned long size,
 			   unsigned long offset, const void *buffer)
@@ -224,7 +224,7 @@ static inline int read_env(struct mmc *mmc, unsigned long size,
 }
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-void env_relocate_spec(void)
+static void env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	struct mmc *mmc;
@@ -284,7 +284,7 @@ err:
 #endif
 }
 #else /* ! CONFIG_ENV_OFFSET_REDUND */
-void env_relocate_spec(void)
+static void env_mmc_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
@@ -327,10 +327,9 @@ err:
 
 U_BOOT_ENV_LOCATION(mmc) = {
 	.location	= ENVL_MMC,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
+	.load		= env_mmc_load,
 #ifndef CONFIG_SPL_BUILD
-	.save		= env_save_ptr(saveenv),
+	.save		= env_save_ptr(env_mmc_save),
 #endif
-	.init		= env_init,
+	.init		= env_mmc_init,
 };
env/nand.c +7 -7
index 07edabab79..596bdd3980 100644
@@ -64,7 +64,7 @@ DECLARE_GLOBAL_DATA_PTR;
  * This way the SPL loads not only the U-Boot image from NAND but
  * also the environment.
  */
-int env_init(void)
+static int env_nand_init(void)
 {
 #if defined(ENV_IS_EMBEDDED) || defined(CONFIG_NAND_ENV_DST)
 	int crc1_ok = 0, crc2_ok = 0;
@@ -185,7 +185,7 @@ static int erase_and_write_env(const struct nand_env_location *location,
 	return ret;
 }
 
-int saveenv(void)
+static int env_nand_save(void)
 {
 	int	ret = 0;
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
@@ -317,7 +317,7 @@ int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result)
 #endif
 
 #ifdef CONFIG_ENV_OFFSET_REDUND
-void env_relocate_spec(void)
+static void env_nand_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	int read1_fail = 0, read2_fail = 0;
@@ -365,7 +365,7 @@ done:
  * device i.e., nand_dev_desc + 0. This is also the behaviour using
  * the new NAND code.
  */
-void env_relocate_spec(void)
+static void env_nand_load(void)
 {
 #if !defined(ENV_IS_EMBEDDED)
 	int ret;
@@ -398,9 +398,9 @@ void env_relocate_spec(void)
 
 U_BOOT_ENV_LOCATION(nand) = {
 	.location	= ENVL_NAND,
-	.load		= env_relocate_spec,
+	.load		= env_nand_load,
 #if defined(CMD_SAVEENV)
-	.save		= env_save_ptr(saveenv),
+	.save		= env_save_ptr(env_nand_save),
 #endif
-	.init		= env_init,
+	.init		= env_nand_init,
 };
env/nowhere.c +4 -4
index c58d299308..6a67ab09ff 100644
@@ -17,7 +17,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 env_t *env_ptr;
 
-void env_relocate_spec(void)
+static void env_nowhere_load(void)
 {
 }
 
@@ -26,7 +26,7 @@ void env_relocate_spec(void)
  *
  * We are still running from ROM, so data use is limited
  */
-int env_init(void)
+static int env_nowhere_init(void)
 {
 	gd->env_addr	= (ulong)&default_environment[0];
 	gd->env_valid	= 0;
@@ -36,6 +36,6 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(nowhere) = {
 	.location	= ENVL_NOWHERE,
-	.load		= env_relocate_spec,
-	.init		= env_init,
+	.load		= env_nowhere_load,
+	.init		= env_nowhere_init,
 };
env/nvram.c +8 -8
index 4f45eae73e..09091b8eb7 100644
@@ -44,7 +44,7 @@ env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 char *env_name_spec = "NVRAM";
 
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-uchar env_get_char_spec(int index)
+static uchar env_nvram_get_char(int index)
 {
 	uchar c;
 
@@ -54,7 +54,7 @@ uchar env_get_char_spec(int index)
 }
 #endif
 
-void env_relocate_spec(void)
+static void env_nvram_load(void)
 {
 	char buf[CONFIG_ENV_SIZE];
 
@@ -66,7 +66,7 @@ void env_relocate_spec(void)
 	env_import(buf, 1);
 }
 
-int saveenv(void)
+static int env_nvram_save(void)
 {
 	env_t	env_new;
 	int	rcode = 0;
@@ -89,7 +89,7 @@ int saveenv(void)
  *
  * We are still running from ROM, so data use is limited
  */
-int env_init(void)
+static int env_nvram_init(void)
 {
 #if defined(CONFIG_SYS_NVRAM_ACCESS_ROUTINE)
 	ulong crc;
@@ -116,9 +116,9 @@ int env_init(void)
 U_BOOT_ENV_LOCATION(nvram) = {
 	.location	= ENVL_NVRAM,
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
-	.get_char	= env_get_char_spec,
+	.get_char	= env_nvram_get_char,
 #endif
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.load		= env_nvram_load,
+	.save		= env_save_ptr(env_nvram_save),
+	.init		= env_nvram_init,
 };
env/onenand.c +6 -7
index d4dfc02a46..f72aa4b036 100644
@@ -28,7 +28,7 @@ char *env_name_spec = "OneNAND";
 
 DECLARE_GLOBAL_DATA_PTR;
 
-void env_relocate_spec(void)
+static void env_onenand_load(void)
 {
 	struct mtd_info *mtd = &onenand_mtd;
 #ifdef CONFIG_ENV_ADDR_FLEX
@@ -63,7 +63,7 @@ void env_relocate_spec(void)
 		gd->env_valid = ENV_VALID;
 }
 
-int saveenv(void)
+static int env_onenand_save(void)
 {
 	env_t	env_new;
 	int ret;
@@ -106,7 +106,7 @@ int saveenv(void)
 	return 0;
 }
 
-int env_init(void)
+static int env_onenand_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -117,8 +117,7 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(onenand) = {
 	.location	= ENVL_ONENAND,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.load		= env_onenand_load,
+	.save		= env_save_ptr(env_onenand_save),
+	.init		= env_onenand_init,
 };
env/remote.c +6 -7
index c221d55c4f..0324cba099 100644
@@ -25,7 +25,7 @@ DECLARE_GLOBAL_DATA_PTR;
 #define CONFIG_ENV_OFFSET 0
 #endif
 
-int env_init(void)
+static int env_remote_init(void)
 {
 	if (crc32(0, env_ptr->data, ENV_SIZE) == env_ptr->crc) {
 		gd->env_addr = (ulong)&(env_ptr->data);
@@ -39,7 +39,7 @@ int env_init(void)
 }
 
 #ifdef CONFIG_CMD_SAVEENV
-int saveenv(void)
+static int env_remote_save(void)
 {
 #ifdef CONFIG_SRIO_PCIE_BOOT_SLAVE
 	printf("Can not support the 'saveenv' when boot from SRIO or PCIE!\n");
@@ -50,7 +50,7 @@ int saveenv(void)
 }
 #endif /* CONFIG_CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static void env_remote_load(void)
 {
 #ifndef ENV_IS_EMBEDDED
 	env_import((char *)env_ptr, 1);
@@ -59,8 +59,7 @@ void env_relocate_spec(void)
 
 U_BOOT_ENV_LOCATION(remote) = {
 	.location	= ENVL_REMOTE,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.load		= env_remote_load,
+	.save		= env_save_ptr(env_remote_save),
+	.init		= env_remote_init,
 };
env/sata.c +6 -7
index f7b159a347..6f9099873d 100644
@@ -33,7 +33,7 @@ __weak int sata_get_env_dev(void)
 	return CONFIG_SYS_SATA_ENV_DEV;
 }
 
-int env_init(void)
+static int env_sata_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -56,7 +56,7 @@ static inline int write_env(struct blk_desc *sata, unsigned long size,
 	return (n == blk_cnt) ? 0 : -1;
 }
 
-int saveenv(void)
+static int env_sata_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	struct blk_desc *sata = NULL;
@@ -102,7 +102,7 @@ static inline int read_env(struct blk_desc *sata, unsigned long size,
 	return (n == blk_cnt) ? 0 : -1;
 }
 
-void env_relocate_spec(void)
+static void env_sata_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 	struct blk_desc *sata = NULL;
@@ -128,8 +128,7 @@ void env_relocate_spec(void)
 
 U_BOOT_ENV_LOCATION(sata) = {
 	.location	= ENVL_ESATA,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.load		= env_sata_load,
+	.save		= env_save_ptr(env_sata_save),
+	.init		= env_sata_init,
 };
env/sf.c +8 -9
index 8f81cf5e40..82babaab67 100644
@@ -84,7 +84,7 @@ static int setup_flash_device(void)
 
 #if defined(CONFIG_ENV_OFFSET_REDUND)
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_sf_save(void)
 {
 	env_t	env_new;
 	char	*saved_buffer = NULL, flag = OBSOLETE_FLAG;
@@ -164,7 +164,7 @@ int saveenv(void)
 }
 #endif /* CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static void env_sf_load(void)
 {
 	int ret;
 	int crc1_ok = 0, crc2_ok = 0;
@@ -249,7 +249,7 @@ out:
 }
 #else
 #ifdef CMD_SAVEENV
-int saveenv(void)
+static int env_sf_save(void)
 {
 	u32	saved_size, saved_offset, sector;
 	char	*saved_buffer = NULL;
@@ -310,7 +310,7 @@ int saveenv(void)
 }
 #endif /* CMD_SAVEENV */
 
-void env_relocate_spec(void)
+static void env_sf_load(void)
 {
 	int ret;
 	char *buf = NULL;
@@ -344,7 +344,7 @@ out:
 }
 #endif
 
-int env_init(void)
+static int env_sf_init(void)
 {
 	/* SPI flash isn't usable before relocation */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -355,10 +355,9 @@ int env_init(void)
 
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
+	.load		= env_sf_load,
 #ifdef CMD_SAVEENV
-	.save		= env_save_ptr(saveenv),
+	.save		= env_save_ptr(env_sf_save),
 #endif
-	.init		= env_init,
+	.init		= env_sf_init,
 };
env/ubi.c +8 -9
index d91fdbaa4a..3b6344df7a 100644
@@ -22,7 +22,7 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-int env_init(void)
+static int env_ubi_init(void)
 {
 	/* use default */
 	gd->env_addr = (ulong)&default_environment[0];
@@ -33,7 +33,7 @@ int env_init(void)
 
 #ifdef CONFIG_CMD_SAVEENV
 #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-int saveenv(void)
+static int env_ubi_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int ret;
@@ -75,7 +75,7 @@ int saveenv(void)
 	return 0;
 }
 #else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-int saveenv(void)
+static int env_ubi_save(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
 	int ret;
@@ -104,7 +104,7 @@ int saveenv(void)
 #endif /* CONFIG_CMD_SAVEENV */
 
 #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
-void env_relocate_spec(void)
+static void env_ubi_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, env1_buf, CONFIG_ENV_SIZE);
 	ALLOC_CACHE_ALIGN_BUFFER(char, env2_buf, CONFIG_ENV_SIZE);
@@ -146,7 +146,7 @@ void env_relocate_spec(void)
 	env_import_redund((char *)tmp_env1, (char *)tmp_env2);
 }
 #else /* ! CONFIG_SYS_REDUNDAND_ENVIRONMENT */
-void env_relocate_spec(void)
+static void env_ubi_load(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(char, buf, CONFIG_ENV_SIZE);
 
@@ -180,8 +180,7 @@ void env_relocate_spec(void)
 
 U_BOOT_ENV_LOCATION(ubi) = {
 	.location	= ENVL_UBI,
-	.get_char	= env_get_char_spec,
-	.load		= env_relocate_spec,
-	.save		= env_save_ptr(saveenv),
-	.init		= env_init,
+	.load		= env_ubi_load,
+	.save		= env_save_ptr(env_ubi_save),
+	.init		= env_ubi_init,
 };
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#14 lore raw

PATCH v4 14/29 env: Drop common init() functions

In reply to Simon Glass

Most of the init() implementations just use the default environment. Adjust env_init_new() to do this automatically, and drop the redundant code.

---

Changes in v4:
- Fix incorrect setting of env_valid in env_init_new()

Changes in v3: None
Changes in v2: None

 env/dataflash.c       | 16 ----------------
 env/eeprom.c          | 14 --------------
 env/env.c             | 14 +++++++++-----
 env/ext4.c            | 10 ----------
 env/fat.c             | 10 ----------
 env/mmc.c             | 10 ----------
 env/nowhere.c         | 19 -------------------
 env/onenand.c         | 10 ----------
 env/remote.c          |  4 +---
 env/sata.c            | 10 ----------
 env/sf.c              | 10 ----------
 env/ubi.c             | 10 ----------
 include/environment.h |  3 ++-
 13 files changed, 12 insertions(+), 128 deletions(-)
env/dataflash.c +0 -16
index 6d95d6409b..8ab482b3b4 100644
@@ -68,25 +68,9 @@ static int env_dataflash_save(void)
 				CONFIG_ENV_SIZE);
 }
 
-/*
- * Initialize environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-int env_dataflash_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 U_BOOT_ENV_LOCATION(dataflash) = {
 	.location	= ENVL_DATAFLASH,
 	.get_char	= env_dataflash_get_char,
 	.load		= env_dataflash_load,
 	.save		= env_save_ptr(env_dataflash_save),
-	.init		= env_dataflash_init,
 };
env/eeprom.c +0 -14
index eb69f75f7b..3cc412620a 100644
@@ -231,23 +231,9 @@ static int env_eeprom_save(void)
 	return rc;
 }
 
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited.
- * Use a (moderately small) buffer on the stack
- */
-static int env_eeprom_init(void)
-{
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-	return 0;
-}
-
 U_BOOT_ENV_LOCATION(eeprom) = {
 	.location	= ENVL_EEPROM,
 	.get_char	= env_eeprom_get_char,
 	.load		= env_eeprom_load,
 	.save		= env_save_ptr(env_eeprom_save),
-	.init		= env_eeprom_init,
 };
env/env.c +9 -5
index d327f9cdff..12cd4750df 100644
@@ -128,14 +128,18 @@ int env_save(void)
 int env_init_new(void)
 {
 	struct env_driver *drv = env_driver_lookup_default();
-	int ret;
+	int ret = -ENOENT;
 
 	if (!drv)
 		return -ENODEV;
-	if (!drv->init)
-		return -ENOSYS;
-	ret = drv->init();
-	if (ret) {
+	if (drv->init)
+		ret = drv->init();
+	if (ret == -ENOENT) {
+		gd->env_addr = (ulong)&default_environment[0];
+		gd->env_valid = 0;
+
+		return 0;
+	} else if (ret) {
 		debug("%s: Environment failed to init (err=%d)\n", __func__,
 		      ret);
 		return ret;
env/ext4.c +0 -10
index aa69219021..25a5cbecdd 100644
@@ -37,15 +37,6 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int env_ext4_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
 static int env_ext4_save(void)
 {
@@ -132,5 +123,4 @@ U_BOOT_ENV_LOCATION(ext4) = {
 	.location	= ENVL_EXT4,
 	.load		= env_ext4_load,
 	.save		= env_save_ptr(env_ext4_save),
-	.init		= env_ext4_init,
 };
env/fat.c +0 -10
index f7abfdb952..bd31b2904d 100644
@@ -37,15 +37,6 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int env_fat_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 #ifdef CMD_SAVEENV
 static int env_fat_save(void)
 {
@@ -131,5 +122,4 @@ U_BOOT_ENV_LOCATION(fat) = {
 #ifdef CMD_SAVEENV
 	.save		= env_save_ptr(env_fat_save),
 #endif
-	.init		= env_fat_init,
 };
env/mmc.c +0 -10
index d63feea2b8..966f620653 100644
@@ -82,15 +82,6 @@ __weak int mmc_get_env_dev(void)
 	return CONFIG_SYS_MMC_ENV_DEV;
 }
 
-static int env_mmc_init(void)
-{
-	/* use default */
-	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= ENV_VALID;
-
-	return 0;
-}
-
 #ifdef CONFIG_SYS_MMC_ENV_PART
 __weak uint mmc_get_env_part(struct mmc *mmc)
 {
@@ -331,5 +322,4 @@ U_BOOT_ENV_LOCATION(mmc) = {
 #ifndef CONFIG_SPL_BUILD
 	.save		= env_save_ptr(env_mmc_save),
 #endif
-	.init		= env_mmc_init,
 };
env/nowhere.c +0 -19
index 6a67ab09ff..1d2ae85a57 100644
@@ -17,25 +17,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 env_t *env_ptr;
 
-static void env_nowhere_load(void)
-{
-}
-
-/*
- * Initialize Environment use
- *
- * We are still running from ROM, so data use is limited
- */
-static int env_nowhere_init(void)
-{
-	gd->env_addr	= (ulong)&default_environment[0];
-	gd->env_valid	= 0;
-
-	return 0;
-}
-
 U_BOOT_ENV_LOCATION(nowhere) = {
 	.location	= ENVL_NOWHERE,
-	.load		= env_nowhere_load,
-	.init		= env_nowhere_init,
 };
env/onenand.c +0 -10
index f72aa4b036..cb1ab53216 100644
@@ -106,18 +106,8 @@ static int env_onenand_save(void)
 	return 0;
 }
 
-static int env_onenand_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 U_BOOT_ENV_LOCATION(onenand) = {
 	.location	= ENVL_ONENAND,
 	.load		= env_onenand_load,
 	.save		= env_save_ptr(env_onenand_save),
-	.init		= env_onenand_init,
 };
env/remote.c +1 -3
index 0324cba099..c5dce5b966 100644
@@ -33,9 +33,7 @@ static int env_remote_init(void)
 		return 0;
 	}
 
-	gd->env_addr = (ulong)default_environment;
-	gd->env_valid = 0;
-	return 0;
+	return -ENOENT;
 }
 
 #ifdef CONFIG_CMD_SAVEENV
env/sata.c +0 -10
index 6f9099873d..a5ff54c287 100644
@@ -33,15 +33,6 @@ __weak int sata_get_env_dev(void)
 	return CONFIG_SYS_SATA_ENV_DEV;
 }
 
-static int env_sata_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
 static inline int write_env(struct blk_desc *sata, unsigned long size,
 			    unsigned long offset, void *buffer)
@@ -130,5 +121,4 @@ U_BOOT_ENV_LOCATION(sata) = {
 	.location	= ENVL_ESATA,
 	.load		= env_sata_load,
 	.save		= env_save_ptr(env_sata_save),
-	.init		= env_sata_init,
 };
env/sf.c +0 -10
index 82babaab67..a07641b7d4 100644
@@ -344,20 +344,10 @@ out:
 }
 #endif
 
-static int env_sf_init(void)
-{
-	/* SPI flash isn't usable before relocation */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
 	.load		= env_sf_load,
 #ifdef CMD_SAVEENV
 	.save		= env_save_ptr(env_sf_save),
 #endif
-	.init		= env_sf_init,
 };
env/ubi.c +0 -10
index 3b6344df7a..4811f97413 100644
@@ -22,15 +22,6 @@ env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int env_ubi_init(void)
-{
-	/* use default */
-	gd->env_addr = (ulong)&default_environment[0];
-	gd->env_valid = ENV_VALID;
-
-	return 0;
-}
-
 #ifdef CONFIG_CMD_SAVEENV
 #ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT
 static int env_ubi_save(void)
@@ -182,5 +173,4 @@ U_BOOT_ENV_LOCATION(ubi) = {
 	.location	= ENVL_UBI,
 	.load		= env_ubi_load,
 	.save		= env_save_ptr(env_ubi_save),
-	.init		= env_ubi_init,
 };
include/environment.h +2 -1
index ff3f54263a..7eaba72181 100644
@@ -259,7 +259,8 @@ struct env_driver {
 	 *
 	 * This method is optional.
 	 *
-	 * @return 0 if OK, -ve on error
+	 * @return 0 if OK, -ENOENT if no initial environment could be found,
+	 * other -ve on error
 	 */
 	int (*init)(void);
 };
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#15 lore raw

PATCH v4 15/29 env: Drop the env_name_spec global

In reply to Simon Glass

Add a name to the driver and use that instead of the global variable declared by each driver.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 cmd/nvedit.c          |  4 +++-
 env/dataflash.c       |  3 +--
 env/eeprom.c          |  3 +--
 env/env.c             |  2 +-
 env/ext4.c            |  3 +--
 env/fat.c             |  3 +--
 env/flash.c           |  3 +--
 env/mmc.c             |  3 +--
 env/nand.c            |  3 +--
 env/nowhere.c         |  1 +
 env/nvram.c           |  3 +--
 env/onenand.c         |  3 +--
 env/remote.c          |  3 +--
 env/sata.c            |  3 +--
 env/sf.c              |  3 +--
 env/ubi.c             |  2 --
 include/environment.h | 19 +++++++++++++++----
 17 files changed, 32 insertions(+), 32 deletions(-)
cmd/nvedit.c +3 -1
index cd17db6409..75df997592 100644
@@ -706,7 +706,9 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
 {
-	printf("Saving Environment to %s...\n", env_name_spec);
+	struct env_driver *env = env_driver_lookup_default();
+
+	printf("Saving Environment to %s...\n", env->name);
 
 	return saveenv() ? 1 : 0;
 }
env/dataflash.c +1 -2
index 8ab482b3b4..9421a6a5b2 100644
@@ -16,8 +16,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 env_t *env_ptr;
 
-char *env_name_spec = "dataflash";
-
 static unsigned char env_dataflash_get_char(int index)
 {
 	uchar c;
@@ -70,6 +68,7 @@ static int env_dataflash_save(void)
 
 U_BOOT_ENV_LOCATION(dataflash) = {
 	.location	= ENVL_DATAFLASH,
+	ENV_NAME("dataflash")
 	.get_char	= env_dataflash_get_char,
 	.load		= env_dataflash_load,
 	.save		= env_save_ptr(env_dataflash_save),
env/eeprom.c +1 -2
index 3cc412620a..2c795b9236 100644
@@ -23,8 +23,6 @@ DECLARE_GLOBAL_DATA_PTR;
 
 env_t *env_ptr;
 
-char *env_name_spec = "EEPROM";
-
 static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
 			   uchar *buffer, unsigned cnt)
 {
@@ -233,6 +231,7 @@ static int env_eeprom_save(void)
 
 U_BOOT_ENV_LOCATION(eeprom) = {
 	.location	= ENVL_EEPROM,
+	ENV_NAME("EEPROM")
 	.get_char	= env_eeprom_get_char,
 	.load		= env_eeprom_load,
 	.save		= env_save_ptr(env_eeprom_save),
env/env.c +1 -1
index 12cd4750df..53a085c431 100644
@@ -54,7 +54,7 @@ static enum env_location env_get_default_location(void)
 		return ENVL_UNKNOWN;
 }
 
-static struct env_driver *env_driver_lookup_default(void)
+struct env_driver *env_driver_lookup_default(void)
 {
 	enum env_location loc = env_get_default_location();
 	struct env_driver *drv;
env/ext4.c +1 -2
index 25a5cbecdd..5acdf0eda0 100644
@@ -31,8 +31,6 @@
 #include <ext4fs.h>
 #include <mmc.h>
 
-char *env_name_spec = "EXT4";
-
 env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -121,6 +119,7 @@ err_env_relocate:
 
 U_BOOT_ENV_LOCATION(ext4) = {
 	.location	= ENVL_EXT4,
+	ENV_NAME("EXT4")
 	.load		= env_ext4_load,
 	.save		= env_save_ptr(env_ext4_save),
 };
env/fat.c +1 -2
index bd31b2904d..ad0c4321c7 100644
@@ -31,8 +31,6 @@
 # endif
 #endif
 
-char *env_name_spec = "FAT";
-
 env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -116,6 +114,7 @@ err_env_relocate:
 
 U_BOOT_ENV_LOCATION(fat) = {
 	.location	= ENVL_FAT,
+	ENV_NAME("FAT")
 #ifdef LOADENV
 	.load		= env_fat_load,
 #endif
env/flash.c +1 -2
index 6ec9b61883..2d72c51622 100644
@@ -45,8 +45,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #define INITENV
 #endif
 
-char *env_name_spec = "Flash";
-
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = &environment;
 
@@ -359,6 +357,7 @@ static void env_flash_load(void)
 
 U_BOOT_ENV_LOCATION(flash) = {
 	.location	= ENVL_FLASH,
+	ENV_NAME("Flash")
 #ifdef LOADENV
 	.load		= env_flash_load,
 #endif
env/mmc.c +1 -2
index 966f620653..18da6dc58c 100644
@@ -23,8 +23,6 @@
 #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
 #endif
 
-char *env_name_spec = "MMC";
-
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = &environment;
 #else /* ! ENV_IS_EMBEDDED */
@@ -318,6 +316,7 @@ err:
 
 U_BOOT_ENV_LOCATION(mmc) = {
 	.location	= ENVL_MMC,
+	ENV_NAME("MMC")
 	.load		= env_mmc_load,
 #ifndef CONFIG_SPL_BUILD
 	.save		= env_save_ptr(env_mmc_save),
env/nand.c +1 -2
index 596bdd3980..e74a8c674e 100644
@@ -40,8 +40,6 @@
 #define CONFIG_ENV_RANGE	CONFIG_ENV_SIZE
 #endif
 
-char *env_name_spec = "NAND";
-
 #if defined(ENV_IS_EMBEDDED)
 env_t *env_ptr = &environment;
 #elif defined(CONFIG_NAND_ENV_DST)
@@ -398,6 +396,7 @@ static void env_nand_load(void)
 
 U_BOOT_ENV_LOCATION(nand) = {
 	.location	= ENVL_NAND,
+	ENV_NAME("NAND")
 	.load		= env_nand_load,
 #if defined(CMD_SAVEENV)
 	.save		= env_save_ptr(env_nand_save),
env/nowhere.c +1 -0
index 1d2ae85a57..1a17d6978b 100644
@@ -19,4 +19,5 @@ env_t *env_ptr;
 
 U_BOOT_ENV_LOCATION(nowhere) = {
 	.location	= ENVL_NOWHERE,
+	ENV_NAME("nowhere")
 };
env/nvram.c +1 -2
index 09091b8eb7..0f4b491fd3 100644
@@ -41,8 +41,6 @@ env_t *env_ptr;
 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 #endif
 
-char *env_name_spec = "NVRAM";
-
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
 static uchar env_nvram_get_char(int index)
 {
@@ -115,6 +113,7 @@ static int env_nvram_init(void)
 
 U_BOOT_ENV_LOCATION(nvram) = {
 	.location	= ENVL_NVRAM,
+	ENV_NAME("NVRAM")
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
 	.get_char	= env_nvram_get_char,
 #endif
env/onenand.c +1 -2
index cb1ab53216..319f553262 100644
@@ -21,8 +21,6 @@
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/onenand.h>
 
-char *env_name_spec = "OneNAND";
-
 #define ONENAND_MAX_ENV_SIZE	CONFIG_ENV_SIZE
 #define ONENAND_ENV_SIZE(mtd)	(ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
 
@@ -108,6 +106,7 @@ static int env_onenand_save(void)
 
 U_BOOT_ENV_LOCATION(onenand) = {
 	.location	= ENVL_ONENAND,
+	ENV_NAME("OneNAND")
 	.load		= env_onenand_load,
 	.save		= env_save_ptr(env_onenand_save),
 };
env/remote.c +1 -2
index c5dce5b966..0d8865bd67 100644
@@ -11,8 +11,6 @@
 #include <environment.h>
 #include <linux/stddef.h>
 
-char *env_name_spec = "Remote";
-
 #ifdef ENV_IS_EMBEDDED
 env_t *env_ptr = &environment;
 #else /* ! ENV_IS_EMBEDDED */
@@ -57,6 +55,7 @@ static void env_remote_load(void)
 
 U_BOOT_ENV_LOCATION(remote) = {
 	.location	= ENVL_REMOTE,
+	ENV_NAME("Remote")
 	.load		= env_remote_load,
 	.save		= env_save_ptr(env_remote_save),
 	.init		= env_remote_init,
env/sata.c +1 -2
index a5ff54c287..16d8f939db 100644
@@ -24,8 +24,6 @@
 #error CONFIG_ENV_OFFSET or CONFIG_ENV_SIZE not defined
 #endif
 
-char *env_name_spec = "SATA";
-
 DECLARE_GLOBAL_DATA_PTR;
 
 __weak int sata_get_env_dev(void)
@@ -119,6 +117,7 @@ static void env_sata_load(void)
 
 U_BOOT_ENV_LOCATION(sata) = {
 	.location	= ENVL_ESATA,
+	ENV_NAME("SATA")
 	.load		= env_sata_load,
 	.save		= env_save_ptr(env_sata_save),
 };
env/sf.c +1 -2
index a07641b7d4..07386c629a 100644
@@ -48,8 +48,6 @@ static ulong env_new_offset	= CONFIG_ENV_OFFSET_REDUND;
 
 DECLARE_GLOBAL_DATA_PTR;
 
-char *env_name_spec = "SPI Flash";
-
 static struct spi_flash *env_flash;
 
 static int setup_flash_device(void)
@@ -346,6 +344,7 @@ out:
 
 U_BOOT_ENV_LOCATION(sf) = {
 	.location	= ENVL_SPI_FLASH,
+	ENV_NAME("SPI Flash")
 	.load		= env_sf_load,
 #ifdef CMD_SAVEENV
 	.save		= env_save_ptr(env_sf_save),
env/ubi.c +0 -2
index 4811f97413..4d5ae1343d 100644
@@ -16,8 +16,6 @@
 #include <ubi_uboot.h>
 #undef crc32
 
-char *env_name_spec = "UBI";
-
 env_t *env_ptr;
 
 DECLARE_GLOBAL_DATA_PTR;
include/environment.h +15 -4
index 7eaba72181..584fd7216d 100644
@@ -143,10 +143,6 @@ extern unsigned long nand_env_oob_offset;
 # define ENV_HEADER_SIZE	(sizeof(uint32_t))
 #endif
 
-#if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-extern char *env_name_spec;
-#endif
-
 #ifdef CONFIG_ENV_AES
 /* Make sure the payload is multiple of AES block size */
 #define ENV_SIZE ((CONFIG_ENV_SIZE - ENV_HEADER_SIZE) & ~(16 - 1))
@@ -224,6 +220,7 @@ enum env_location {
 };
 
 struct env_driver {
+	const char *name;
 	enum env_location location;
 
 	/**
@@ -269,6 +266,13 @@ struct env_driver {
 #define U_BOOT_ENV_LOCATION(__name)					\
 	ll_entry_declare(struct env_driver, __name, env_driver)
 
+/* Declare the name of a location */
+#ifdef CONFIG_CMD_SAVEENV
+#define ENV_NAME(_name) .name = _name,
+#else
+#define ENV_NAME(_name)
+#endif
+
 #ifdef CONFIG_CMD_SAVEENV
 #define env_save_ptr(x) x
 #else
@@ -303,6 +307,13 @@ int env_export(env_t *env_out);
 int env_import_redund(const char *buf1, const char *buf2);
 #endif
 
+/**
+ * env_driver_lookup_default() - Look up the default environment driver
+ *
+ * @return pointer to driver, or NULL if none (which should not happen)
+ */
+struct env_driver *env_driver_lookup_default(void);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#16 lore raw

PATCH v4 16/29 env: Drop unused env_ptr variables

In reply to Simon Glass

This variable is declared as a global in most environment location drivers. But it is not used outside the drivers and most of the declarations are unnecessary.

Also some drivers call free() on env_ptr which seems wrong since it is not in the heap.

Drop the variable where possible, and all calls to free().

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/dataflash.c | 2 --
 env/eeprom.c    | 4 ----
 env/ext4.c      | 2 --
 env/fat.c       | 2 --
 env/mmc.c       | 6 ------
 env/nowhere.c   | 2 --
 env/nvram.c     | 1 -
 env/ubi.c       | 2 --
 8 files changed, 21 deletions(-)
env/dataflash.c +0 -2
index 9421a6a5b2..28dcf6fa1c 100644
@@ -14,8 +14,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
 static unsigned char env_dataflash_get_char(int index)
 {
 	uchar c;
env/eeprom.c +0 -4
index 2c795b9236..39adccabbe 100644
@@ -21,8 +21,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
 static int eeprom_bus_read(unsigned dev_addr, unsigned offset,
 			   uchar *buffer, unsigned cnt)
 {
@@ -196,8 +194,6 @@ static int env_eeprom_save(void)
 	char flag_obsolete	= OBSOLETE_FLAG;
 #endif
 
-	BUG_ON(env_ptr != NULL);
-
 	rc = env_export(&env_new);
 	if (rc)
 		return rc;
env/ext4.c +0 -2
index 5acdf0eda0..ee073a8b7c 100644
@@ -31,8 +31,6 @@
 #include <ext4fs.h>
 #include <mmc.h>
 
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_CMD_SAVEENV
env/fat.c +0 -2
index ad0c4321c7..69319f8834 100644
@@ -31,8 +31,6 @@
 # endif
 #endif
 
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CMD_SAVEENV
env/mmc.c +0 -6
index 18da6dc58c..88ffc91f0b 100644
@@ -23,12 +23,6 @@
 #error CONFIG_ENV_SIZE_REDUND should be the same as CONFIG_ENV_SIZE
 #endif
 
-#ifdef ENV_IS_EMBEDDED
-env_t *env_ptr = &environment;
-#else /* ! ENV_IS_EMBEDDED */
-env_t *env_ptr;
-#endif /* ENV_IS_EMBEDDED */
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #if !defined(CONFIG_ENV_OFFSET)
env/nowhere.c +0 -2
index 1a17d6978b..d60de494e6 100644
@@ -15,8 +15,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-env_t *env_ptr;
-
 U_BOOT_ENV_LOCATION(nowhere) = {
 	.location	= ENVL_NOWHERE,
 	ENV_NAME("nowhere")
env/nvram.c +0 -1
index 0f4b491fd3..ac389ace62 100644
@@ -36,7 +36,6 @@ DECLARE_GLOBAL_DATA_PTR;
 #ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
 extern void *nvram_read(void *dest, const long src, size_t count);
 extern void nvram_write(long dest, const void *src, size_t count);
-env_t *env_ptr;
 #else
 env_t *env_ptr = (env_t *)CONFIG_ENV_ADDR;
 #endif
env/ubi.c +0 -2
index 4d5ae1343d..9399f943dc 100644
@@ -16,8 +16,6 @@
 #include <ubi_uboot.h>
 #undef crc32
 
-env_t *env_ptr;
-
 DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_CMD_SAVEENV
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#17 lore raw

PATCH v4 17/29 env: Drop env_init_new()

In reply to Simon Glass

Now that env_init() is only defined once we can drop the env_init_new() name and just use env_init().

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/env.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
env/env.c +1 -5
index 53a085c431..ac6a583a02 100644
@@ -125,7 +125,7 @@ int env_save(void)
 	return 0;
 }
 
-int env_init_new(void)
+int env_init(void)
 {
 	struct env_driver *drv = env_driver_lookup_default();
 	int ret = -ENOENT;
@@ -163,7 +163,3 @@ int saveenv(void)
 	return env_save();
 }
 
-int env_init(void)
-{
-	return env_init_new();
-}
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#18 lore raw

PATCH v4 18/29 env: Drop env_get_char_spec()

In reply to Simon Glass

We only have a single implementation of this function now and it is called env_get_char(). Drop the old function and the weak version.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 env/common.c          | 14 --------------
 env/env.c             |  9 +++------
 include/environment.h | 14 ++++++++++----
 3 files changed, 13 insertions(+), 24 deletions(-)
env/common.c +0 -14
index 842c0f7fd1..9b3a26859f 100644
@@ -27,20 +27,6 @@ struct hsearch_data env_htab = {
 	.change_ok = env_flags_validate,
 };
 
-__weak uchar env_get_char_spec(int index)
-{
-	return *(uchar *)(gd->env_addr + index);
-}
-
-uchar env_get_char(int index)
-{
-	/* if env is not set up, or crc was bad, use the default environment */
-	if (!gd->env_valid)
-		return default_environment[index];
-	else
-		return env_get_char_spec(index);
-}
-
 /*
  * Read an environment variable as a boolean
  * Return -1 if variable does not exist (default to true)
env/env.c +3 -6
index ac6a583a02..a239d93156 100644
@@ -69,11 +69,13 @@ struct env_driver *env_driver_lookup_default(void)
 	return drv;
 }
 
-int env_get_char_new(int index)
+int env_get_char(int index)
 {
 	struct env_driver *drv = env_driver_lookup_default();
 	int ret;
 
+	if (!gd->env_valid)
+		return default_environment[index];
 	if (!drv)
 		return -ENODEV;
 	if (!drv->get_char)
@@ -148,11 +150,6 @@ int env_init(void)
 	return 0;
 }
 
-unsigned char env_get_char_spec(int index)
-{
-	return *(uchar *)(gd->env_addr + index);
-}
-
 void env_relocate_spec(void)
 {
 	env_load();
include/environment.h +10 -4
index 584fd7216d..1df243462e 100644
@@ -171,7 +171,6 @@ extern const unsigned char default_environment[];
 extern env_t *env_ptr;
 
 extern void env_relocate_spec(void);
-extern unsigned char env_get_char_spec(int);
 
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 extern void env_reloc(void);
@@ -281,9 +280,6 @@ struct env_driver {
 
 extern struct hsearch_data env_htab;
 
-/* Function that returns a character from the environment */
-unsigned char env_get_char(int);
-
 /* Function that updates CRC of the enironment */
 void env_crc_update(void);
 
@@ -314,6 +310,16 @@ int env_import_redund(const char *buf1, const char *buf2);
  */
 struct env_driver *env_driver_lookup_default(void);
 
+/**
+ * env_get_char() - Get a character from the early environment
+ *
+ * This reads from the pre-relocation environemnt
+ *
+ * @index: Index of character to read (0 = first)
+ * @return character read, or -ve on error
+ */
+int env_get_char(int index);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#19 lore raw

PATCH v4 19/29 env: Drop env_relocate_spec() in favour of env_load()

In reply to Simon Glass

This is a strange name for a function that loads the environment. There is now only one implementation of this function, so use the new env_load() function directly instead.

---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 board/birdland/bav335x/board.c              | 2 +-
 board/gateworks/gw_ventana/gw_ventana_spl.c | 2 +-
 board/tcl/sl50/board.c                      | 2 +-
 board/ti/am335x/board.c                     | 2 +-
 board/ti/am57xx/board.c                     | 2 +-
 board/ti/dra7xx/evm.c                       | 2 +-
 env/common.c                                | 2 +-
 env/env.c                                   | 5 -----
 include/environment.h                       | 9 +++++++--
 9 files changed, 14 insertions(+), 14 deletions(-)
board/birdland/bav335x/board.c +1 -1
index 67aca3cc43..b49365e157 100644
@@ -162,7 +162,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
+	env_load();
 	if (getenv_yesno("boot_os") != 1)
 		return 1;
 #endif
board/gateworks/gw_ventana/gw_ventana_spl.c +1 -1
index 69a638d71d..baa8480b6c 100644
@@ -690,7 +690,7 @@ int spl_start_uboot(void)
 	debug("%s\n", __func__);
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
+	env_load();
 	debug("boot_os=%s\n", getenv("boot_os"));
 	if (getenv_yesno("boot_os") == 1)
 		ret = 0;
board/tcl/sl50/board.c +1 -1
index e89ee35d30..d3c953e993 100644
@@ -76,7 +76,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
+	env_load();
 	if (getenv_yesno("boot_os") != 1)
 		return 1;
 #endif
board/ti/am335x/board.c +1 -1
index 0a16529b5f..ac0592b725 100644
@@ -249,7 +249,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
+	env_load();
 	if (getenv_yesno("boot_os") != 1)
 		return 1;
 #endif
board/ti/am57xx/board.c +1 -1
index 00a31a97fd..126c9ef694 100644
@@ -742,7 +742,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
+	env_load();
 	if (getenv_yesno("boot_os") != 1)
 		return 1;
 #endif
board/ti/dra7xx/evm.c +1 -1
index 7d36f03fa1..23be2c70e4 100644
@@ -825,7 +825,7 @@ int spl_start_uboot(void)
 
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
-	env_relocate_spec();
+	env_load();
 	if (getenv_yesno("boot_os") != 1)
 		return 1;
 #endif
env/common.c +1 -1
index 9b3a26859f..0cc8829d0d 100644
@@ -280,7 +280,7 @@ void env_relocate(void)
 		set_default_env("!bad CRC");
 #endif
 	} else {
-		env_relocate_spec();
+		env_load();
 	}
 }
 
env/env.c +0 -5
index a239d93156..85d95e5747 100644
@@ -150,11 +150,6 @@ int env_init(void)
 	return 0;
 }
 
-void env_relocate_spec(void)
-{
-	env_load();
-}
-
 int saveenv(void)
 {
 	return env_save();
include/environment.h +7 -2
index 1df243462e..b4f93663da 100644
@@ -170,8 +170,6 @@ extern env_t environment;
 extern const unsigned char default_environment[];
 extern env_t *env_ptr;
 
-extern void env_relocate_spec(void);
-
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 extern void env_reloc(void);
 #endif
@@ -320,6 +318,13 @@ struct env_driver *env_driver_lookup_default(void);
  */
 int env_get_char(int index);
 
+/**
+ * env_load() - Load the environment from storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_load(void);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#20 lore raw

PATCH v4 20/29 env: Drop saveenv() in favour of env_save()

In reply to Simon Glass

Use the env_save() function directly now that there is only one implementation of saveenv().

---

Changes in v4:
- Add changes for edison also

Changes in v3: None
Changes in v2: None

 arch/arm/mach-omap2/boot-common.c       | 3 ++-
 board/intel/edison/edison.c             | 5 +++--
 board/siemens/taurus/taurus.c           | 5 +++--
 board/toradex/apalis_imx6/apalis_imx6.c | 3 ++-
 cmd/nvedit.c                            | 2 +-
 drivers/bootcount/bootcount_env.c       | 3 ++-
 env/env.c                               | 6 ------
 include/common.h                        | 1 -
 include/environment.h                   | 7 +++++++
 9 files changed, 20 insertions(+), 15 deletions(-)
arch/arm/mach-omap2/boot-common.c +2 -1
index 700e6c2f79..2bcc8e9f97 100644
@@ -10,6 +10,7 @@
 
 #include <common.h>
 #include <ahci.h>
+#include <environment.h>
 #include <spl.h>
 #include <asm/omap_common.h>
 #include <asm/arch/omap.h>
@@ -241,7 +242,7 @@ int fb_set_reboot_flag(void)
 {
 	printf("Setting reboot to fastboot flag ...\n");
 	setenv("dofastboot", "1");
-	saveenv();
+	env_save();
 	return 0;
 }
 #endif
board/intel/edison/edison.c +3 -2
index a1a7d4d7c8..80f9b544b0 100644
@@ -5,6 +5,7 @@
  */
 #include <common.h>
 #include <dwc3-uboot.h>
+#include <environment.h>
 #include <mmc.h>
 #include <u-boot/md5.h>
 #include <usb.h>
@@ -70,7 +71,7 @@ static void assign_serial(void)
 	setenv("serial#", serial);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-	saveenv();
+	env_save();
 #endif
 }
 
@@ -88,7 +89,7 @@ static void assign_hardware_id(void)
 	setenv("hardware_id", hardware_id);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
-	saveenv();
+	env_save();
 #endif
 }
 
board/siemens/taurus/taurus.c +3 -2
index 4aa8d64869..3b742ebc22 100644
@@ -15,6 +15,7 @@
 #include <command.h>
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/io.h>
 #include <asm/arch/at91sam9260_matrix.h>
 #include <asm/arch/at91sam9_smc.h>
@@ -405,7 +406,7 @@ static int upgrade_failure_fallback(void)
 	setenv("bootargs", '\0');
 	setenv("upgrade_available", '\0');
 	setenv("boot_retries", '\0');
-	saveenv();
+	env_save();
 
 	return 0;
 }
@@ -424,7 +425,7 @@ static int do_upgrade_available(cmd_tbl_t *cmdtp, int flag, int argc,
 		boot_retry++;
 		sprintf(boot_buf, "%lx", boot_retry);
 		setenv("boot_retries", boot_buf);
-		saveenv();
+		env_save();
 
 		/*
 		 * Here the boot_retries count is checked, and if the
board/toradex/apalis_imx6/apalis_imx6.c +2 -1
index 8e5613cb12..e41547bbee 100644
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <environment.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/mxc_hdmi.h>
@@ -818,7 +819,7 @@ int board_late_init(void)
 			setenv("fdt_file", FDT_FILE_V1_0);
 			printf("patching fdt_file to " FDT_FILE_V1_0 "\n");
 #ifndef CONFIG_ENV_IS_NOWHERE
-			saveenv();
+			env_save();
 #endif
 		}
 	}
cmd/nvedit.c +1 -1
index 75df997592..4431ef66d8 100644
@@ -710,7 +710,7 @@ static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	printf("Saving Environment to %s...\n", env->name);
 
-	return saveenv() ? 1 : 0;
+	return env_save() ? 1 : 0;
 }
 
 U_BOOT_CMD(
drivers/bootcount/bootcount_env.c +2 -1
index 2d6e8db126..7f22dd0748 100644
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <environment.h>
 
 void bootcount_store(ulong a)
 {
@@ -13,7 +14,7 @@ void bootcount_store(ulong a)
 
 	if (upgrade_available) {
 		setenv_ulong("bootcount", a);
-		saveenv();
+		env_save();
 	}
 }
 
env/env.c +0 -6
index 85d95e5747..2b8b9611cf 100644
@@ -149,9 +149,3 @@ int env_init(void)
 
 	return 0;
 }
-
-int saveenv(void)
-{
-	return env_save();
-}
-
include/common.h +0 -1
index 751665f8a4..f0fc02cd3b 100644
@@ -335,7 +335,6 @@ ulong getenv_hex(const char *varname, ulong default_val);
  * Return -1 if variable does not exist (default to true)
  */
 int getenv_yesno(const char *var);
-int	saveenv	     (void);
 int	setenv	     (const char *, const char *);
 int setenv_ulong(const char *varname, ulong value);
 int setenv_hex(const char *varname, ulong value);
include/environment.h +7 -0
index b4f93663da..a055e3fa89 100644
@@ -325,6 +325,13 @@ int env_get_char(int index);
  */
 int env_load(void);
 
+/**
+ * env_save() - Save the environment to storage
+ *
+ * @return 0 if OK, -ve on error
+ */
+int env_save(void);
+
 #endif /* DO_DEPS_ONLY */
 
 #endif /* _ENVIRONMENT_H_ */
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#21 lore raw

PATCH v4 21/29 env: Rename setenv() to env_set()

In reply to Simon Glass

We are now using an env_ prefix for environment functions. Rename setenv() for consistency. Also add function comments in common.h.

---

Changes in v4:
- Reduce patch to only change setenv(), not any related function

Changes in v3: None
Changes in v2:
- Add new patch to rename setenv() and friends to env_set()

 api/api.c                                          |  2 +-
 arch/arm/cpu/armv7/vf610/generic.c                 |  2 +-
 arch/arm/lib/semihosting.c                         |  2 +-
 arch/arm/mach-imx/mx6/opos6ul.c                    |  2 +-
 arch/arm/mach-imx/mx7/soc.c                        |  4 +-
 arch/arm/mach-omap2/boot-common.c                  |  2 +-
 arch/arm/mach-omap2/utils.c                        | 10 +--
 arch/arm/mach-rockchip/rk3036-board.c              |  4 +-
 arch/arm/mach-rockchip/rk322x-board.c              |  4 +-
 arch/arm/mach-rockchip/rk3288-board.c              |  4 +-
 arch/arm/mach-socfpga/misc_gen5.c                  |  4 +-
 arch/arm/mach-tegra/board2.c                       |  4 +-
 arch/arm/mach-tegra/tegra186/nvtboot_board.c       |  2 +-
 arch/arm/mach-uniphier/board_late_init.c           | 10 +--
 board/Arcturus/ucp1020/cmd_arc.c                   | 14 ++---
 board/Arcturus/ucp1020/ucp1020.c                   |  6 +-
 board/BuR/brppt1/board.c                           |  2 +-
 board/BuR/brxre1/board.c                           | 16 ++---
 board/BuR/common/common.c                          |  2 +-
 board/CZ.NIC/turris_omnia/turris_omnia.c           |  2 +-
 board/Synology/ds414/cmd_syno.c                    |  6 +-
 board/amazon/kc1/kc1.c                             |  2 +-
 board/amlogic/odroid-c2/odroid-c2.c                |  2 +-
 board/aries/ma5d4evk/ma5d4evk.c                    |  2 +-
 board/aristainetos/aristainetos-v2.c               |  4 +-
 board/armltd/integrator/integrator.c               |  2 +-
 board/atmel/sama5d3xek/sama5d3xek.c                |  2 +-
 board/bachmann/ot1200/ot1200.c                     |  4 +-
 board/birdland/bav335x/board.c                     |  4 +-
 board/bosch/shc/board.c                            |  2 +-
 board/boundary/nitrogen6x/nitrogen6x.c             |  4 +-
 board/buffalo/lsxl/lsxl.c                          |  2 +-
 board/cadence/xtfpga/xtfpga.c                      |  2 +-
 board/ccv/xpress/xpress.c                          |  2 +-
 board/congatec/cgtqmx6eval/cgtqmx6eval.c           |  4 +-
 board/cssi/MCR3000/MCR3000.c                       |  2 +-
 board/davinci/da8xxevm/omapl138_lcdk.c             |  2 +-
 board/el/el6x/el6x.c                               |  2 +-
 board/engicam/common/board.c                       | 12 ++--
 board/engicam/geam6ul/geam6ul.c                    |  2 +-
 board/engicam/icorem6/icorem6.c                    |  4 +-
 board/engicam/icorem6_rqs/icorem6_rqs.c            |  4 +-
 board/engicam/isiotmx6ul/isiotmx6ul.c              |  4 +-
 board/freescale/common/cmd_esbc_validate.c         |  2 +-
 board/freescale/common/fsl_chain_of_trust.c        |  4 +-
 board/freescale/common/sys_eeprom.c                |  2 +-
 board/freescale/mpc8323erdb/mpc8323erdb.c          |  2 +-
 board/freescale/mx53loco/mx53loco.c                |  4 +-
 board/freescale/mx6sabreauto/mx6sabreauto.c        |  8 +--
 board/freescale/mx6sabresd/mx6sabresd.c            |  8 +--
 board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c  |  6 +-
 board/freescale/mx6ullevk/mx6ullevk.c              |  4 +-
 board/gateworks/gw_ventana/gw_ventana.c            | 26 ++++----
 board/grinn/liteboard/board.c                      |  2 +-
 board/highbank/highbank.c                          |  4 +-
 board/htkw/mcx/mcx.c                               |  2 +-
 board/intel/edison/edison.c                        |  6 +-
 board/isee/igep003x/board.c                        |  6 +-
 board/isee/igep00x0/igep00x0.c                     |  4 +-
 board/keymile/common/common.c                      | 16 ++---
 board/keymile/common/ivm.c                         |  8 +--
 board/keymile/km83xx/km83xx.c                      |  8 +--
 board/keymile/km_arm/km_arm.c                      |  4 +-
 board/keymile/kmp204x/kmp204x.c                    |  2 +-
 board/lg/sniper/sniper.c                           |  2 +-
 board/liebherr/mccmon6/mccmon6.c                   |  2 +-
 board/logicpd/imx6/imx6logic.c                     |  6 +-
 board/logicpd/omap3som/omap3logic.c                |  2 +-
 board/nokia/rx51/rx51.c                            |  2 +-
 board/overo/overo.c                                | 44 ++++++-------
 board/qualcomm/dragonboard410c/dragonboard410c.c   |  2 +-
 board/raspberrypi/rpi/rpi.c                        | 14 ++---
 board/renesas/ecovec/ecovec.c                      |  2 +-
 board/renesas/sh7752evb/sh7752evb.c                |  4 +-
 board/renesas/sh7753evb/sh7753evb.c                |  4 +-
 board/renesas/sh7757lcr/sh7757lcr.c                |  6 +-
 board/rockchip/kylin_rk3036/kylin_rk3036.c         |  2 +-
 board/samsung/common/misc.c                        | 14 ++---
 board/samsung/trats/trats.c                        |  2 +-
 board/samsung/universal_c210/universal.c           |  2 +-
 board/samtec/vining_2000/vining_2000.c             |  6 +-
 board/samtec/vining_fpga/socfpga.c                 | 10 +--
 board/siemens/common/factoryset.c                  |  6 +-
 board/siemens/common/factoryset.h                  |  2 +-
 board/siemens/draco/board.c                        |  8 +--
 board/siemens/pxm2/board.c                         |  4 +-
 board/siemens/rut/board.c                          |  4 +-
 board/siemens/taurus/taurus.c                      | 24 ++++----
 board/solidrun/mx6cuboxi/mx6cuboxi.c               |  8 +--
 board/spear/common/spr_misc.c                      |  8 +--
 board/st/stm32f429-discovery/stm32f429-discovery.c |  2 +-
 board/sunxi/board.c                                |  8 +--
 board/syteco/zmx25/zmx25.c                         |  4 +-
 board/theobroma-systems/puma_rk3399/puma-rk3399.c  |  4 +-
 board/ti/am335x/board.c                            |  2 +-
 board/ti/am43xx/board.c                            |  2 +-
 board/ti/am57xx/board.c                            |  4 +-
 board/ti/beagle/beagle.c                           | 38 ++++++------
 board/ti/common/board_detect.c                     | 14 ++---
 board/ti/dra7xx/evm.c                              |  2 +-
 board/ti/ks2_evm/board_k2g.c                       |  4 +-
 board/ti/panda/panda.c                             |  4 +-
 board/toradex/apalis_imx6/apalis_imx6.c            |  4 +-
 board/toradex/colibri_imx6/colibri_imx6.c          |  2 +-
 board/toradex/colibri_vf/colibri_vf.c              |  2 +-
 board/toradex/common/tdx-common.c                  |  2 +-
 board/tqc/tqma6/tqma6.c                            |  2 +-
 board/udoo/neo/neo.c                               |  2 +-
 board/udoo/udoo.c                                  |  4 +-
 board/varisys/common/sys_eeprom.c                  |  4 +-
 board/vscom/baltos/board.c                         |  4 +-
 board/wandboard/wandboard.c                        |  8 +--
 board/xilinx/zynq/board.c                          | 12 ++--
 board/xilinx/zynqmp/zynqmp.c                       |  2 +-
 cmd/fdt.c                                          | 24 ++++----
 cmd/gpt.c                                          |  2 +-
 cmd/ini.c                                          |  2 +-
 cmd/md5sum.c                                       |  2 +-
 cmd/mtdparts.c                                     | 26 ++++----
 cmd/net.c                                          | 34 +++++-----
 cmd/nvedit.c                                       |  8 +--
 cmd/part.c                                         |  8 +--
 cmd/pxe.c                                          |  6 +-
 cmd/qfw.c                                          |  2 +-
 cmd/setexpr.c                                      |  4 +-
 common/board_r.c                                   |  2 +-
 common/bootm.c                                     |  2 +-
 common/cli_hush.c                                  |  2 +-
 common/console.c                                   |  4 +-
 common/hash.c                                      |  2 +-
 common/hwconfig.c                                  |  4 +-
 common/image-android.c                             |  2 +-
 common/main.c                                      |  2 +-
 common/spl/Kconfig                                 |  2 +-
 common/spl/spl_dfu.c                               |  2 +-
 common/spl/spl_net.c                               |  4 +-
 common/update.c                                    |  4 +-
 doc/README.enetaddr                                |  2 +-
 drivers/mtd/dataflash.c                            |  7 ++-
 drivers/net/sandbox-raw.c                          |  4 +-
 fs/fs.c                                            |  4 +-
 include/_exports.h                                 |  2 +-
 include/common.h                                   | 14 ++++-
 include/configs/tam3517-common.h                   |  2 +-
 include/dataflash.h                                |  2 +-
 include/exports.h                                  |  2 +-
 include/search.h                                   |  2 +-
 lib/uuid.c                                         |  2 +-
 net/arp.c                                          |  2 +-
 net/bootp.c                                        |  2 +-
 net/dns.c                                          |  2 +-
 net/eth_common.c                                   |  6 +-
 test/dm/eth.c                                      | 72 +++++++++++-----------
 tools/env/fw_env.c                                 |  2 +-
 tools/env/fw_env.h                                 |  4 +-
 tools/env/fw_env_main.c                            |  8 +--
 156 files changed, 467 insertions(+), 452 deletions(-)
api/api.c +1 -1
index c368511704..423fb6b0c1 100644
@@ -481,7 +481,7 @@ static int API_env_set(va_list ap)
 	if ((value = (char *)va_arg(ap, uintptr_t)) == NULL)
 		return API_EINVAL;
 
-	setenv(name, value);
+	env_set(name, value);
 
 	return 0;
 }
arch/arm/cpu/armv7/vf610/generic.c +1 -1
index ac2d8d1a3f..88f3f4dd16 100644
@@ -329,7 +329,7 @@ int arch_misc_init(void)
 
 	strcpy(soc, "vf");
 	strcat(soc, soc_type);
-	setenv("soc", soc);
+	env_set("soc", soc);
 
 	return 0;
 }
arch/arm/lib/semihosting.c +1 -1
index 415ac89de9..bcd16ee591 100644
@@ -200,7 +200,7 @@ static int do_smhload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		/* Optionally save returned end to the environment */
 		if (argc == 4) {
 			sprintf(end_str, "0x%08lx", end_addr);
-			setenv(argv[3], end_str);
+			env_set(argv[3], end_str);
 		}
 	} else {
 		return CMD_RET_USAGE;
arch/arm/mach-imx/mx6/opos6ul.c +1 -1
index 22b244079b..f8d7e8ee68 100644
@@ -132,7 +132,7 @@ int board_late_init(void)
 	/* In bootstrap don't use the env vars */
 	if (((reg & 0x3000000) >> 24) == 0x1) {
 		set_default_env(NULL);
-		setenv("preboot", "");
+		env_set("preboot", "");
 	}
 
 	return opos6ul_board_late_init();
arch/arm/mach-imx/mx7/soc.c +2 -2
index 4cf977e20a..7152c847d0 100644
@@ -256,9 +256,9 @@ int arch_misc_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_mx7d())
-		setenv("soc", "imx7d");
+		env_set("soc", "imx7d");
 	else
-		setenv("soc", "imx7s");
+		env_set("soc", "imx7s");
 #endif
 
 	return 0;
arch/arm/mach-omap2/boot-common.c +1 -1
index 2bcc8e9f97..26245aa169 100644
@@ -241,7 +241,7 @@ void arch_preboot_os(void)
 int fb_set_reboot_flag(void)
 {
 	printf("Setting reboot to fastboot flag ...\n");
-	setenv("dofastboot", "1");
+	env_set("dofastboot", "1");
 	env_save();
 	return 0;
 }
arch/arm/mach-omap2/utils.c +5 -5
index 1946641eb9..b7074638bd 100644
@@ -40,7 +40,7 @@ static void omap_set_fastboot_cpu(void)
 		printf("Warning: fastboot.cpu: unknown CPU rev: %u\n", cpu_rev);
 	}
 
-	setenv("fastboot.cpu", cpu);
+	env_set("fastboot.cpu", cpu);
 }
 
 static void omap_set_fastboot_secure(void)
@@ -63,7 +63,7 @@ static void omap_set_fastboot_secure(void)
 		printf("Warning: fastboot.secure: unknown CPU sec: %u\n", dev);
 	}
 
-	setenv("fastboot.secure", secure);
+	env_set("fastboot.secure", secure);
 }
 
 static void omap_set_fastboot_board_rev(void)
@@ -74,7 +74,7 @@ static void omap_set_fastboot_board_rev(void)
 	if (board_rev == NULL)
 		printf("Warning: fastboot.board_rev: unknown board revision\n");
 
-	setenv("fastboot.board_rev", board_rev);
+	env_set("fastboot.board_rev", board_rev);
 }
 
 #ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
@@ -118,7 +118,7 @@ static void omap_set_fastboot_userdata_size(void)
 		sprintf(buf, "%u", sz_kb);
 	}
 
-	setenv("fastboot.userdata_size", buf);
+	env_set("fastboot.userdata_size", buf);
 }
 #else
 static inline void omap_set_fastboot_userdata_size(void)
@@ -173,7 +173,7 @@ void omap_die_id_serial(void)
 		snprintf(serial_string, sizeof(serial_string),
 			"%08x%08x", die_id[0], die_id[3]);
 
-		setenv("serial#", serial_string);
+		env_set("serial#", serial_string);
 	}
 }
 
arch/arm/mach-rockchip/rk3036-board.c +2 -2
index 26ea23b014..a3457f3914 100644
@@ -34,11 +34,11 @@ static void setup_boot_mode(void)
 	switch (boot_mode) {
 	case BOOT_FASTBOOT:
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 		break;
 	case BOOT_UMS:
 		printf("enter UMS!\n");
-		setenv("preboot", "setenv preboot; ums mmc 0");
+		env_set("preboot", "setenv preboot; ums mmc 0");
 		break;
 	}
 }
arch/arm/mach-rockchip/rk322x-board.c +2 -2
index b6543a5108..1e79c19309 100644
@@ -30,11 +30,11 @@ static void setup_boot_mode(void)
 	switch (boot_mode) {
 	case BOOT_FASTBOOT:
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 		break;
 	case BOOT_UMS:
 		printf("enter UMS!\n");
-		setenv("preboot", "setenv preboot; ums mmc 0");
+		env_set("preboot", "setenv preboot; ums mmc 0");
 		break;
 	}
 }
arch/arm/mach-rockchip/rk3288-board.c +2 -2
index 613967c307..4a3f9e8df3 100644
@@ -37,11 +37,11 @@ static void setup_boot_mode(void)
 	switch (boot_mode) {
 	case BOOT_FASTBOOT:
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 		break;
 	case BOOT_UMS:
 		printf("enter UMS!\n");
-		setenv("preboot", "setenv preboot; if mmc dev 0;"
+		env_set("preboot", "setenv preboot; if mmc dev 0;"
 		       "then ums mmc 0; else ums mmc 1;fi");
 		break;
 	}
arch/arm/mach-socfpga/misc_gen5.c +2 -2
index 49b26b3570..2f1da740fb 100644
@@ -219,9 +219,9 @@ int arch_misc_init(void)
 {
 	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
 	const int fpga_id = socfpga_fpga_id(0);
-	setenv("bootmode", bsel_str[bsel].mode);
+	env_set("bootmode", bsel_str[bsel].mode);
 	if (fpga_id >= 0)
-		setenv("fpgatype", socfpga_fpga_model[fpga_id].var);
+		env_set("fpgatype", socfpga_fpga_model[fpga_id].var);
 	return socfpga_eth_reset();
 }
 #endif
arch/arm/mach-tegra/board2.c +2 -2
index bd137969f0..0426b7a95a 100644
@@ -214,9 +214,9 @@ int board_late_init(void)
 #if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
 	if (tegra_cpu_is_non_secure()) {
 		printf("CPU is in NS mode\n");
-		setenv("cpu_ns_mode", "1");
+		env_set("cpu_ns_mode", "1");
 	} else {
-		setenv("cpu_ns_mode", "");
+		env_set("cpu_ns_mode", "");
 	}
 #endif
 	start_cpu_fan();
arch/arm/mach-tegra/tegra186/nvtboot_board.c +1 -1
index feb935f0d9..56650efd4f 100644
@@ -49,7 +49,7 @@ static int set_ethaddr_from_nvtboot(void)
 		return -ENOENT;
 	}
 
-	ret = setenv("ethaddr", (void *)prop);
+	ret = env_set("ethaddr", (void *)prop);
 	if (ret) {
 		printf("Failed to set ethaddr from nvtboot DTB: %d\n", ret);
 		return ret;
arch/arm/mach-uniphier/board_late_init.c +5 -5
index 4bfa10b374..e6d600e41f 100644
@@ -55,7 +55,7 @@ static int uniphier_set_fdt_file(void)
 
 	strncat(dtb_name, ".dtb", buf_len);
 
-	return setenv("fdt_file", dtb_name);
+	return env_set("fdt_file", dtb_name);
 }
 
 int board_late_init(void)
@@ -65,20 +65,20 @@ int board_late_init(void)
 	switch (uniphier_boot_device_raw()) {
 	case BOOT_DEVICE_MMC1:
 		printf("eMMC Boot");
-		setenv("bootmode", "emmcboot");
+		env_set("bootmode", "emmcboot");
 		break;
 	case BOOT_DEVICE_NAND:
 		printf("NAND Boot");
-		setenv("bootmode", "nandboot");
+		env_set("bootmode", "nandboot");
 		nand_denali_wp_disable();
 		break;
 	case BOOT_DEVICE_NOR:
 		printf("NOR Boot");
-		setenv("bootmode", "norboot");
+		env_set("bootmode", "norboot");
 		break;
 	case BOOT_DEVICE_USB:
 		printf("USB Boot");
-		setenv("bootmode", "usbboot");
+		env_set("bootmode", "usbboot");
 		break;
 	default:
 		printf("Unknown");
board/Arcturus/ucp1020/cmd_arc.c +7 -7
index fa6b4853f9..c32f7df454 100644
@@ -138,7 +138,7 @@ int get_arc_info(void)
 			printf("\t<not found>\n");
 		} else {
 			printf("\t%s\n", smac[3]);
-			setenv("SERIAL", smac[3]);
+			env_set("SERIAL", smac[3]);
 		}
 	}
 
@@ -152,7 +152,7 @@ int get_arc_info(void)
 		char *ret = getenv("ethaddr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETHADDR)) == 0) {
-			setenv("ethaddr", smac[2]);
+			env_set("ethaddr", smac[2]);
 			printf("\t%s (factory)\n", smac[2]);
 		} else {
 			printf("\t%s\n", ret);
@@ -160,8 +160,8 @@ int get_arc_info(void)
 	}
 
 	if (strcmp(smac[1], "00:00:00:00:00:00") == 0) {
-		setenv("eth1addr", smac[2]);
-		setenv("eth2addr", smac[2]);
+		env_set("eth1addr", smac[2]);
+		env_set("eth2addr", smac[2]);
 		return 0;
 	}
 
@@ -172,7 +172,7 @@ int get_arc_info(void)
 		char *ret = getenv("eth1addr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETH1ADDR)) == 0) {
-			setenv("eth1addr", smac[1]);
+			env_set("eth1addr", smac[1]);
 			printf("\t%s (factory)\n", smac[1]);
 		} else {
 			printf("\t%s\n", ret);
@@ -180,7 +180,7 @@ int get_arc_info(void)
 	}
 
 	if (strcmp(smac[0], "00:00:00:00:00:00") == 0) {
-		setenv("eth2addr", smac[1]);
+		env_set("eth2addr", smac[1]);
 		return 0;
 	}
 
@@ -191,7 +191,7 @@ int get_arc_info(void)
 		char *ret = getenv("eth2addr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETH2ADDR)) == 0) {
-			setenv("eth2addr", smac[0]);
+			env_set("eth2addr", smac[0]);
 			printf("\t%s (factory)\n", smac[0]);
 		} else {
 			printf("\t%s\n", ret);
board/Arcturus/ucp1020/ucp1020.c +3 -3
index 0d086e87fa..2cc2e54d5b 100644
@@ -230,9 +230,9 @@ int last_stage_init(void)
 				strcat(newkernelargs, mmckargs);
 				strcat(newkernelargs, " ");
 				strcat(newkernelargs, &tmp[n]);
-				setenv("kernelargs", newkernelargs);
+				env_set("kernelargs", newkernelargs);
 			} else {
-				setenv("kernelargs", mmckargs);
+				env_set("kernelargs", mmckargs);
 			}
 		}
 	get_arc_info();
@@ -244,7 +244,7 @@ int last_stage_init(void)
 			strcat(newkernelargs, sval);
 			strcat(newkernelargs, " ");
 			strcat(newkernelargs, kval);
-			setenv("kernelargs", newkernelargs);
+			env_set("kernelargs", newkernelargs);
 		}
 	} else {
 		printf("Error reading kernelargs env variable!\n");
board/BuR/brppt1/board.c +1 -1
index a22722122b..6083479f2b 100644
@@ -167,7 +167,7 @@ int board_late_init(void)
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"switching to network-console ...       ");
-		setenv("bootcmd", "run netconsole");
+		env_set("bootcmd", "run netconsole");
 	}
 	return 0;
 }
board/BuR/brxre1/board.c +8 -8
index f4bfa410cc..cdbc93a8ec 100644
@@ -203,7 +203,7 @@ int board_late_init(void)
 				lcd_position_cursor(1, 8);
 				lcd_puts(
 				"switching to network-console ...       ");
-				setenv("bootcmd", "run netconsole");
+				env_set("bootcmd", "run netconsole");
 				cnt = 4;
 				break;
 			} else if (!gpio_get_value(ESC_KEY) &&
@@ -211,7 +211,7 @@ int board_late_init(void)
 				lcd_position_cursor(1, 8);
 				lcd_puts(
 				"starting u-boot script from USB ...    ");
-				setenv("bootcmd", "run usbscript");
+				env_set("bootcmd", "run usbscript");
 				cnt = 4;
 				break;
 			} else if ((!gpio_get_value(ESC_KEY) &&
@@ -221,7 +221,7 @@ int board_late_init(void)
 				lcd_position_cursor(1, 8);
 				lcd_puts(
 				"starting script from network ...      ");
-				setenv("bootcmd", "run netscript");
+				env_set("bootcmd", "run netscript");
 				cnt = 4;
 				break;
 			} else if (!gpio_get_value(ESC_KEY)) {
@@ -232,19 +232,19 @@ int board_late_init(void)
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"starting vxworks from network ...      ");
-		setenv("bootcmd", "run netboot");
+		env_set("bootcmd", "run netboot");
 		cnt = 4;
 	} else if (scratchreg == 0xCD) {
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"starting script from network ...      ");
-		setenv("bootcmd", "run netscript");
+		env_set("bootcmd", "run netscript");
 		cnt = 4;
 	} else if (scratchreg == 0xCE) {
 		lcd_position_cursor(1, 8);
 		lcd_puts(
 		"starting AR from eMMC ...             ");
-		setenv("bootcmd", "run mmcboot");
+		env_set("bootcmd", "run mmcboot");
 		cnt = 4;
 	}
 
@@ -252,7 +252,7 @@ int board_late_init(void)
 	switch (cnt) {
 	case 0:
 		lcd_puts("entering BOOT-mode.                    ");
-		setenv("bootcmd", "run defaultAR");
+		env_set("bootcmd", "run defaultAR");
 		buf = 0x0000;
 		break;
 	case 1:
@@ -285,7 +285,7 @@ int board_late_init(void)
 		 (u32)getenv_ulong("vx_memtop", 16, gd->fb_base-0x20),
 		 (u32)getenv_ulong("vx_romfsbase", 16, 0),
 		 (u32)getenv_ulong("vx_romfssize", 16, 0));
-	setenv("othbootargs", othbootargs);
+	env_set("othbootargs", othbootargs);
 	/*
 	 * reset VBAR registers to its reset location, VxWorks 6.9.3.2 does
 	 * expect that vectors are there, original u-boot moves them to _start
board/BuR/common/common.c +1 -1
index c3a56db76a..6bea9a4383 100644
@@ -184,7 +184,7 @@ int load_lcdtiming(struct am335x_lcdpanel *panel)
 		puts("no 'factory-settings / rotation' in dtb!\n");
 	}
 	snprintf(buf, sizeof(buf), "fbcon=rotate:%d", panel_info.vl_rot);
-	setenv("optargs_rot", buf);
+	env_set("optargs_rot", buf);
 #else
 	pnltmp.hactive = getenv_ulong("ds1_hactive", 10, ~0UL);
 	pnltmp.vactive = getenv_ulong("ds1_vactive", 10, ~0UL);
board/CZ.NIC/turris_omnia/turris_omnia.c +1 -1
index 86926f8050..b09bff0267 100644
@@ -280,7 +280,7 @@ static int set_regdomain(void)
 		puts("EEPROM regdomain read failed.\n");
 
 	printf("Regdomain set to %s\n", rd);
-	return setenv("regdomain", rd);
+	return env_set("regdomain", rd);
 }
 #endif
 
board/Synology/ds414/cmd_syno.c +3 -3
index 20544e29c4..6313882a52 100644
@@ -81,7 +81,7 @@ static int do_syno_populate(int argc, char * const argv[])
 		         ethaddr[0], ethaddr[1], ethaddr[2],
 			 ethaddr[3], ethaddr[4], ethaddr[5]);
 		printf("parsed %s = %s\n", var, val);
-		setenv(var, val);
+		env_set(var, val);
 	}
 	if (!strncmp(buf + 32, SYNO_SN_TAG, strlen(SYNO_SN_TAG))) {
 		char *snp, *csump;
@@ -111,7 +111,7 @@ static int do_syno_populate(int argc, char * const argv[])
 			goto out_unmap;
 		}
 		printf("parsed SN = %s\n", snp);
-		setenv("SN", snp);
+		env_set("SN", snp);
 	} else {	/* old style format */
 		unsigned char csum = 0;
 
@@ -125,7 +125,7 @@ static int do_syno_populate(int argc, char * const argv[])
 		}
 		bufp[n] = '\0';
 		printf("parsed SN = %s\n", buf + 32);
-		setenv("SN", buf + 32);
+		env_set("SN", buf + 32);
 	}
 out_unmap:
 	unmap_physmem(buf, len);
board/amazon/kc1/kc1.c +1 -1
index 13a9c6a0fe..2d8be1804a 100644
@@ -119,7 +119,7 @@ int misc_init_r(void)
 
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
 		if (!getenv("reboot-mode"))
-			setenv("reboot-mode", (char *)reboot_mode);
+			env_set("reboot-mode", (char *)reboot_mode);
 	}
 
 	omap_reboot_mode_clear();
board/amlogic/odroid-c2/odroid-c2.c +1 -1
index b29f56d5eb..f2a394a72b 100644
@@ -55,7 +55,7 @@ int misc_init_r(void)
 		len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial,
 			EFUSE_SN_SIZE);
 		if (len == EFUSE_SN_SIZE) 
-			setenv("serial#", serial);
+			env_set("serial#", serial);
 	}
 
 	return 0;
board/aries/ma5d4evk/ma5d4evk.c +1 -1
index b9294fc881..956c297e72 100644
@@ -325,7 +325,7 @@ int board_init(void)
 
 int board_late_init(void)
 {
-	setenv("bootmode", boot_mode_sf ? "sf" : "emmc");
+	env_set("bootmode", boot_mode_sf ? "sf" : "emmc");
 	return 0;
 }
 
board/aristainetos/aristainetos-v2.c +2 -2
index 6abc2159bb..bdf41b99c8 100644
@@ -670,9 +670,9 @@ int board_late_init(void)
 	if (bootmode == 7) {
 		my_bootdelay = getenv("nor_bootdelay");
 		if (my_bootdelay != NULL)
-			setenv("bootdelay", my_bootdelay);
+			env_set("bootdelay", my_bootdelay);
 		else
-			setenv("bootdelay", "-2");
+			env_set("bootdelay", "-2");
 	}
 
 	/* if we have the lg panel, we can initialze it now */
board/armltd/integrator/integrator.c +1 -1
index c3bafd453e..858f74e5cf 100644
@@ -116,7 +116,7 @@ extern void cm_remap(void);
 
 int misc_init_r (void)
 {
-	setenv("verify", "n");
+	env_set("verify", "n");
 	return (0);
 }
 
board/atmel/sama5d3xek/sama5d3xek.c +1 -1
index c1f2769f1c..88bcd876c9 100644
@@ -267,7 +267,7 @@ int board_late_init(void)
 		*p = tolower(*p);
 
 	strcat(name, "ek.dtb");
-	setenv("dtb_name", name);
+	env_set("dtb_name", name);
 #endif
 	return 0;
 }
board/bachmann/ot1200/ot1200.c +2 -2
index 1ad4ef93cf..df10d6a0d0 100644
@@ -312,9 +312,9 @@ int board_eth_init(bd_t *bis)
 
 	/* depending on the phy address we can detect our board version */
 	if (phydev->addr == 0)
-		setenv("boardver", "");
+		env_set("boardver", "");
 	else
-		setenv("boardver", "mr");
+		env_set("boardver", "mr");
 
 	printf("using phy at %d\n", phydev->addr);
 	ret = fec_probe(bis, -1, base, bus, phydev);
board/birdland/bav335x/board.c +2 -2
index b49365e157..c5122253cf 100644
@@ -301,8 +301,8 @@ int board_init(void)
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "BAV335xB");
-	setenv("board_rev", "B"); /* Fix me, but why bother.. */
+	env_set("board_name", "BAV335xB");
+	env_set("board_rev", "B"); /* Fix me, but why bother.. */
 #endif
 	return 0;
 }
board/bosch/shc/board.c +1 -1
index 38577f30f1..2c830a219c 100644
@@ -251,7 +251,7 @@ static void check_button_status(void)
 
 	if (value == 0) {
 		printf("front button activated !\n");
-		setenv("harakiri", "1");
+		env_set("harakiri", "1");
 	}
 }
 
board/boundary/nitrogen6x/nitrogen6x.c +2 -2
index 17fd6f56ea..c04926c0bb 100644
@@ -954,7 +954,7 @@ static int do_kbd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char envvalue[ARRAY_SIZE(buttons)+1];
 	int numpressed = read_keys(envvalue);
-	setenv("keybd", envvalue);
+	env_set("keybd", envvalue);
 	return numpressed == 0;
 }
 
@@ -995,7 +995,7 @@ static void preboot_keys(void)
 			sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix);
 			cmd = getenv(cmd_name);
 			if (cmd) {
-				setenv("preboot", cmd);
+				env_set("preboot", cmd);
 				return;
 			}
 		}
board/buffalo/lsxl/lsxl.c +1 -1
index 0f3734587a..5b31e056ba 100644
@@ -228,7 +228,7 @@ static void erase_environment(void)
 static void rescue_mode(void)
 {
 	printf("Entering rescue mode..\n");
-	setenv("bootsource", "rescue");
+	env_set("bootsource", "rescue");
 }
 
 static void check_push_button(void)
board/cadence/xtfpga/xtfpga.c +1 -1
index 0265e9bb36..83244c3ad4 100644
@@ -93,7 +93,7 @@ int misc_init_r(void)
 		x = (*(volatile u32 *)CONFIG_SYS_FPGAREG_DIPSW)
 			& FPGAREG_MAC_MASK;
 		sprintf(&s[15], "%02x", x);
-		setenv("ethaddr", s);
+		env_set("ethaddr", s);
 	}
 #endif /* CONFIG_CMD_NET */
 
board/ccv/xpress/xpress.c +1 -1
index 542e534270..b65646588a 100644
@@ -318,7 +318,7 @@ static const struct boot_mode board_boot_modes[] = {
 int board_late_init(void)
 {
 	add_board_boot_modes(board_boot_modes);
-	setenv("board_name", "xpress");
+	env_set("board_name", "xpress");
 
 	return 0;
 }
board/congatec/cgtqmx6eval/cgtqmx6eval.c +2 -2
index 5cb97b4778..ac66248b3f 100644
@@ -755,9 +755,9 @@ int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
board/cssi/MCR3000/MCR3000.c +1 -1
index 43c4cb77bb..c928881804 100644
@@ -123,7 +123,7 @@ int misc_init_r(void)
 
 	/* if BTN_ACQ_AL is pressed then bootdelay is changed to 60 second */
 	if ((in_be16(&iop->iop_pcdat) & 0x0004) == 0)
-		setenv("bootdelay", "60");
+		env_set("bootdelay", "60");
 
 	return 0;
 }
board/davinci/da8xxevm/omapl138_lcdk.c +1 -1
index 52bb7363a7..29296b0478 100644
@@ -337,7 +337,7 @@ int misc_init_r(void)
 				addr[0], addr[1], addr[2], addr[3], addr[4],
 				addr[5]);
 
-			setenv("ethaddr", (char *)tmp);
+			env_set("ethaddr", (char *)tmp);
 		} else {
 			printf("Invalid MAC address read.\n");
 		}
board/el/el6x/el6x.c +1 -1
index cbe355a600..6b98b5c3eb 100644
@@ -466,7 +466,7 @@ int board_late_init(void)
 	add_board_boot_modes(board_boot_modes);
 #endif
 
-	setenv("board_name", BOARD_NAME);
+	env_set("board_name", BOARD_NAME);
 	return 0;
 }
 
board/engicam/common/board.c +6 -6
index e3bb5698f6..56112d3459 100644
@@ -25,7 +25,7 @@ static void mmc_late_init(void)
 
 	/* Set mmcblk env */
 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
-	setenv("mmcroot", mmcblk);
+	env_set("mmcroot", mmcblk);
 
 	sprintf(cmd, "mmc dev %d", dev_no);
 	run_command(cmd, 0);
@@ -43,20 +43,20 @@ int board_late_init(void)
 #ifdef CONFIG_ENV_IS_IN_MMC
 		mmc_late_init();
 #endif
-		setenv("modeboot", "mmcboot");
+		env_set("modeboot", "mmcboot");
 		break;
 	case IMX6_BMODE_NAND:
-		setenv("modeboot", "nandboot");
+		env_set("modeboot", "nandboot");
 		break;
 	default:
-		setenv("modeboot", "");
+		env_set("modeboot", "");
 		break;
 	}
 
 	if (is_mx6ul())
-		setenv("console", "ttymxc0");
+		env_set("console", "ttymxc0");
 	else
-		setenv("console", "ttymxc3");
+		env_set("console", "ttymxc3");
 
 	setenv_fdt_file();
 
board/engicam/geam6ul/geam6ul.c +1 -1
index bc36fc77ee..ffd383a0ee 100644
@@ -93,7 +93,7 @@ void setup_gpmi_nand(void)
 void setenv_fdt_file(void)
 {
 	if (is_mx6ul())
-		setenv("fdt_file", "imx6ul-geam-kit.dtb");
+		env_set("fdt_file", "imx6ul-geam-kit.dtb");
 }
 
 #ifdef CONFIG_SPL_BUILD
board/engicam/icorem6/icorem6.c +2 -2
index 5b2ed066b4..3d4f713c3e 100644
@@ -195,9 +195,9 @@ void setup_display(void)
 void setenv_fdt_file(void)
 {
 	if (is_mx6dq())
-		setenv("fdt_file", "imx6q-icore.dtb");
+		env_set("fdt_file", "imx6q-icore.dtb");
 	else if(is_mx6dl() || is_mx6solo())
-		setenv("fdt_file", "imx6dl-icore.dtb");
+		env_set("fdt_file", "imx6dl-icore.dtb");
 }
 
 #ifdef CONFIG_SPL_BUILD
board/engicam/icorem6_rqs/icorem6_rqs.c +2 -2
index 10a9471730..2a321dca50 100644
@@ -35,9 +35,9 @@ int board_mmc_get_env_dev(int devno)
 void setenv_fdt_file(void)
 {
 	if (is_mx6dq())
-		setenv("fdt_file", "imx6q-icore-rqs.dtb");
+		env_set("fdt_file", "imx6q-icore-rqs.dtb");
 	else if(is_mx6dl() || is_mx6solo())
-		setenv("fdt_file", "imx6dl-icore-rqs.dtb");
+		env_set("fdt_file", "imx6dl-icore-rqs.dtb");
 }
 
 #ifdef CONFIG_SPL_BUILD
board/engicam/isiotmx6ul/isiotmx6ul.c +2 -2
index 4dcc9ea11b..fbf17242f8 100644
@@ -102,9 +102,9 @@ void setenv_fdt_file(void)
 {
 	if (is_mx6ul()) {
 #ifdef CONFIG_ENV_IS_IN_MMC
-		setenv("fdt_file", "imx6ul-isiot-emmc.dtb");
+		env_set("fdt_file", "imx6ul-isiot-emmc.dtb");
 #else
-		setenv("fdt_file", "imx6ul-isiot-nand.dtb");
+		env_set("fdt_file", "imx6ul-isiot-nand.dtb");
 #endif
 	}
 }
board/freescale/common/cmd_esbc_validate.c +1 -1
index cefe3cc531..b3e5f019b8 100644
@@ -52,7 +52,7 @@ static int do_esbc_validate(cmd_tbl_t *cmdtp, int flag, int argc,
 	 * to continue U-Boot
 	 */
 	sprintf(buf, "%lx", img_addr);
-	setenv("img_addr", buf);
+	env_set("img_addr", buf);
 
 	if (ret)
 		return 1;
board/freescale/common/fsl_chain_of_trust.c +2 -2
index 2cd4fba13f..7071f6a5e3 100644
@@ -80,8 +80,8 @@ int fsl_setenv_chain_of_trust(void)
 	 * bootdelay = 0 (To disable Boot Prompt)
 	 * bootcmd = CONFIG_CHAIN_BOOT_CMD (Validate and execute Boot script)
 	 */
-	setenv("bootdelay", "0");
-	setenv("bootcmd", CONFIG_CHAIN_BOOT_CMD);
+	env_set("bootdelay", "0");
+	env_set("bootcmd", CONFIG_CHAIN_BOOT_CMD);
 	return 0;
 }
 #endif
board/freescale/common/sys_eeprom.c +1 -1
index 29aa778dbe..c593cff5e7 100644
@@ -479,7 +479,7 @@ int mac_read_from_eeprom(void)
 			 * (i.e. have not yet been set)
 			 */
 			if (!getenv(enetvar))
-				setenv(enetvar, ethaddr);
+				env_set(enetvar, ethaddr);
 		}
 	}
 
board/freescale/mpc8323erdb/mpc8323erdb.c +1 -1
index f30a1510ee..b715d8363e 100644
@@ -216,7 +216,7 @@ int mac_read_from_eeprom(void)
 						buf[i * 6 + 4], buf[i * 6 + 5]);
 					sprintf((char *)enetvar,
 						i ? "eth%daddr" : "ethaddr", i);
-					setenv((char *)enetvar, str);
+					env_set((char *)enetvar, str);
 				}
 			}
 		}
board/freescale/mx53loco/mx53loco.c +2 -2
index 27d606f310..ea36603686 100644
@@ -246,7 +246,7 @@ static int power_init(void)
 		if (!p)
 			return -ENODEV;
 
-		setenv("fdt_file", "imx53-qsb.dtb");
+		env_set("fdt_file", "imx53-qsb.dtb");
 
 		/* Set VDDA to 1.25V */
 		val = DA9052_BUCKCORE_BCOREEN | DA_BUCKCORE_VBCORE_1_250V;
@@ -289,7 +289,7 @@ static int power_init(void)
 		if (!p)
 			return -ENODEV;
 
-		setenv("fdt_file", "imx53-qsrb.dtb");
+		env_set("fdt_file", "imx53-qsrb.dtb");
 
 		/* Set VDDGP to 1.25V for 1GHz on SW1 */
 		pmic_reg_read(p, REG_SW_0, &val);
board/freescale/mx6sabreauto/mx6sabreauto.c +4 -4
index a5703a35b1..ea78091744 100644
@@ -687,14 +687,14 @@ int board_late_init(void)
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "SABREAUTO");
+	env_set("board_name", "SABREAUTO");
 
 	if (is_mx6dqp())
-		setenv("board_rev", "MX6QP");
+		env_set("board_rev", "MX6QP");
 	else if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else if (is_mx6sdl())
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
board/freescale/mx6sabresd/mx6sabresd.c +4 -4
index e4160420fa..19aa6f44d0 100644
@@ -700,14 +700,14 @@ int board_late_init(void)
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "SABRESD");
+	env_set("board_name", "SABRESD");
 
 	if (is_mx6dqp())
-		setenv("board_rev", "MX6QP");
+		env_set("board_rev", "MX6QP");
 	else if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else if (is_mx6sdl())
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
board/freescale/mx6ul_14x14_evk/mx6ul_14x14_evk.c +3 -3
index a30c379e4d..cf7a069c56 100644
@@ -674,12 +674,12 @@ int board_late_init(void)
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "EVK");
+	env_set("board_name", "EVK");
 
 	if (is_mx6ul_9x9_evk())
-		setenv("board_rev", "9X9");
+		env_set("board_rev", "9X9");
 	else
-		setenv("board_rev", "14X14");
+		env_set("board_rev", "14X14");
 #endif
 
 	return 0;
board/freescale/mx6ullevk/mx6ullevk.c +2 -2
index 66b08f823e..cebcec738f 100644
@@ -84,8 +84,8 @@ int board_late_init(void)
 #endif
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", "EVK");
-	setenv("board_rev", "14X14");
+	env_set("board_name", "EVK");
+	env_set("board_rev", "14X14");
 #endif
 
 	return 0;
board/gateworks/gw_ventana/gw_ventana.c +13 -13
index 89848c8f07..efadb0c324 100644
@@ -301,7 +301,7 @@ int board_eth_init(bd_t *bis)
 	if (!getenv("ethprime")) {
 		struct eth_device *dev = eth_get_dev_by_index(0);
 		if (dev) {
-			setenv("ethprime", dev->name);
+			env_set("ethprime", dev->name);
 			printf("set ethprime to %s\n", getenv("ethprime"));
 		}
 	}
@@ -662,7 +662,7 @@ int checkboard(void)
 	if (p)
 		quiet = simple_strtol(p, NULL, 10);
 	else
-		setenv("quiet", "0");
+		env_set("quiet", "0");
 
 	puts("\nGateworks Corporation Copyright 2014\n");
 	if (info->model[0]) {
@@ -737,26 +737,26 @@ int misc_init_r(void)
 		else if (is_cpu_type(MXC_CPU_MX6DL) ||
 			 is_cpu_type(MXC_CPU_MX6SOLO))
 			cputype = "imx6dl";
-		setenv("soctype", cputype);
+		env_set("soctype", cputype);
 		if (8 << (ventana_info.nand_flash_size-1) >= 2048)
-			setenv("flash_layout", "large");
+			env_set("flash_layout", "large");
 		else
-			setenv("flash_layout", "normal");
+			env_set("flash_layout", "normal");
 		memset(str, 0, sizeof(str));
 		for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++)
 			str[i] = tolower(info->model[i]);
-		setenv("model", str);
+		env_set("model", str);
 		if (!getenv("fdt_file")) {
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
-			setenv("fdt_file", fdt);
+			env_set("fdt_file", fdt);
 		}
 		p = strchr(str, '-');
 		if (p) {
 			*p++ = 0;
 
-			setenv("model_base", str);
+			env_set("model_base", str);
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
-			setenv("fdt_file1", fdt);
+			env_set("fdt_file1", fdt);
 			if (board_type != GW551x &&
 			    board_type != GW552x &&
 			    board_type != GW553x &&
@@ -765,7 +765,7 @@ int misc_init_r(void)
 			str[5] = 'x';
 			str[6] = 0;
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
-			setenv("fdt_file2", fdt);
+			env_set("fdt_file2", fdt);
 		}
 
 		/* initialize env from EEPROM */
@@ -780,11 +780,11 @@ int misc_init_r(void)
 
 		/* board serial-number */
 		sprintf(str, "%6d", info->serial);
-		setenv("serial#", str);
+		env_set("serial#", str);
 
 		/* memory MB */
 		sprintf(str, "%d", (int) (gd->ram_size >> 20));
-		setenv("mem_mb", str);
+		env_set("mem_mb", str);
 	}
 
 	/* Set a non-initialized hwconfig based on board configuration */
@@ -798,7 +798,7 @@ int misc_init_r(void)
 			if (strlen(buf) + strlen(buf1) < sizeof(buf))
 				strcat(buf, buf1);
 		}
-		setenv("hwconfig", buf);
+		env_set("hwconfig", buf);
 	}
 
 	/* setup baseboard specific GPIO based on board and env */
board/grinn/liteboard/board.c +1 -1
index 817e22fd45..835be99b96 100644
@@ -173,7 +173,7 @@ void board_late_mmc_init(void)
 	/* Set mmcblk env */
 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
 		dev_no);
-	setenv("mmcroot", mmcblk);
+	env_set("mmcroot", mmcblk);
 
 	sprintf(cmd, "mmc dev %d", dev_no);
 	run_command(cmd, 0);
board/highbank/highbank.c +2 -2
index 1af2207867..e51043aa91 100644
@@ -82,9 +82,9 @@ int misc_init_r(void)
 	sprintf(envbuffer, "bootcmd%d", boot_choice);
 	if (getenv(envbuffer)) {
 		sprintf(envbuffer, "run bootcmd%d", boot_choice);
-		setenv("bootcmd", envbuffer);
+		env_set("bootcmd", envbuffer);
 	} else
-		setenv("bootcmd", "");
+		env_set("bootcmd", "");
 
 	return 0;
 }
board/htkw/mcx/mcx.c +1 -1
index 1deb2bdd8b..0a02e44046 100644
@@ -83,7 +83,7 @@ int board_late_init(void)
 	if (gpio_get_value(HOT_WATER_BUTTON))
 		return 0;
 
-	setenv("bootcmd", "run swupdate");
+	env_set("bootcmd", "run swupdate");
 
 	return 0;
 }
board/intel/edison/edison.c +3 -3
index 80f9b544b0..aaafae86a8 100644
@@ -64,11 +64,11 @@ static void assign_serial(void)
 
 	snprintf(usb0addr, sizeof(usb0addr), "02:00:86:%02x:%02x:%02x",
 		 ssn[13], ssn[14], ssn[15]);
-	setenv("usb0addr", usb0addr);
+	env_set("usb0addr", usb0addr);
 
 	for (i = 0; i < 16; i++)
 		snprintf(&serial[2 * i], 3, "%02x", ssn[i]);
-	setenv("serial#", serial);
+	env_set("serial#", serial);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
 	env_save();
@@ -86,7 +86,7 @@ static void assign_hardware_id(void)
 		printf("Can't retrieve hardware revision\n");
 
 	snprintf(hardware_id, sizeof(hardware_id), "%02X", v.hardware_id);
-	setenv("hardware_id", hardware_id);
+	env_set("hardware_id", hardware_id);
 
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
 	env_save();
board/isee/igep003x/board.c +3 -3
index e33170d65f..24687e22e4 100644
@@ -194,13 +194,13 @@ int board_late_init(void)
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	switch (get_board_revision()) {
 		case 0:
-			setenv("board_name", "igep0034-lite");
+			env_set("board_name", "igep0034-lite");
 			break;
 		case 1:
-			setenv("board_name", "igep0034");
+			env_set("board_name", "igep0034");
 			break;
 		default:
-			setenv("board_name", "igep0033");
+			env_set("board_name", "igep0033");
 			break;
 	}
 #endif
board/isee/igep00x0/igep00x0.c +2 -2
index 843d35eb2d..a7a75601dd 100644
@@ -251,10 +251,10 @@ void set_fdt(void)
 {
 	switch (gd->bd->bi_arch_number) {
 	case MACH_TYPE_IGEP0020:
-		setenv("fdtfile", "omap3-igep0020.dtb");
+		env_set("fdtfile", "omap3-igep0020.dtb");
 		break;
 	case MACH_TYPE_IGEP0030:
-		setenv("fdtfile", "omap3-igep0030.dtb");
+		env_set("fdtfile", "omap3-igep0030.dtb");
 		break;
 	}
 }
board/keymile/common/common.c +8 -8
index 408079c9a1..56d3044241 100644
@@ -51,7 +51,7 @@ int set_km_env(void)
 	pnvramaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM
 			- CONFIG_KM_PNVRAM;
 	sprintf((char *)buf, "0x%x", pnvramaddr);
-	setenv("pnvramaddr", (char *)buf);
+	env_set("pnvramaddr", (char *)buf);
 
 	/* try to read rootfssize (ram image) from environment */
 	p = getenv("rootfssize");
@@ -60,15 +60,15 @@ int set_km_env(void)
 	pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
 		CONFIG_KM_PNVRAM) / 0x400;
 	sprintf((char *)buf, "0x%x", pram);
-	setenv("pram", (char *)buf);
+	env_set("pram", (char *)buf);
 
 	varaddr = gd->ram_size - CONFIG_KM_RESERVED_PRAM - CONFIG_KM_PHRAM;
 	sprintf((char *)buf, "0x%x", varaddr);
-	setenv("varaddr", (char *)buf);
+	env_set("varaddr", (char *)buf);
 
 	kernelmem = gd->ram_size - 0x400 * pram;
 	sprintf((char *)buf, "0x%x", kernelmem);
-	setenv("kernelmem", (char *)buf);
+	env_set("kernelmem", (char *)buf);
 
 	return 0;
 }
@@ -169,7 +169,7 @@ static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc,
 		return 1;
 	}
 	strcpy((char *)buf, p);
-	setenv("boardid", (char *)buf);
+	env_set("boardid", (char *)buf);
 	printf("set boardid=%s\n", buf);
 
 	p = get_local_var("IVM_HWKey");
@@ -178,7 +178,7 @@ static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc,
 		return 1;
 	}
 	strcpy((char *)buf, p);
-	setenv("hwkey", (char *)buf);
+	env_set("hwkey", (char *)buf);
 	printf("set hwkey=%s\n", buf);
 	printf("Execute manually saveenv for persistent storage.\n");
 
@@ -311,9 +311,9 @@ static int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc,
 					envbid   = bid;
 					envhwkey = hwkey;
 					sprintf(buf, "%lx", bid);
-					setenv("boardid", buf);
+					env_set("boardid", buf);
 					sprintf(buf, "%lx", hwkey);
-					setenv("hwkey", buf);
+					env_set("hwkey", buf);
 				}
 			} /* end while( ! found ) */
 		}
board/keymile/common/ivm.c +4 -4
index e9e518cf72..dc40a83fc0 100644
@@ -310,11 +310,11 @@ static int ivm_populate_env(unsigned char *buf, int len)
 #ifndef CONFIG_KMTEGR1
 	/* if an offset is defined, add it */
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, true);
-	setenv((char *)"ethaddr", (char *)valbuf);
+	env_set((char *)"ethaddr", (char *)valbuf);
 #ifdef CONFIG_KMVECT1
 /* KMVECT1 has two ethernet interfaces */
 	process_mac(valbuf, page2, 1, true);
-	setenv((char *)"eth1addr", (char *)valbuf);
+	env_set((char *)"eth1addr", (char *)valbuf);
 #endif
 #else
 /* KMTEGR1 has a special setup. eth0 has no connection to the outside and
@@ -322,9 +322,9 @@ static int ivm_populate_env(unsigned char *buf, int len)
  * gets the official MAC address from the IVM
  */
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, false);
-	setenv((char *)"ethaddr", (char *)valbuf);
+	env_set((char *)"ethaddr", (char *)valbuf);
 	process_mac(valbuf, page2, CONFIG_PIGGY_MAC_ADRESS_OFFSET, true);
-	setenv((char *)"eth1addr", (char *)valbuf);
+	env_set((char *)"eth1addr", (char *)valbuf);
 #endif
 
 	return 0;
board/keymile/km83xx/km83xx.c +4 -4
index 8020c379fd..5e07faa818 100644
@@ -263,11 +263,11 @@ int last_stage_init(void)
 	mv88e_sw_reset(name, CONFIG_KM_MVEXTSW_ADDR);
 
 	if (piggy_present()) {
-		setenv("ethact", "UEC2");
-		setenv("netdev", "eth1");
+		env_set("ethact", "UEC2");
+		env_set("netdev", "eth1");
 		puts("using PIGGY for network boot\n");
 	} else {
-		setenv("netdev", "eth0");
+		env_set("netdev", "eth0");
 		puts("using frontport for network boot\n");
 	}
 #endif
@@ -280,7 +280,7 @@ int last_stage_init(void)
 	if (dip_switch != 0) {
 		/* start bootloader */
 		puts("DIP:   Enabled\n");
-		setenv("actual_bank", "0");
+		env_set("actual_bank", "0");
 	}
 #endif
 	set_km_env();
board/keymile/km_arm/km_arm.c +2 -2
index 85785ffc02..08ae9ae346 100644
@@ -193,7 +193,7 @@ static void set_bootcount_addr(void)
 	unsigned int bootcountaddr;
 	bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR;
 	sprintf((char *)buf, "0x%x", bootcountaddr);
-	setenv("bootcountaddr", (char *)buf);
+	env_set("bootcountaddr", (char *)buf);
 }
 
 int misc_init_r(void)
@@ -299,7 +299,7 @@ int board_late_init(void)
 	if (dip_switch != 0) {
 		/* start bootloader */
 		puts("DIP:   Enabled\n");
-		setenv("actual_bank", "0");
+		env_set("actual_bank", "0");
 	}
 #endif
 
board/keymile/kmp204x/kmp204x.c +1 -1
index abb20196c5..095e467ac0 100644
@@ -222,7 +222,7 @@ int last_stage_init(void)
 	if (dip_switch != 0) {
 		/* start bootloader */
 		puts("DIP:   Enabled\n");
-		setenv("actual_bank", "0");
+		env_set("actual_bank", "0");
 	}
 #endif
 	set_km_env();
board/lg/sniper/sniper.c +1 -1
index f924645dc0..4906e4f9d2 100644
@@ -134,7 +134,7 @@ int misc_init_r(void)
 
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
 		if (!getenv("reboot-mode"))
-			setenv("reboot-mode", (char *)reboot_mode);
+			env_set("reboot-mode", (char *)reboot_mode);
 	}
 
 	omap_reboot_mode_clear();
board/liebherr/mccmon6/mccmon6.c +1 -1
index e265e2a732..8d0a66621d 100644
@@ -367,7 +367,7 @@ int board_init(void)
 
 int board_late_init(void)
 {
-	setenv("board_name", "mccmon6");
+	env_set("board_name", "mccmon6");
 
 	return 0;
 }
board/logicpd/imx6/imx6logic.c +3 -3
index 0a7d4124a6..78fc5466b6 100644
@@ -173,11 +173,11 @@ int board_init(void)
 
 int board_late_init(void)
 {
-	setenv("board_name", "imx6logic");
+	env_set("board_name", "imx6logic");
 
 	if (is_mx6dq()) {
-		setenv("board_rev", "MX6DQ");
-		setenv("fdt_file", "imx6q-logicpd.dtb");
+		env_set("board_rev", "MX6DQ");
+		env_set("fdt_file", "imx6q-logicpd.dtb");
 	}
 
 	return 0;
board/logicpd/omap3som/omap3logic.c +1 -1
index 7990dd2513..8885d1e6a9 100644
@@ -220,7 +220,7 @@ int board_late_init(void)
 
 		/* If the user has not set fdtimage, set the default */
 		if (!getenv("fdtimage"))
-			setenv("fdtimage", board->fdtfile);
+			env_set("fdtimage", board->fdtfile);
 	}
 
 	/* restore hsusb0_data5 pin as hsusb0_data5 */
board/nokia/rx51/rx51.c +1 -1
index 6a4427a42e..889e748f98 100644
@@ -413,7 +413,7 @@ int misc_init_r(void)
 
 	/* set env variable attkernaddr for relocated kernel */
 	sprintf(buf, "%#x", KERNEL_ADDRESS);
-	setenv("attkernaddr", buf);
+	env_set("attkernaddr", buf);
 
 	/* initialize omap tags */
 	init_omap_tags();
board/overo/overo.c +22 -22

120 lines not on this page · raw message

board/qualcomm/dragonboard410c/dragonboard410c.c +1 -1
index 37d0b85e0e..848e27848b 100644
@@ -128,7 +128,7 @@ int misc_init_r(void)
 	}
 
 	if (dm_gpio_get_value(&resin)) {
-		setenv("bootdelay", "-1");
+		env_set("bootdelay", "-1");
 		printf("Power button pressed - dropping to console.\n");
 	}
 
board/raspberrypi/rpi/rpi.c +7 -7
index d3c6ba580f..c1985fd418 100644
@@ -251,7 +251,7 @@ static void set_fdtfile(void)
 		return;
 
 	fdtfile = model->fdtfile;
-	setenv("fdtfile", fdtfile);
+	env_set("fdtfile", fdtfile);
 }
 
 /*
@@ -303,7 +303,7 @@ static void set_usbethaddr(void)
 	eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
 
 	if (!getenv("ethaddr"))
-		setenv("ethaddr", getenv("usbethaddr"));
+		env_set("ethaddr", getenv("usbethaddr"));
 
 	return;
 }
@@ -314,13 +314,13 @@ static void set_board_info(void)
 	char s[11];
 
 	snprintf(s, sizeof(s), "0x%X", revision);
-	setenv("board_revision", s);
+	env_set("board_revision", s);
 	snprintf(s, sizeof(s), "%d", rev_scheme);
-	setenv("board_rev_scheme", s);
+	env_set("board_rev_scheme", s);
 	/* Can't rename this to board_rev_type since it's an ABI for scripts */
 	snprintf(s, sizeof(s), "0x%X", rev_type);
-	setenv("board_rev", s);
-	setenv("board_name", model->name);
+	env_set("board_rev", s);
+	env_set("board_name", model->name);
 }
 #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
 
@@ -345,7 +345,7 @@ static void set_serial_number(void)
 
 	snprintf(serial_string, sizeof(serial_string), "%016" PRIx64,
 		 msg->get_board_serial.body.resp.serial);
-	setenv("serial#", serial_string);
+	env_set("serial#", serial_string);
 }
 
 int misc_init_r(void)
board/renesas/ecovec/ecovec.c +1 -1
index 28b557a5b0..e4bb440d24 100644
@@ -55,7 +55,7 @@ int board_late_init(void)
 	/* Set MAC address */
 	sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
 		mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
-	setenv("ethaddr", env_mac);
+	env_set("ethaddr", env_mac);
 
 	debug_led(0x0F);
 
board/renesas/sh7752evb/sh7752evb.c +2 -2
index 525d979724..4a76fb73ee 100644
@@ -221,10 +221,10 @@ static void init_ethernet_mac(void)
 	for (i = 0; i < SH7752EVB_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i, mac_string, buf);
 		if (i == 0)
-			setenv("ethaddr", mac_string);
+			env_set("ethaddr", mac_string);
 		else {
 			sprintf(env_string, "eth%daddr", i);
-			setenv(env_string, mac_string);
+			env_set(env_string, mac_string);
 		}
 		set_mac_to_sh_giga_eth_register(i, mac_string);
 	}
board/renesas/sh7753evb/sh7753evb.c +2 -2
index 3d1eedaa5f..ca9e144743 100644
@@ -237,10 +237,10 @@ static void init_ethernet_mac(void)
 	for (i = 0; i < SH7753EVB_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i, mac_string, buf);
 		if (i == 0)
-			setenv("ethaddr", mac_string);
+			env_set("ethaddr", mac_string);
 		else {
 			sprintf(env_string, "eth%daddr", i);
-			setenv(env_string, mac_string);
+			env_set(env_string, mac_string);
 		}
 		set_mac_to_sh_giga_eth_register(i, mac_string);
 	}
board/renesas/sh7757lcr/sh7757lcr.c +3 -3
index 0a04a9d39d..3f970fc401 100644
@@ -278,10 +278,10 @@ static void init_ethernet_mac(void)
 	for (i = 0; i < SH7757LCR_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i, mac_string, buf);
 		if (i == 0)
-			setenv("ethaddr", mac_string);
+			env_set("ethaddr", mac_string);
 		else {
 			sprintf(env_string, "eth%daddr", i);
-			setenv(env_string, mac_string);
+			env_set(env_string, mac_string);
 		}
 
 		set_mac_to_sh_eth_register(i, mac_string);
@@ -291,7 +291,7 @@ static void init_ethernet_mac(void)
 	for (i = 0; i < SH7757LCR_GIGA_ETHERNET_NUM_CH; i++) {
 		get_sh_eth_mac(i + SH7757LCR_ETHERNET_NUM_CH, mac_string, buf);
 		sprintf(env_string, "eth%daddr", i + SH7757LCR_ETHERNET_NUM_CH);
-		setenv(env_string, mac_string);
+		env_set(env_string, mac_string);
 
 		set_mac_to_sh_giga_eth_register(i, mac_string);
 	}
board/rockchip/kylin_rk3036/kylin_rk3036.c +1 -1
index 7e2edf4a56..9134994874 100644
@@ -44,7 +44,7 @@ int rk_board_late_init(void)
 {
 	if (fastboot_key_pressed()) {
 		printf("enter fastboot!\n");
-		setenv("preboot", "setenv preboot; fastboot usb0");
+		env_set("preboot", "setenv preboot; fastboot usb0");
 	}
 
 	return 0;
board/samsung/common/misc.c +7 -7
index b18eed2fac..4157349d02 100644
@@ -51,7 +51,7 @@ void set_dfu_alt_info(char *interface, char *devstr)
 
 	alt_setting = get_dfu_alt_boot(interface, devstr);
 	if (alt_setting) {
-		setenv("dfu_alt_boot", alt_setting);
+		env_set("dfu_alt_boot", alt_setting);
 		offset = snprintf(buf, buf_size, "%s", alt_setting);
 	}
 
@@ -71,7 +71,7 @@ void set_dfu_alt_info(char *interface, char *devstr)
 		status = "done\n";
 	}
 
-	setenv("dfu_alt_info", alt_info);
+	env_set("dfu_alt_info", alt_info);
 	puts(status);
 }
 #endif
@@ -83,14 +83,14 @@ void set_board_info(void)
 
 	snprintf(info, ARRAY_SIZE(info), "%u.%u", (s5p_cpu_rev & 0xf0) >> 4,
 		 s5p_cpu_rev & 0xf);
-	setenv("soc_rev", info);
+	env_set("soc_rev", info);
 
 	snprintf(info, ARRAY_SIZE(info), "%x", s5p_cpu_id);
-	setenv("soc_id", info);
+	env_set("soc_id", info);
 
 #ifdef CONFIG_REVISION_TAG
 	snprintf(info, ARRAY_SIZE(info), "%x", get_board_rev());
-	setenv("board_rev", info);
+	env_set("board_rev", info);
 #endif
 #ifdef CONFIG_OF_LIBFDT
 	const char *bdtype = "";
@@ -102,11 +102,11 @@ void set_board_info(void)
 		bdtype = "";
 
 	sprintf(info, "%s%s", bdname, bdtype);
-	setenv("boardname", info);
+	env_set("boardname", info);
 #endif
 	snprintf(info, ARRAY_SIZE(info),  "%s%x-%s%s.dtb",
 		 CONFIG_SYS_SOC, s5p_cpu_id, bdname, bdtype);
-	setenv("fdtfile", info);
+	env_set("fdtfile", info);
 #endif
 }
 #endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */
board/samsung/trats/trats.c +1 -1
index 00059a1317..f0913383b9 100644
@@ -469,7 +469,7 @@ void exynos_lcd_misc_init(vidinfo_t *vid)
 #endif
 #ifdef CONFIG_S6E8AX0
 	s6e8ax0_init();
-	setenv("lcdinfo", "lcd=s6e8ax0");
+	env_set("lcdinfo", "lcd=s6e8ax0");
 #endif
 }
 #endif
board/samsung/universal_c210/universal.c +1 -1
index cc6eaf7ad0..549ac8b48a 100644
@@ -397,6 +397,6 @@ void exynos_lcd_misc_init(vidinfo_t *vid)
 	vid->pclk_name = 1;	/* MPLL */
 	vid->sclk_div = 1;
 
-	setenv("lcdinfo", "lcd=ld9040");
+	env_set("lcdinfo", "lcd=ld9040");
 }
 #endif
board/samtec/vining_2000/vining_2000.c +3 -3
index 5c8b436776..d15f2a9c1d 100644
@@ -413,11 +413,11 @@ static int set_pin_state(void)
 		return ret;
 
 	if (val >= VAL_UPPER)
-		setenv("pin_state", "connected");
+		env_set("pin_state", "connected");
 	else if (val < VAL_UPPER && val > VAL_LOWER)
-		setenv("pin_state", "open");
+		env_set("pin_state", "open");
 	else
-		setenv("pin_state", "button");
+		env_set("pin_state", "button");
 
 	return ret;
 }
board/samtec/vining_fpga/socfpga.c +5 -5
index f888ecbbc1..2ee6d3b554 100644
@@ -69,9 +69,9 @@ int misc_init_r(void)
 	/* Check EEPROM signature. */
 	if (!(data[0] == 0xa5 && data[1] == 0x5a)) {
 		puts("Invalid I2C EEPROM signature.\n");
-		setenv("unit_serial", "invalid");
-		setenv("unit_ident", "VINing-xxxx-STD");
-		setenv("hostname", "vining-invalid");
+		env_set("unit_serial", "invalid");
+		env_set("unit_ident", "VINing-xxxx-STD");
+		env_set("hostname", "vining-invalid");
 		return 0;
 	}
 
@@ -82,13 +82,13 @@ int misc_init_r(void)
 			 (data[0x56] << 8) | (data[0x57] << 0);
 		memset(str, 0, sizeof(str));
 		sprintf(str, "%07i", serial);
-		setenv("unit_serial", str);
+		env_set("unit_serial", str);
 	}
 
 	if (!getenv("unit_ident")) {
 		memset(str, 0, sizeof(str));
 		memcpy(str, &data[0x2e], 18);
-		setenv("unit_ident", str);
+		env_set("unit_ident", str);
 	}
 
 	/* Set ethernet address from EEPROM. */
board/siemens/common/factoryset.c +3 -3
index 6c869ed2b0..4e5ad58d44 100644
@@ -266,7 +266,7 @@ err:
 
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
-static int factoryset_mac_setenv(void)
+static int factoryset_mac_env_set(void)
 {
 	uint8_t mac_addr[6];
 
@@ -296,11 +296,11 @@ static int factoryset_mac_setenv(void)
 	return 0;
 }
 
-int factoryset_setenv(void)
+int factoryset_env_set(void)
 {
 	int ret = 0;
 
-	if (factoryset_mac_setenv() < 0)
+	if (factoryset_mac_env_set() < 0)
 		ret = -1;
 
 	return ret;
board/siemens/common/factoryset.h +1 -1
index 3f23d5ebf4..8602627d2e 100644
@@ -25,7 +25,7 @@ struct factorysetcontainer {
 };
 
 int factoryset_read_eeprom(int i2c_addr);
-int factoryset_setenv(void);
+int factoryset_env_set(void);
 extern struct factorysetcontainer factory_dat;
 
 #endif /* __FACTORYSET_H */
board/siemens/draco/board.c +4 -4
index d8869a09dd..c705b5ab0f 100644
@@ -272,13 +272,13 @@ int board_late_init(void)
 #ifdef CONFIG_FACTORYSET
 	/* Set ASN in environment*/
 	if (factory_dat.asn[0] != 0) {
-		setenv("dtb_name", (char *)factory_dat.asn);
+		env_set("dtb_name", (char *)factory_dat.asn);
 	} else {
 		/* dtb suffix gets added in load script */
-		setenv("dtb_name", "am335x-draco");
+		env_set("dtb_name", "am335x-draco");
 	}
 #else
-	setenv("dtb_name", "am335x-draco");
+	env_set("dtb_name", "am335x-draco");
 #endif
 
 	return 0;
@@ -330,7 +330,7 @@ int board_eth_init(bd_t *bis)
 	int n = 0;
 	int rv;
 
-	factoryset_setenv();
+	factoryset_env_set();
 
 	/* Set rgmii mode and enable rmii clock to be sourced from chip */
 	writel((RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE), &cdev->miisel);
board/siemens/pxm2/board.c +2 -2
index 750f338897..012974d8eb 100644
@@ -446,12 +446,12 @@ int board_late_init(void)
 			factory_dat.pxm50 = 0;
 		sprintf(tmp, "%s_%s", factory_dat.asn,
 			factory_dat.comp_version);
-		ret = setenv("boardid", tmp);
+		ret = env_set("boardid", tmp);
 		if (ret)
 			printf("error setting board id\n");
 	} else {
 		factory_dat.pxm50 = 1;
-		ret = setenv("boardid", "PXM50_1.0");
+		ret = env_set("boardid", "PXM50_1.0");
 		if (ret)
 			printf("error setting board id\n");
 	}
board/siemens/rut/board.c +2 -2
index b3c666c054..2a97414baf 100644
@@ -182,7 +182,7 @@ int board_eth_init(bd_t *bis)
 	int rv;
 
 #ifndef CONFIG_SPL_BUILD
-	factoryset_setenv();
+	factoryset_env_set();
 #endif
 
 	/* Set rgmii mode and enable rmii clock to be sourced from chip */
@@ -482,7 +482,7 @@ int board_late_init(void)
 	else
 		strcpy(tmp, "QMX7.E38_4.0");
 
-	ret = setenv("boardid", tmp);
+	ret = env_set("boardid", tmp);
 	if (ret)
 		printf("error setting board id\n");
 
board/siemens/taurus/taurus.c +12 -12
index 3b742ebc22..d877a9c771 100644
@@ -380,9 +380,9 @@ static int upgrade_failure_fallback(void)
 	partitionset_active = getenv("partitionset_active");
 	if (partitionset_active) {
 		if (partitionset_active[0] == 'A')
-			setenv("partitionset_active", "B");
+			env_set("partitionset_active", "B");
 		else
-			setenv("partitionset_active", "A");
+			env_set("partitionset_active", "A");
 	} else {
 		printf("partitionset_active missing.\n");
 		return -ENOENT;
@@ -390,22 +390,22 @@ static int upgrade_failure_fallback(void)
 
 	rootfs = getenv("rootfs");
 	rootfs_fallback = getenv("rootfs_fallback");
-	setenv("rootfs", rootfs_fallback);
-	setenv("rootfs_fallback", rootfs);
+	env_set("rootfs", rootfs_fallback);
+	env_set("rootfs_fallback", rootfs);
 
 	kern_size = getenv("kernel_size");
 	kern_size_fb = getenv("kernel_size_fallback");
-	setenv("kernel_size", kern_size_fb);
-	setenv("kernel_size_fallback", kern_size);
+	env_set("kernel_size", kern_size_fb);
+	env_set("kernel_size_fallback", kern_size);
 
 	kern_off = getenv("kernel_Off");
 	kern_off_fb = getenv("kernel_Off_fallback");
-	setenv("kernel_Off", kern_off_fb);
-	setenv("kernel_Off_fallback", kern_off);
+	env_set("kernel_Off", kern_off_fb);
+	env_set("kernel_Off_fallback", kern_off);
 
-	setenv("bootargs", '\0');
-	setenv("upgrade_available", '\0');
-	setenv("boot_retries", '\0');
+	env_set("bootargs", '\0');
+	env_set("upgrade_available", '\0');
+	env_set("boot_retries", '\0');
 	env_save();
 
 	return 0;
@@ -424,7 +424,7 @@ static int do_upgrade_available(cmd_tbl_t *cmdtp, int flag, int argc,
 		boot_retry = simple_strtoul(getenv("boot_retries"), NULL, 10);
 		boot_retry++;
 		sprintf(boot_buf, "%lx", boot_retry);
-		setenv("boot_retries", boot_buf);
+		env_set("boot_retries", boot_buf);
 		env_save();
 
 		/*
board/solidrun/mx6cuboxi/mx6cuboxi.c +4 -4
index 1ccdfa8e05..7e59fb259e 100644
@@ -376,14 +376,14 @@ int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_hummingboard())
-		setenv("board_name", "HUMMINGBOARD");
+		env_set("board_name", "HUMMINGBOARD");
 	else
-		setenv("board_name", "CUBOXI");
+		env_set("board_name", "CUBOXI");
 
 	if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 
 	return 0;
board/spear/common/spr_misc.c +4 -4
index d6a84dba60..3bb4ff14d9 100644
@@ -56,12 +56,12 @@ int misc_init_r(void)
 	if (!eth_getenv_enetaddr("ethaddr", mac_id) && !i2c_read_mac(mac_id))
 		eth_setenv_enetaddr("ethaddr", mac_id);
 #endif
-	setenv("verify", "n");
+	env_set("verify", "n");
 
 #if defined(CONFIG_SPEAR_USBTTY)
-	setenv("stdin", "usbtty");
-	setenv("stdout", "usbtty");
-	setenv("stderr", "usbtty");
+	env_set("stdin", "usbtty");
+	env_set("stdout", "usbtty");
+	env_set("stderr", "usbtty");
 
 #ifndef CONFIG_SYS_NO_DCACHE
 	dcache_enable();
board/st/stm32f429-discovery/stm32f429-discovery.c +1 -1
index 8c8abf6a06..673e7728f1 100644
@@ -320,7 +320,7 @@ int misc_init_r(void)
 		u_id_high = readl(&STM32_U_ID->u_id_high);
 		sprintf(serialno, "%08x%08x%08x",
 			u_id_high, u_id_mid, u_id_low);
-		setenv("serial#", serialno);
+		env_set("serial#", serialno);
 	}
 
 	return 0;
board/sunxi/board.c +4 -4
index 800f412b38..b1fcd9d0b9 100644
@@ -712,7 +712,7 @@ static void setup_environment(const void *fdt)
 			snprintf(serial_string, sizeof(serial_string),
 				"%08x%08x", sid[0], sid[3]);
 
-			setenv("serial#", serial_string);
+			env_set("serial#", serial_string);
 		}
 	}
 }
@@ -721,11 +721,11 @@ int misc_init_r(void)
 {
 	__maybe_unused int ret;
 
-	setenv("fel_booted", NULL);
-	setenv("fel_scriptaddr", NULL);
+	env_set("fel_booted", NULL);
+	env_set("fel_scriptaddr", NULL);
 	/* determine if we are running in FEL mode */
 	if (!is_boot0_magic(SPL_ADDR + 4)) { /* eGON.BT0 */
-		setenv("fel_booted", "1");
+		env_set("fel_booted", "1");
 		parse_spl_header(SPL_ADDR);
 	}
 
board/syteco/zmx25/zmx25.c +2 -2
index bdbf02a067..e02dcf2995 100644
@@ -156,9 +156,9 @@ int board_late_init(void)
 				gpio_set_value(IMX_GPIO_NR(1, 29), 0);
 				gpio_set_value(IMX_GPIO_NR(4, 21), 0);
 
-				setenv("preboot", "run gs_slow_boot");
+				env_set("preboot", "run gs_slow_boot");
 			} else
-				setenv("preboot", "run gs_fast_boot");
+				env_set("preboot", "run gs_fast_boot");
 		}
 	}
 
board/theobroma-systems/puma_rk3399/puma-rk3399.c +2 -2
index 9347329eac..fd3b638466 100644
@@ -144,8 +144,8 @@ static void setup_serial(void)
 	serialno |= (u64)crc32_no_comp(serialno, high, 8) << 32;
 	snprintf(serialno_str, sizeof(serialno_str), "%llx", serialno);
 
-	setenv("cpuid#", cpuid_str);
-	setenv("serial#", serialno_str);
+	env_set("cpuid#", cpuid_str);
+	env_set("serial#", serialno_str);
 #endif
 
 	return;
board/ti/am335x/board.c +1 -1
index ac0592b725..5751b814ca 100644
@@ -731,7 +731,7 @@ int board_late_init(void)
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 #endif
 
 #if !defined(CONFIG_SPL_BUILD)
board/ti/am43xx/board.c +1 -1
index 933596d59c..55098bf816 100644
@@ -626,7 +626,7 @@ int board_late_init(void)
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 #endif
 	return 0;
 }
board/ti/am57xx/board.c +2 -2
index 126c9ef694..bd94a90f8f 100644
@@ -592,7 +592,7 @@ void am57x_idk_lcd_detect(void)
 		/* we will let default be "no lcd" */
 	}
 out:
-	setenv("idk_lcd", idk_lcd);
+	env_set("idk_lcd", idk_lcd);
 	return;
 }
 
@@ -612,7 +612,7 @@ int board_late_init(void)
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 
 	/*
 	 * Set the GPIO7 Pad to POWERHOLD. This has higher priority
board/ti/beagle/beagle.c +19 -19
index 887b577b6a..2f62fbec69 100644
@@ -341,16 +341,16 @@ int misc_init_r(void)
 	switch (get_board_revision()) {
 	case REVISION_AXBX:
 		printf("Beagle Rev Ax/Bx\n");
-		setenv("beaglerev", "AxBx");
+		env_set("beaglerev", "AxBx");
 		break;
 	case REVISION_CX:
 		printf("Beagle Rev C1/C2/C3\n");
-		setenv("beaglerev", "Cx");
+		env_set("beaglerev", "Cx");
 		MUX_BEAGLE_C();
 		break;
 	case REVISION_C4:
 		printf("Beagle Rev C4\n");
-		setenv("beaglerev", "C4");
+		env_set("beaglerev", "C4");
 		MUX_BEAGLE_C();
 		/* Set VAUX2 to 1.8V for EHCI PHY */
 		twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
@@ -360,7 +360,7 @@ int misc_init_r(void)
 		break;
 	case REVISION_XM_AB:
 		printf("Beagle xM Rev A/B\n");
-		setenv("beaglerev", "xMAB");
+		env_set("beaglerev", "xMAB");
 		MUX_BEAGLE_XM();
 		/* Set VAUX2 to 1.8V for EHCI PHY */
 		twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
@@ -371,7 +371,7 @@ int misc_init_r(void)
 		break;
 	case REVISION_XM_C:
 		printf("Beagle xM Rev C\n");
-		setenv("beaglerev", "xMC");
+		env_set("beaglerev", "xMC");
 		MUX_BEAGLE_XM();
 		/* Set VAUX2 to 1.8V for EHCI PHY */
 		twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED,
@@ -397,14 +397,14 @@ int misc_init_r(void)
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_TINCANTOOLS_ZIPPY();
-		setenv("buddy", "zippy");
+		env_set("buddy", "zippy");
 		break;
 	case TINCANTOOLS_ZIPPY2:
 		printf("Recognized Tincantools Zippy2 board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		MUX_TINCANTOOLS_ZIPPY();
-		setenv("buddy", "zippy2");
+		env_set("buddy", "zippy2");
 		break;
 	case TINCANTOOLS_TRAINER:
 		printf("Recognized Tincantools Trainer board (rev %d %s)\n",
@@ -412,37 +412,37 @@ int misc_init_r(void)
 			expansion_config.fab_revision);
 		MUX_TINCANTOOLS_ZIPPY();
 		MUX_TINCANTOOLS_TRAINER();
-		setenv("buddy", "trainer");
+		env_set("buddy", "trainer");
 		break;
 	case TINCANTOOLS_SHOWDOG:
 		printf("Recognized Tincantools Showdow board (rev %d %s)\n",
 			expansion_config.revision,
 			expansion_config.fab_revision);
 		/* Place holder for DSS2 definition for showdog lcd */
-		setenv("defaultdisplay", "showdoglcd");
-		setenv("buddy", "showdog");
+		env_set("defaultdisplay", "showdoglcd");
+		env_set("buddy", "showdog");
 		break;
 	case KBADC_BEAGLEFPGA:
 		printf("Recognized KBADC Beagle FPGA board\n");
 		MUX_KBADC_BEAGLEFPGA();
-		setenv("buddy", "beaglefpga");
+		env_set("buddy", "beaglefpga");
 		break;
 	case LW_BEAGLETOUCH:
 		printf("Recognized Liquidware BeagleTouch board\n");
-		setenv("buddy", "beagletouch");
+		env_set("buddy", "beagletouch");
 		break;
 	case BRAINMUX_LCDOG:
 		printf("Recognized Brainmux LCDog board\n");
-		setenv("buddy", "lcdog");
+		env_set("buddy", "lcdog");
 		break;
 	case BRAINMUX_LCDOGTOUCH:
 		printf("Recognized Brainmux LCDog Touch board\n");
-		setenv("buddy", "lcdogtouch");
+		env_set("buddy", "lcdogtouch");
 		break;
 	case BBTOYS_WIFI:
 		printf("Recognized BeagleBoardToys WiFi board\n");
 		MUX_BBTOYS_WIFI()
-		setenv("buddy", "bbtoys-wifi");
+		env_set("buddy", "bbtoys-wifi");
 		break;
 	case BBTOYS_VGA:
 		printf("Recognized BeagleBoardToys VGA board\n");
@@ -459,20 +459,20 @@ int misc_init_r(void)
 	case LSR_COM6L_ADPT:
 		printf("Recognized LSR COM6L Adapter Board\n");
 		MUX_BBTOYS_WIFI()
-		setenv("buddy", "lsr-com6l-adpt");
+		env_set("buddy", "lsr-com6l-adpt");
 		break;
 	case BEAGLE_NO_EEPROM:
 		printf("No EEPROM on expansion board\n");
-		setenv("buddy", "none");
+		env_set("buddy", "none");
 		break;
 	default:
 		printf("Unrecognized expansion board: %x\n",
 			expansion_config.device_vendor);
-		setenv("buddy", "unknown");
+		env_set("buddy", "unknown");
 	}
 
 	if (expansion_config.content == 1)
-		setenv(expansion_config.env_var, expansion_config.env_setting);
+		env_set(expansion_config.env_var, expansion_config.env_setting);
 
 	twl4030_power_init();
 	switch (get_board_revision()) {
board/ti/common/board_detect.c +7 -7
index 1da5ace923..c4ef28282f 100644
@@ -379,21 +379,21 @@ void __maybe_unused set_board_info_env(char *name)
 	struct ti_common_eeprom *ep = TI_EEPROM_DATA;
 
 	if (name)
-		setenv("board_name", name);
+		env_set("board_name", name);
 	else if (ep->name)
-		setenv("board_name", ep->name);
+		env_set("board_name", ep->name);
 	else
-		setenv("board_name", unknown);
+		env_set("board_name", unknown);
 
 	if (ep->version)
-		setenv("board_rev", ep->version);
+		env_set("board_rev", ep->version);
 	else
-		setenv("board_rev", unknown);
+		env_set("board_rev", unknown);
 
 	if (ep->serial)
-		setenv("board_serial", ep->serial);
+		env_set("board_serial", ep->serial);
 	else
-		setenv("board_serial", unknown);
+		env_set("board_serial", unknown);
 }
 
 static u64 mac_to_u64(u8 mac[6])
board/ti/dra7xx/evm.c +1 -1
index 23be2c70e4..5c43561bb7 100644
@@ -558,7 +558,7 @@ int board_late_init(void)
 	 * on HS devices.
 	 */
 	if (get_device_type() == HS_DEVICE)
-		setenv("boot_fit", "1");
+		env_set("boot_fit", "1");
 
 	omap_die_id_serial();
 	omap_set_fastboot_vars();
board/ti/ks2_evm/board_k2g.c +2 -2
index 21605762ef..15f0f54af6 100644
@@ -310,9 +310,9 @@ int board_late_init(void)
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (board_is_k2g_gp())
-		setenv("board_name", "66AK2GGP\0");
+		env_set("board_name", "66AK2GGP\0");
 	else if (board_is_k2g_ice())
-		setenv("board_name", "66AK2GIC\0");
+		env_set("board_name", "66AK2GIC\0");
 #endif
 	return 0;
 }
board/ti/panda/panda.c +2 -2
index 6ffb53c4c6..c59e58a82a 100644
@@ -103,7 +103,7 @@ int get_board_revision(void)
 		board_id4 = gpio_get_value(PANDA_ES_BOARD_ID_4_GPIO);
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-		setenv("board_name", "panda-es");
+		env_set("board_name", "panda-es");
 #endif
 		board_id = ((board_id4 << 4) | (board_id3 << 3) |
 			(board_id2 << 2) | (board_id1 << 1) | (board_id0));
@@ -117,7 +117,7 @@ int get_board_revision(void)
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 		if ((board_id >= 0x3) && (processor_rev == OMAP4430_ES2_3))
-			setenv("board_name", "panda-a4");
+			env_set("board_name", "panda-a4");
 #endif
 	}
 
board/toradex/apalis_imx6/apalis_imx6.c +2 -2
index e41547bbee..86a7a159e8 100644
@@ -804,7 +804,7 @@ int board_late_init(void)
 
 	rev = get_board_rev();
 	snprintf(env_str, ARRAY_SIZE(env_str), "%.4x", rev);
-	setenv("board_rev", env_str);
+	env_set("board_rev", env_str);
 
 #ifndef CONFIG_TDX_APALIS_IMX6_V1_0
 	if ((rev & 0xfff0) == 0x0100) {
@@ -816,7 +816,7 @@ int board_late_init(void)
 		/* if using the default device tree, use version for V1.0 HW */
 		fdt_env = getenv("fdt_file");
 		if ((fdt_env != NULL) && (strcmp(FDT_FILE, fdt_env) == 0)) {
-			setenv("fdt_file", FDT_FILE_V1_0);
+			env_set("fdt_file", FDT_FILE_V1_0);
 			printf("patching fdt_file to " FDT_FILE_V1_0 "\n");
 #ifndef CONFIG_ENV_IS_NOWHERE
 			env_save();
board/toradex/colibri_imx6/colibri_imx6.c +1 -1
index cbf7aa952a..dbcd233782 100644
@@ -676,7 +676,7 @@ int board_late_init(void)
 
 	rev = get_board_rev();
 	snprintf(env_str, ARRAY_SIZE(env_str), "%.4x", rev);
-	setenv("board_rev", env_str);
+	env_set("board_rev", env_str);
 #endif
 
 	return 0;
board/toradex/colibri_vf/colibri_vf.c +1 -1
index 46dd15bac8..3858af9c40 100644
@@ -535,7 +535,7 @@ int board_late_init(void)
 	if (((src->sbmr2 & SRC_SBMR2_BMOD_MASK) >> SRC_SBMR2_BMOD_SHIFT)
 			== SRC_SBMR2_BMOD_SERIAL) {
 		printf("Serial Downloader recovery mode, disable autoboot\n");
-		setenv("bootdelay", "-1");
+		env_set("bootdelay", "-1");
 	}
 
 	return 0;
board/toradex/common/tdx-common.c +1 -1
index 0d267877fa..77ebb88317 100644
@@ -80,7 +80,7 @@ int show_board_info(void)
 		tdx_hw_tag.ver_minor,
 		(char)tdx_hw_tag.ver_assembly + 'A');
 
-	setenv("serial#", tdx_serial_str);
+	env_set("serial#", tdx_serial_str);
 
 	/*
 	 * Check if environment contains a valid MAC address,
board/tqc/tqma6/tqma6.c +1 -1
index fcdea34f05..14991fdb00 100644
@@ -251,7 +251,7 @@ int power_init_board(void)
 
 int board_late_init(void)
 {
-	setenv("board_name", tqma6_get_boardname());
+	env_set("board_name", tqma6_get_boardname());
 
 	tqma6_bb_board_late_init();
 
board/udoo/neo/neo.c +1 -1
index 276c625cfd..7fa1289de0 100644
@@ -437,7 +437,7 @@ int checkboard(void)
 int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-	setenv("board_name", board_string());
+	env_set("board_name", board_string());
 #endif
 
 	return 0;
board/udoo/udoo.c +2 -2
index 7534935dde..a359626b81 100644
@@ -255,9 +255,9 @@ int board_late_init(void)
 {
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_cpu_type(MXC_CPU_MX6Q))
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 #endif
 	return 0;
 }
board/varisys/common/sys_eeprom.c +2 -2
index b55ab818e6..d235897311 100644
@@ -401,7 +401,7 @@ int mac_read_from_generic_eeprom(const char *envvar, int chip,
 			mac[5]);
 
 		printf("MAC: %s\n", ethaddr);
-		setenv(envvar, ethaddr);
+		env_set(envvar, ethaddr);
 	}
 
 	return ret;
@@ -487,7 +487,7 @@ int mac_read_from_eeprom_common(void)
 			 * (i.e. have not yet been set)
 			 */
 			if (!getenv(enetvar))
-				setenv(enetvar, ethaddr);
+				env_set(enetvar, ethaddr);
 		}
 	}
 
board/vscom/baltos/board.c +2 -2
index d3b1f1564f..5f730b8fd0 100644
@@ -68,7 +68,7 @@ static int baltos_set_console(void)
 	printf("DIPs: 0x%1x\n", (~dips) & 0xf);
 
 	if ((dips & 0xf) == 0xe)
-		setenv("console", "ttyUSB0,115200n8");
+		env_set("console", "ttyUSB0,115200n8");
 
 	return 0;
 }
@@ -373,7 +373,7 @@ int board_late_init(void)
 		return -ENODEV;
 	}
 
-	setenv("board_name", model);
+	env_set("board_name", model);
 #endif
 
 	return 0;
board/wandboard/wandboard.c +4 -4
index 1dbc966b6e..adfcf48562 100644
@@ -425,14 +425,14 @@ int board_late_init(void)
 
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (is_mx6dq())
-		setenv("board_rev", "MX6Q");
+		env_set("board_rev", "MX6Q");
 	else
-		setenv("board_rev", "MX6DL");
+		env_set("board_rev", "MX6DL");
 
 	if (is_revc1())
-		setenv("board_name", "C1");
+		env_set("board_name", "C1");
 	else
-		setenv("board_name", "B1");
+		env_set("board_name", "B1");
 #endif
 	return 0;
 }
board/xilinx/zynq/board.c +6 -6
index b2fbecf6de..90ef542458 100644
@@ -86,22 +86,22 @@ int board_late_init(void)
 {
 	switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
 	case ZYNQ_BM_QSPI:
-		setenv("modeboot", "qspiboot");
+		env_set("modeboot", "qspiboot");
 		break;
 	case ZYNQ_BM_NAND:
-		setenv("modeboot", "nandboot");
+		env_set("modeboot", "nandboot");
 		break;
 	case ZYNQ_BM_NOR:
-		setenv("modeboot", "norboot");
+		env_set("modeboot", "norboot");
 		break;
 	case ZYNQ_BM_SD:
-		setenv("modeboot", "sdboot");
+		env_set("modeboot", "sdboot");
 		break;
 	case ZYNQ_BM_JTAG:
-		setenv("modeboot", "jtagboot");
+		env_set("modeboot", "jtagboot");
 		break;
 	default:
-		setenv("modeboot", "");
+		env_set("modeboot", "");
 		break;
 	}
 
board/xilinx/zynqmp/zynqmp.c +1 -1
index 51a3d9f276..89ab24417d 100644
@@ -285,7 +285,7 @@ int board_late_init(void)
 				strlen(getenv("boot_targets")) + 2);
 
 	sprintf(new_targets, "%s %s", mode, getenv("boot_targets"));
-	setenv("boot_targets", new_targets);
+	env_set("boot_targets", new_targets);
 
 	return 0;
 }
cmd/fdt.c +13 -11
index 05e19f8a72..bd994317c8 100644
@@ -49,15 +49,15 @@ void set_working_fdt_addr(ulong addr)
 /*
  * Get a value from the fdt and format it to be set in the environment
  */
-static int fdt_value_setenv(const void *nodep, int len, const char *var)
+static int fdt_value_env_set(const void *nodep, int len, const char *var)
 {
 	if (is_printable_string(nodep, len))
-		setenv(var, (void *)nodep);
+		env_set(var, (void *)nodep);
 	else if (len == 4) {
 		char buf[11];
 
 		sprintf(buf, "0x%08X", fdt32_to_cpu(*(fdt32_t *)nodep));
-		setenv(var, buf);
+		env_set(var, buf);
 	} else if (len%4 == 0 && len <= 20) {
 		/* Needed to print things like sha1 hashes. */
 		char buf[41];
@@ -66,7 +66,7 @@ static int fdt_value_setenv(const void *nodep, int len, const char *var)
 		for (i = 0; i < len; i += sizeof(unsigned int))
 			sprintf(buf + (i * 2), "%08x",
 				*(unsigned int *)(nodep + i));
-		setenv(var, buf);
+		env_set(var, buf);
 	} else {
 		printf("error: unprintable value\n");
 		return 1;
@@ -358,10 +358,12 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				if (curDepth == startDepth + 1)
 					curIndex++;
 				if (subcmd[0] == 'n' && curIndex == reqIndex) {
-					const char *nodeName = fdt_get_name(
-					    working_fdt, nextNodeOffset, NULL);
+					const char *node_name;
 
-					setenv(var, (char *)nodeName);
+					node_name = fdt_get_name(working_fdt,
+								 nextNodeOffset,
+								 NULL);
+					env_set(var, node_name);
 					return 0;
 				}
 				nextNodeOffset = fdt_next_node(
@@ -382,13 +384,13 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				working_fdt, nodeoffset, prop, &len);
 			if (len == 0) {
 				/* no property value */
-				setenv(var, "");
+				env_set(var, "");
 				return 0;
 			} else if (nodep && len > 0) {
 				if (subcmd[0] == 'v') {
 					int ret;
 
-					ret = fdt_value_setenv(nodep, len, var);
+					ret = fdt_value_env_set(nodep, len, var);
 					if (ret != 0)
 						return ret;
 				} else if (subcmd[0] == 'a') {
@@ -396,13 +398,13 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 					char buf[11];
 
 					sprintf(buf, "0x%p", nodep);
-					setenv(var, buf);
+					env_set(var, buf);
 				} else if (subcmd[0] == 's') {
 					/* Get size */
 					char buf[11];
 
 					sprintf(buf, "0x%08X", len);
-					setenv(var, buf);
+					env_set(var, buf);
 				} else
 					return CMD_RET_USAGE;
 				return 0;
cmd/gpt.c +1 -1
index 3e98821868..cb76d5e540 100644
@@ -55,7 +55,7 @@ static int extract_env(const char *str, char **env)
 #ifdef CONFIG_RANDOM_UUID
 		debug("%s unset. ", str);
 		gen_rand_uuid_str(uuid_str, UUID_STR_FORMAT_GUID);
-		setenv(s, uuid_str);
+		env_set(s, uuid_str);
 
 		e = getenv(s);
 		if (e) {
cmd/ini.c +1 -1
index 727fd1c664..449f6e9f51 100644
@@ -219,7 +219,7 @@ static int ini_handler(void *user, char *section, char *name, char *value)
 		for (i = 0; i < strlen(value); i++)
 			value[i] = tolower(value[i]);
 #endif
-		setenv(name, value);
+		env_set(name, value);
 		printf("ini: Imported %s as %s\n", name, value);
 	}
 
cmd/md5sum.c +1 -1
index 23bb81e88c..1b2352ea55 100644
@@ -35,7 +35,7 @@ static void store_result(const u8 *sum, const char *dest)
 			sprintf(str_ptr, "%02x", sum[i]);
 			str_ptr += 2;
 		}
-		setenv(dest, str_output);
+		env_set(dest, str_output);
 	}
 }
 
cmd/mtdparts.c +13 -13
index 683c48bdad..a2433503c4 100644
@@ -246,12 +246,12 @@ static void index_partitions(void)
 		}
 
 		part = mtd_part_info(current_mtd_dev, current_mtd_partnum);
-		setenv("mtddevname", part->name);
+		env_set("mtddevname", part->name);
 
 		debug("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name);
 	} else {
-		setenv("mtddevnum", NULL);
-		setenv("mtddevname", NULL);
+		env_set("mtddevnum", NULL);
+		env_set("mtddevname", NULL);
 
 		debug("=> mtddevnum NULL\n=> mtddevname NULL\n");
 	}
@@ -270,12 +270,12 @@ static void current_save(void)
 		sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_mtd_dev->id->type),
 					current_mtd_dev->id->num, current_mtd_partnum);
 
-		setenv("partition", buf);
+		env_set("partition", buf);
 		strncpy(last_partition, buf, 16);
 
 		debug("=> partition %s\n", buf);
 	} else {
-		setenv("partition", NULL);
+		env_set("partition", NULL);
 		last_partition[0] = '\0';
 
 		debug("=> partition NULL\n");
@@ -1213,9 +1213,9 @@ static int generate_mtdparts_save(char *buf, u32 buflen)
 	ret = generate_mtdparts(buf, buflen);
 
 	if ((buf[0] != '\0') && (ret == 0))
-		setenv("mtdparts", buf);
+		env_set("mtdparts", buf);
 	else
-		setenv("mtdparts", NULL);
+		env_set("mtdparts", NULL);
 
 	return ret;
 }
@@ -1764,7 +1764,7 @@ int mtdparts_init(void)
 		if (mtdids_default) {
 			debug("mtdids variable not defined, using default\n");
 			ids = mtdids_default;
-			setenv("mtdids", (char *)ids);
+			env_set("mtdids", (char *)ids);
 		} else {
 			printf("mtdids not defined, no default present\n");
 			return 1;
@@ -1780,7 +1780,7 @@ int mtdparts_init(void)
 	if (!parts) {
 		if (mtdparts_default && use_defaults) {
 			parts = mtdparts_default;
-			if (setenv("mtdparts", (char *)parts) == 0)
+			if (env_set("mtdparts", (char *)parts) == 0)
 				use_defaults = 0;
 		} else
 			printf("mtdparts variable not set, see 'help mtdparts'\n");
@@ -1956,9 +1956,9 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
 {
 	if (argc == 2) {
 		if (strcmp(argv[1], "default") == 0) {
-			setenv("mtdids", NULL);
-			setenv("mtdparts", NULL);
-			setenv("partition", NULL);
+			env_set("mtdids", NULL);
+			env_set("mtdparts", NULL);
+			env_set("partition", NULL);
 			use_defaults = 1;
 
 			mtdparts_init();
@@ -1967,7 +1967,7 @@ static int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc,
 			/* this may be the first run, initialize lists if needed */
 			mtdparts_init();
 
-			setenv("mtdparts", NULL);
+			env_set("mtdparts", NULL);
 
 			/* mtd_devices_init() calls current_save() */
 			return mtd_devices_init();
cmd/net.c +17 -17
index df8b6c9b53..fa6d02f90d 100644
@@ -116,23 +116,23 @@ static void netboot_update_env(void)
 
 	if (net_gateway.s_addr) {
 		ip_to_string(net_gateway, tmp);
-		setenv("gatewayip", tmp);
+		env_set("gatewayip", tmp);
 	}
 
 	if (net_netmask.s_addr) {
 		ip_to_string(net_netmask, tmp);
-		setenv("netmask", tmp);
+		env_set("netmask", tmp);
 	}
 
 	if (net_hostname[0])
-		setenv("hostname", net_hostname);
+		env_set("hostname", net_hostname);
 
 	if (net_root_path[0])
-		setenv("rootpath", net_root_path);
+		env_set("rootpath", net_root_path);
 
 	if (net_ip.s_addr) {
 		ip_to_string(net_ip, tmp);
-		setenv("ipaddr", tmp);
+		env_set("ipaddr", tmp);
 	}
 #if !defined(CONFIG_BOOTP_SERVERIP)
 	/*
@@ -141,32 +141,32 @@ static void netboot_update_env(void)
 	 */
 	if (net_server_ip.s_addr) {
 		ip_to_string(net_server_ip, tmp);
-		setenv("serverip", tmp);
+		env_set("serverip", tmp);
 	}
 #endif
 	if (net_dns_server.s_addr) {
 		ip_to_string(net_dns_server, tmp);
-		setenv("dnsip", tmp);
+		env_set("dnsip", tmp);
 	}
 #if defined(CONFIG_BOOTP_DNS2)
 	if (net_dns_server2.s_addr) {
 		ip_to_string(net_dns_server2, tmp);
-		setenv("dnsip2", tmp);
+		env_set("dnsip2", tmp);
 	}
 #endif
 	if (net_nis_domain[0])
-		setenv("domain", net_nis_domain);
+		env_set("domain", net_nis_domain);
 
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
 	if (net_ntp_time_offset) {
 		sprintf(tmp, "%d", net_ntp_time_offset);
-		setenv("timeoffset", tmp);
+		env_set("timeoffset", tmp);
 	}
 #endif
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
 	if (net_ntp_server.s_addr) {
 		ip_to_string(net_ntp_server, tmp);
-		setenv("ntpserverip", tmp);
+		env_set("ntpserverip", tmp);
 	}
 #endif
 }
@@ -291,14 +291,14 @@ static void cdp_update_env(void)
 		printf("CDP offered appliance VLAN %d\n",
 		       ntohs(cdp_appliance_vlan));
 		vlan_to_string(cdp_appliance_vlan, tmp);
-		setenv("vlan", tmp);
+		env_set("vlan", tmp);
 		net_our_vlan = cdp_appliance_vlan;
 	}
 
 	if (cdp_native_vlan != htons(-1)) {
 		printf("CDP offered native VLAN %d\n", ntohs(cdp_native_vlan));
 		vlan_to_string(cdp_native_vlan, tmp);
-		setenv("nvlan", tmp);
+		env_set("nvlan", tmp);
 		net_native_vlan = cdp_native_vlan;
 	}
 }
@@ -423,14 +423,14 @@ static int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	net_gateway.s_addr = 0;
 	ip_to_string(net_gateway, tmp);
-	setenv("gatewayip", tmp);
+	env_set("gatewayip", tmp);
 
 	ip_to_string(net_netmask, tmp);
-	setenv("netmask", tmp);
+	env_set("netmask", tmp);
 
 	ip_to_string(net_ip, tmp);
-	setenv("ipaddr", tmp);
-	setenv("llipaddr", tmp); /* store this for next time */
+	env_set("ipaddr", tmp);
+	env_set("llipaddr", tmp); /* store this for next time */
 
 	return CMD_RET_SUCCESS;
 }
cmd/nvedit.c +4 -4
index 4431ef66d8..1b1e9667b5 100644
@@ -283,7 +283,7 @@ static int _do_env_set(int flag, int argc, char * const argv[], int env_flag)
 	return 0;
 }
 
-int setenv(const char *varname, const char *varvalue)
+int env_set(const char *varname, const char *varvalue)
 {
 	const char * const argv[4] = { "setenv", varname, varvalue, NULL };
 
@@ -309,7 +309,7 @@ int setenv_ulong(const char *varname, ulong value)
 	/* TODO: this should be unsigned */
 	char *str = simple_itoa(value);
 
-	return setenv(varname, str);
+	return env_set(varname, str);
 }
 
 /**
@@ -324,7 +324,7 @@ int setenv_hex(const char *varname, ulong value)
 	char str[17];
 
 	sprintf(str, "%lx", value);
-	return setenv(varname, str);
+	return env_set(varname, str);
 }
 
 ulong getenv_hex(const char *varname, ulong default_val)
@@ -931,7 +931,7 @@ NXTARG:		;
 			return 1;
 		}
 		sprintf(buf, "%zX", (size_t)len);
-		setenv("filesize", buf);
+		env_set("filesize", buf);
 
 		return 0;
 	}
cmd/part.c +4 -4
index 8ba05984e4..746bf40b2d 100644
@@ -38,7 +38,7 @@ static int do_part_uuid(int argc, char * const argv[])
 		return 1;
 
 	if (argc > 2)
-		setenv(argv[2], info.uuid);
+		env_set(argv[2], info.uuid);
 	else
 		printf("%s\n", info.uuid);
 
@@ -99,7 +99,7 @@ static int do_part_list(int argc, char * const argv[])
 			sprintf(t, "%s%x", str[0] ? " " : "", p);
 			strcat(str, t);
 		}
-		setenv(var, str);
+		env_set(var, str);
 		return 0;
 	}
 
@@ -135,7 +135,7 @@ static int do_part_start(int argc, char * const argv[])
 	snprintf(buf, sizeof(buf), LBAF, info.start);
 
 	if (argc > 3)
-		setenv(argv[3], buf);
+		env_set(argv[3], buf);
 	else
 		printf("%s\n", buf);
 
@@ -169,7 +169,7 @@ static int do_part_size(int argc, char * const argv[])
 	snprintf(buf, sizeof(buf), LBAF, info.size);
 
 	if (argc > 3)
-		setenv(argv[3], buf);
+		env_set(argv[3], buf);
 	else
 		printf("%s\n", buf);
 
cmd/pxe.c +3 -3
index 0a07f14ca8..357b96940c 100644
@@ -591,7 +591,7 @@ static int label_localboot(struct pxe_label *label)
 		char bootargs[CONFIG_SYS_CBSIZE];
 
 		cli_simple_process_macros(label->append, bootargs);
-		setenv("bootargs", bootargs);
+		env_set("bootargs", bootargs);
 	}
 
 	debug("running: %s\n", localcmd);
@@ -695,7 +695,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		strcat(bootargs, mac_str);
 
 		cli_simple_process_macros(bootargs, finalbootargs);
-		setenv("bootargs", finalbootargs);
+		env_set("bootargs", finalbootargs);
 		printf("append: %s\n", finalbootargs);
 	}
 
@@ -1674,7 +1674,7 @@ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		filename = getenv("bootfile");
 	else {
 		filename = argv[5];
-		setenv("bootfile", filename);
+		env_set("bootfile", filename);
 	}
 
 	if (strstr(argv[3], "ext2"))
cmd/qfw.c +1 -1
index 12436ec9b4..9b12ab40ca 100644
@@ -55,7 +55,7 @@ static int qemu_fwcfg_setup_kernel(void *load_addr, void *initrd_addr)
 		 * when invoking qemu), do not update bootargs
 		 */
 		if (*data_addr != '\0') {
-			if (setenv("bootargs", data_addr) < 0)
+			if (env_set("bootargs", data_addr) < 0)
 				printf("warning: unable to change bootargs\n");
 		}
 	}
cmd/setexpr.c +2 -2
index e7194fc4f4..e9058c4a0a 100644
@@ -282,11 +282,11 @@ static int regex_sub(const char *name,
 		if (!global)
 			break;
 	}
-	debug("## FINAL (now setenv()) :  %s\n", data);
+	debug("## FINAL (now env_set()) :  %s\n", data);
 
 	printf("%s=%s\n", name, data);
 
-	return setenv(name, data);
+	return env_set(name, data);
 }
 #endif
 
common/board_r.c +1 -1
index 985aa95c2a..a4a7384f8b 100644
@@ -658,7 +658,7 @@ int initr_mem(void)
 	pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024;
 # endif
 	sprintf(memsz, "%ldk", (long int) ((gd->ram_size / 1024) - pram));
-	setenv("mem", memsz);
+	env_set("mem", memsz);
 
 	return 0;
 }
common/bootm.c +1 -1
index b2c09126ce..f5ecc06d52 100644
@@ -569,7 +569,7 @@ static void fixup_silent_linux(void)
 		env_val = CONSOLE_ARG;
 	}
 
-	setenv("bootargs", env_val);
+	env_set("bootargs", env_val);
 	debug("after silent fix-up: %s\n", env_val);
 	free(buf);
 }
common/cli_hush.c +1 -1
index 00861e2d9e..280289639c 100644
@@ -2265,7 +2265,7 @@ void unset_local_var(const char *name)
 			} else {
 #ifndef __U_BOOT__
 				if(cur->flg_export)
-					unsetenv(cur->name);
+					unenv_set(cur->name);
 #endif
 				free(cur->name);
 				free(cur->value);
common/console.c +2 -2
index 01eef5594f..daf155500d 100644
@@ -777,7 +777,7 @@ done:
 #ifdef CONFIG_SYS_CONSOLE_ENV_OVERWRITE
 	/* set the environment variables (will overwrite previous env settings) */
 	for (i = 0; i < 3; i++) {
-		setenv(stdio_names[i], stdio_devices[i]->name);
+		env_set(stdio_names[i], stdio_devices[i]->name);
 	}
 #endif /* CONFIG_SYS_CONSOLE_ENV_OVERWRITE */
 
@@ -856,7 +856,7 @@ int console_init_r(void)
 
 	/* Setting environment variables */
 	for (i = 0; i < 3; i++) {
-		setenv(stdio_names[i], stdio_devices[i]->name);
+		env_set(stdio_names[i], stdio_devices[i]->name);
 	}
 
 	gd->flags |= GD_FLG_DEVINIT;	/* device initialization completed */
common/hash.c +1 -1
index 771d8fa87f..fda636d34a 100644
@@ -302,7 +302,7 @@ static void store_result(struct hash_algo *algo, const uint8_t *sum,
 			str_ptr += 2;
 		}
 		*str_ptr = '\0';
-		setenv(dest, str_output);
+		env_set(dest, str_output);
 	} else {
 		ulong addr;
 		void *buf;
common/hwconfig.c +2 -2
index 4ae042ee33..85aaabbb85 100644
@@ -243,7 +243,7 @@ int main()
 	const char *ret;
 	size_t len;
 
-	setenv("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
+	env_set("hwconfig", "key1:subkey1=value1,subkey2=value2;key2:value3;;;;"
 			   "key3;:,:=;key4", 1);
 
 	ret = hwconfig_arg("key1", &len);
@@ -274,7 +274,7 @@ int main()
 	assert(hwconfig_arg("key4", &len) == NULL);
 	assert(hwconfig_arg("bogus", &len) == NULL);
 
-	unsetenv("hwconfig");
+	unenv_set("hwconfig");
 
 	assert(hwconfig(NULL) == 0);
 	assert(hwconfig("") == 0);
common/image-android.c +1 -1
index c668407817..018c7594fe 100644
@@ -90,7 +90,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
 	if (*hdr->cmdline)
 		strcat(newbootargs, hdr->cmdline);
 
-	setenv("bootargs", newbootargs);
+	env_set("bootargs", newbootargs);
 
 	if (os_data) {
 		*os_data = (ulong)hdr;
common/main.c +1 -1
index 2116a9e0a2..07fc31b716 100644
@@ -48,7 +48,7 @@ void main_loop(void)
 	bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
 
 #ifdef CONFIG_VERSION_VARIABLE
-	setenv("ver", version_string);  /* set version variable */
+	env_set("ver", version_string);  /* set version variable */
 #endif /* CONFIG_VERSION_VARIABLE */
 
 	cli_init();
common/spl/Kconfig +1 -1
index 4de81392b0..60a73311d9 100644
@@ -249,7 +249,7 @@ config SPL_ENV_SUPPORT
 	  configuration. But some boards use this to support 'Falcon' boot
 	  on EXT2 and FAT, where SPL boots directly into Linux without
 	  starting U-Boot first. Enabling this option will make getenv()
-	  and setenv() available in SPL.
+	  and env_set() available in SPL.
 
 config SPL_SAVEENV
 	bool "Support save environment"
common/spl/spl_dfu.c +1 -1
index e8d0ba18e6..f5ec0fb396 100644
@@ -46,7 +46,7 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
 		return -EINVAL;
 	}
 
-	ret = setenv("dfu_alt_info", str_env);
+	ret = env_set("dfu_alt_info", str_env);
 	if (ret) {
 		error("unable to set env variable \"dfu_alt_info\"!\n");
 		return -EINVAL;
common/spl/spl_net.c +2 -2
index 85fe508b17..88831097fa 100644
@@ -33,14 +33,14 @@ static int spl_net_load_image(struct spl_image_info *spl_image,
 
 	env_init();
 	env_relocate();
-	setenv("autoload", "yes");
+	env_set("autoload", "yes");
 	rv = eth_initialize();
 	if (rv == 0) {
 		printf("No Ethernet devices found\n");
 		return -ENODEV;
 	}
 	if (bootdev->boot_device_name)
-		setenv("ethact", bootdev->boot_device_name);
+		env_set("ethact", bootdev->boot_device_name);
 	rv = net_loop(BOOTP);
 	if (rv < 0) {
 		printf("Problem booting with BOOTP\n");
common/update.c +2 -2
index 0767fcbcb5..061a5541b1 100644
@@ -67,7 +67,7 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
 	tftp_timeout_count_max = cnt_max;
 
 	/* we don't want to retry the connection if errors occur */
-	setenv("netretry", "no");
+	env_set("netretry", "no");
 
 	/* download the update file */
 	load_addr = addr;
@@ -83,7 +83,7 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
 	tftp_timeout_ms = saved_timeout_msecs;
 	tftp_timeout_count_max = saved_timeout_count;
 
-	setenv("netretry", saved_netretry);
+	env_set("netretry", saved_netretry);
 	if (saved_netretry != NULL)
 		free(saved_netretry);
 
doc/README.enetaddr +1 -1
index 50e4899787..bf994d4e41 100644
@@ -101,7 +101,7 @@ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 	* int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
 
 Store the MAC address into the named environment variable.  The return value is
-the same as the setenv() function.
+the same as the env_set() function.
 uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
 eth_setenv_enetaddr("ethaddr", enetaddr);
 /* the "ethaddr" env var should now be set to "00:11:22:33:44:55" */
drivers/mtd/dataflash.c +4 -3
index 2d2c318adf..e961f518b0 100644
@@ -155,7 +155,7 @@ int AT91F_DataflashInit (void)
 	return found[0];
 }
 
-void AT91F_DataflashSetEnv (void)
+void AT91F_Dataflashenv_set(void)
 {
 	int i, j;
 	int part;
@@ -169,8 +169,9 @@ void AT91F_DataflashSetEnv (void)
 			/* Set the environment according to the label...*/
 			if((env & FLAG_SETENV) == FLAG_SETENV) {
 				start = dataflash_info[i].Device.area_list[j].start;
-				sprintf((char*) s,"%lX",start);
-				setenv((char*) area_list[part].label,(char*) s);
+				sprintf((char *)s, "%lX", start);
+				env_set((char *)area_list[part].label,
+					(char *)s);
 			}
 			part++;
 		}
drivers/net/sandbox-raw.c +2 -2
index f5fa0e8533..590ae0c0fc 100644
@@ -33,8 +33,8 @@ static int sb_eth_raw_start(struct udevice *dev)
 
 	if (strcmp(interface, "lo") == 0) {
 		priv->local = 1;
-		setenv("ipaddr", "127.0.0.1");
-		setenv("serverip", "127.0.0.1");
+		env_set("ipaddr", "127.0.0.1");
+		env_set("serverip", "127.0.0.1");
 	}
 	return sandbox_eth_raw_os_start(interface, pdata->enetaddr, priv);
 }
fs/fs.c +2 -2
index 595ff1fe69..ef41b74826 100644
@@ -509,7 +509,7 @@ int do_fs_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 		return CMD_RET_FAILURE;
 
 	if (argc == 4)
-		setenv(argv[3], uuid);
+		env_set(argv[3], uuid);
 	else
 		printf("%s\n", uuid);
 
@@ -529,7 +529,7 @@ int do_fs_type(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	info = fs_get_info(fs_type);
 
 	if (argc == 4)
-		setenv(argv[3], info->name);
+		env_set(argv[3], info->name);
 	else
 		printf("%s\n", info->name);
 
include/_exports.h +1 -1
index 6ff4364e44..9deed77378 100644
@@ -32,7 +32,7 @@
 	EXPORT_FUNC(do_reset, int, do_reset, cmd_tbl_t *,
 		    int , int , char * const [])
 	EXPORT_FUNC(getenv, char  *, getenv, const char*)
-	EXPORT_FUNC(setenv, int, setenv, const char *, const char *)
+	EXPORT_FUNC(env_set, int, env_set, const char *, const char *)
 	EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul,
 		    const char *, char **, unsigned int)
 	EXPORT_FUNC(strict_strtoul, int, strict_strtoul,
include/common.h +13 -1
index f0fc02cd3b..fdbb07bffe 100644
@@ -335,7 +335,19 @@ ulong getenv_hex(const char *varname, ulong default_val);
  * Return -1 if variable does not exist (default to true)
  */
 int getenv_yesno(const char *var);
-int	setenv	     (const char *, const char *);
+
+/**
+ * env_set() - set an environment variable
+ *
+ * This sets or deletes the value of an environment variable. For setting the
+ * value the variable is created if it does not already exist.
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable, or NULL or "" to delete the variable
+ * @return 0 if OK, 1 on error
+ */
+int env_set(const char *varname, const char *value);
+
 int setenv_ulong(const char *varname, ulong value);
 int setenv_hex(const char *varname, ulong value);
 /**
include/configs/tam3517-common.h +1 -1
index fb173ebfb4..f33465508e 100644
@@ -340,7 +340,7 @@ do {								\
 		else						\
 			strcpy(ethname, "ethaddr");		\
 		printf("Setting %s from EEPROM with %s\n", ethname, buf);\
-		setenv(ethname, buf);				\
+		env_set(ethname, buf);				\
 	}							\
 } while (0)
 
include/dataflash.h +1 -1
index 84a56c30ce..c9f22200cf 100644
@@ -197,7 +197,7 @@ extern int AT91F_DataflashInit(void);
 
 extern void dataflash_print_info (void);
 extern void dataflash_perror (int err);
-extern void AT91F_DataflashSetEnv (void);
+extern void AT91F_Dataflashenv_set(void);
 
 extern struct dataflash_addr cs[CONFIG_SYS_MAX_DATAFLASH_BANKS];
 extern dataflash_protect_t area_list[NB_DATAFLASH_AREA];
include/exports.h +1 -1
index 1d81bc4b28..6522d78fac 100644
@@ -28,7 +28,7 @@ int vprintf(const char *, va_list);
 unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base);
 int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
 char *getenv (const char *name);
-int setenv (const char *varname, const char *varvalue);
+int env_set(const char *varname, const char *value);
 long simple_strtol(const char *cp, char **endp, unsigned int base);
 int strcmp(const char *cs, const char *ct);
 unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
include/search.h +1 -1
index 402dfd84fb..df5d61c2eb 100644
@@ -118,7 +118,7 @@ extern int hwalk_r(struct hsearch_data *__htab, int (*callback)(ENTRY *));
 #define H_MATCH_SUBSTR	(1 << 7) /* search for substring matches	     */
 #define H_MATCH_REGEX	(1 << 8) /* search for regular expression matches    */
 #define H_MATCH_METHOD	(H_MATCH_IDENT | H_MATCH_SUBSTR | H_MATCH_REGEX)
-#define H_PROGRAMMATIC	(1 << 9) /* indicate that an import is from setenv() */
+#define H_PROGRAMMATIC	(1 << 9) /* indicate that an import is from env_set() */
 #define H_ORIGIN_FLAGS	(H_INTERACTIVE | H_PROGRAMMATIC)
 
 #endif /* _SEARCH_H_ */
lib/uuid.c +1 -1
index c8584edcb8..1536c027da 100644
@@ -291,7 +291,7 @@ int do_uuid(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc == 1)
 		printf("%s\n", uuid);
 	else
-		setenv(argv[1], uuid);
+		env_set(argv[1], uuid);
 
 	return CMD_RET_SUCCESS;
 }
net/arp.c +1 -1
index f3ceff9ed8..4c79e09ccb 100644
@@ -194,7 +194,7 @@ void arp_receive(struct ethernet_hdr *et, struct ip_udp_hdr *ip, int len)
 		if (net_server_ip.s_addr == net_arp_wait_packet_ip.s_addr) {
 			char buf[20];
 			sprintf(buf, "%pM", &arp->ar_sha);
-			setenv("serveraddr", buf);
+			env_set("serveraddr", buf);
 		}
 #endif
 
net/bootp.c +1 -1
index be8f710e0c..579515687b 100644
@@ -170,7 +170,7 @@ static void store_net_params(struct bootp_hdr *bp)
 	 * not contain a new value
 	 */
 	if (*net_boot_file_name)
-		setenv("bootfile", net_boot_file_name);
+		env_set("bootfile", net_boot_file_name);
 #endif
 	net_copy_ip(&net_ip, &bp->bp_yiaddr);
 }
net/dns.c +1 -1
index 7017bac75a..eee8a02f7c 100644
@@ -184,7 +184,7 @@ static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
 			ip_to_string(ip_addr, ip_str);
 			printf("%s\n", ip_str);
 			if (net_dns_env_var)
-				setenv(net_dns_env_var, ip_str);
+				env_set(net_dns_env_var, ip_str);
 		} else {
 			puts("server responded with invalid IP number\n");
 		}
net/eth_common.c +3 -3
index 58fa295771..ef97da7267 100644
@@ -39,7 +39,7 @@ int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
 
 	sprintf(buf, "%pM", enetaddr);
 
-	return setenv(name, buf);
+	return env_set(name, buf);
 }
 
 int eth_getenv_enetaddr_by_index(const char *base_name, int index,
@@ -97,14 +97,14 @@ void eth_current_changed(void)
 	/* update current ethernet name */
 	if (eth_get_dev()) {
 		if (act == NULL || strcmp(act, eth_get_name()) != 0)
-			setenv("ethact", eth_get_name());
+			env_set("ethact", eth_get_name());
 	}
 	/*
 	 * remove the variable completely if there is no active
 	 * interface
 	 */
 	else if (act != NULL)
-		setenv("ethact", NULL);
+		env_set("ethact", NULL);
 }
 
 void eth_try_another(int first_restart)
test/dm/eth.c +36 -36

188 lines not on this page · raw message

tools/env/fw_env.c +1 -1
index c9c79e066d..e50c075559 100644
@@ -468,7 +468,7 @@ int fw_env_write(char *name, char *value)
  *	    modified or deleted
  *
  */
-int fw_setenv(int argc, char *argv[], struct env_opts *opts)
+int fw_env_set(int argc, char *argv[], struct env_opts *opts)
 {
 	int i;
 	size_t len;
tools/env/fw_env.h +2 -2
index 04bb64602b..2d37eb5053 100644
@@ -44,7 +44,7 @@ int parse_aes_key(char *key, uint8_t *bin_key);
 int fw_printenv(int argc, char *argv[], int value_only, struct env_opts *opts);
 
 /**
- * fw_setenv() - adds or removes one variable to the environment
+ * fw_env_set() - adds or removes one variable to the environment
  *
  * @argc: number of strings in argv, argv[0] is variable name,
  *          argc==1 means erase variable, argc > 1 means add a variable
@@ -61,7 +61,7 @@ int fw_printenv(int argc, char *argv[], int value_only, struct env_opts *opts);
  * ERRORS:
  *  EROFS - some variables ("ethaddr", "serial#") cannot be modified
  */
-int fw_setenv(int argc, char *argv[], struct env_opts *opts);
+int fw_env_set(int argc, char *argv[], struct env_opts *opts);
 
 /**
  * fw_parse_script() - adds or removes multiple variables with a batch script
tools/env/fw_env_main.c +4 -4
index b8bff264eb..6e278ca80b 100644
@@ -78,7 +78,7 @@ void usage_printenv(void)
 		"\n");
 }
 
-void usage_setenv(void)
+void usage_env_set(void)
 {
 	fprintf(stderr,
 		"Usage: fw_setenv [OPTIONS]... [VARIABLE]...\n"
@@ -142,7 +142,7 @@ static void parse_common_args(int argc, char *argv[])
 			env_opts.lockname = optarg;
 			break;
 		case 'h':
-			do_printenv ? usage_printenv() : usage_setenv();
+			do_printenv ? usage_printenv() : usage_env_set();
 			exit(EXIT_SUCCESS);
 			break;
 		default:
@@ -202,7 +202,7 @@ int parse_setenv_args(int argc, char *argv[])
 			/* ignore common options */
 			break;
 		default: /* '?' */
-			usage_setenv();
+			usage_env_set();
 			exit(EXIT_FAILURE);
 			break;
 		}
@@ -273,7 +273,7 @@ int main(int argc, char *argv[])
 			retval = EXIT_FAILURE;
 	} else {
 		if (!script_file) {
-			if (fw_setenv(argc, argv, &env_opts) != 0)
+			if (fw_env_set(argc, argv, &env_opts) != 0)
 				retval = EXIT_FAILURE;
 		} else {
 			if (fw_parse_script(script_file, &env_opts) != 0)
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#22 lore raw

PATCH v4 22/29 env: Rename common functions related to setenv()

In reply to Simon Glass

We are now using an env_ prefix for environment functions. Rename these commonly used functions, for consistency. Also add function comments in common.h.

---

Changes in v4:
- Split out changes to setenv_ulong(), etc. into a new patch

Changes in v3: None
Changes in v2:
- Add new patch to rename setenv() and friends to env_set()

 api/api.c                                    |  2 +-
 arch/arm/mach-tegra/tegra186/nvtboot_board.c |  2 +-
 arch/arm/mach-uniphier/mmc-first-dev.c       |  2 +-
 board/boundary/nitrogen6x/nitrogen6x.c       |  2 +-
 board/engicam/common/board.c                 |  2 +-
 board/freescale/qemu-ppce500/qemu-ppce500.c  |  4 ++--
 board/grinn/liteboard/board.c                |  2 +-
 board/raspberrypi/rpi/rpi.c                  |  2 +-
 board/sunxi/board.c                          |  2 +-
 cmd/cbfs.c                                   |  2 +-
 cmd/cramfs.c                                 |  2 +-
 cmd/fdt.c                                    |  4 ++--
 cmd/jffs2.c                                  |  2 +-
 cmd/load.c                                   |  6 +++---
 cmd/lzmadec.c                                |  2 +-
 cmd/mtdparts.c                               |  2 +-
 cmd/nand.c                                   |  6 +++---
 cmd/nvedit.c                                 |  6 +++---
 cmd/reiser.c                                 |  2 +-
 cmd/setexpr.c                                |  4 ++--
 cmd/tpm.c                                    |  4 ++--
 cmd/trace.c                                  | 12 ++++++------
 cmd/unzip.c                                  |  2 +-
 cmd/ximg.c                                   |  4 ++--
 cmd/zfs.c                                    |  2 +-
 cmd/zip.c                                    |  2 +-
 common/autoboot.c                            |  6 +++---
 common/board_r.c                             |  2 +-
 common/bootm.c                               |  4 ++--
 common/bootm_os.c                            |  2 +-
 drivers/bootcount/bootcount_env.c            |  2 +-
 drivers/net/fm/fm.c                          |  2 +-
 drivers/scsi/scsi.c                          |  2 +-
 fs/fs.c                                      |  6 +++---
 fs/ubifs/ubifs.c                             |  2 +-
 include/common.h                             | 26 +++++++++++++++++++++-----
 net/net.c                                    |  4 ++--
 37 files changed, 79 insertions(+), 63 deletions(-)
api/api.c +1 -1
index 423fb6b0c1..2e620e2a0f 100644
@@ -663,7 +663,7 @@ void api_init(void)
 		return;
 	}
 
-	setenv_hex("api_address", (unsigned long)sig);
+	env_set_hex("api_address", (unsigned long)sig);
 	debugf("API sig @ 0x%lX\n", (unsigned long)sig);
 	memcpy(sig->magic, API_SIG_MAGIC, 8);
 	sig->version = API_SIG_VERSION;
arch/arm/mach-tegra/tegra186/nvtboot_board.c +1 -1
index 56650efd4f..9cd3fe2f30 100644
@@ -15,7 +15,7 @@ static int set_fdt_addr(void)
 {
 	int ret;
 
-	ret = setenv_hex("fdt_addr", nvtboot_boot_x0);
+	ret = env_set_hex("fdt_addr", nvtboot_boot_x0);
 	if (ret) {
 		printf("Failed to set fdt_addr to point at DTB: %d\n", ret);
 		return ret;
arch/arm/mach-uniphier/mmc-first-dev.c +1 -1
index 8c45229a89..acc859a6c3 100644
@@ -35,7 +35,7 @@ static int do_mmcsetn(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (dev < 0)
 		return CMD_RET_FAILURE;
 
-	setenv_ulong("mmc_first_dev", dev);
+	env_set_ulong("mmc_first_dev", dev);
 	return CMD_RET_SUCCESS;
 }
 
board/boundary/nitrogen6x/nitrogen6x.c +1 -1
index c04926c0bb..0e2c4fc0ef 100644
@@ -1021,6 +1021,6 @@ int misc_init_r(void)
 #ifdef CONFIG_CMD_BMODE
 	add_board_boot_modes(board_boot_modes);
 #endif
-	setenv_hex("reset_cause", get_imx_reset_cause());
+	env_set_hex("reset_cause", get_imx_reset_cause());
 	return 0;
 }
board/engicam/common/board.c +1 -1
index 56112d3459..c7ec55ff82 100644
@@ -21,7 +21,7 @@ static void mmc_late_init(void)
 	char mmcblk[32];
 	u32 dev_no = mmc_get_env_dev();
 
-	setenv_ulong("mmcdev", dev_no);
+	env_set_ulong("mmcdev", dev_no);
 
 	/* Set mmcblk env */
 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
board/freescale/qemu-ppce500/qemu-ppce500.c +2 -2
index 6cb5692eda..d40e62af4f 100644
@@ -205,10 +205,10 @@ int last_stage_init(void)
 	/* -kernel boot */
 	prop = fdt_getprop(fdt, chosen, "qemu,boot-kernel", &len);
 	if (prop && (len >= 8))
-		setenv_hex("qemu_kernel_addr", *prop);
+		env_set_hex("qemu_kernel_addr", *prop);
 
 	/* Give the user a variable for the host fdt */
-	setenv_hex("fdt_addr_r", (ulong)fdt);
+	env_set_hex("fdt_addr_r", (ulong)fdt);
 
 	return 0;
 }
board/grinn/liteboard/board.c +1 -1
index 835be99b96..24956927ac 100644
@@ -168,7 +168,7 @@ void board_late_mmc_init(void)
 	if (!check_mmc_autodetect())
 		return;
 
-	setenv_ulong("mmcdev", dev_no);
+	env_set_ulong("mmcdev", dev_no);
 
 	/* Set mmcblk env */
 	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
board/raspberrypi/rpi/rpi.c +1 -1
index c1985fd418..aaa3a42abf 100644
@@ -266,7 +266,7 @@ static void set_fdt_addr(void)
 	if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
 		return;
 
-	setenv_hex("fdt_addr", fw_dtb_pointer);
+	env_set_hex("fdt_addr", fw_dtb_pointer);
 }
 
 /*
board/sunxi/board.c +1 -1
index b1fcd9d0b9..92fa6c8974 100644
@@ -646,7 +646,7 @@ static void parse_spl_header(const uint32_t spl_addr)
 		return;
 	}
 	/* otherwise assume .scr format (mkimage-type script) */
-	setenv_hex("fel_scriptaddr", spl->fel_script_address);
+	env_set_hex("fel_scriptaddr", spl->fel_script_address);
 }
 
 /*
cmd/cbfs.c +1 -1
index 95a11a3616..799ba01fcc 100644
@@ -80,7 +80,7 @@ static int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc,
 
 	printf("\n%ld bytes read\n", size);
 
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return 0;
 }
cmd/cramfs.c +1 -1
index 49ee36c74a..7b23c5b3dd 100644
@@ -138,7 +138,7 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (size > 0) {
 		printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n",
 			size, offset);
-		setenv_hex("filesize", size);
+		env_set_hex("filesize", size);
 	} else {
 		printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename);
 	}
cmd/fdt.c +2 -2
index bd994317c8..ac5c6c4f90 100644
@@ -43,7 +43,7 @@ void set_working_fdt_addr(ulong addr)
 
 	buf = map_sysmem(addr, 0);
 	working_fdt = buf;
-	setenv_hex("fdtaddr", addr);
+	env_set_hex("fdtaddr", addr);
 }
 
 /*
@@ -373,7 +373,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			}
 			if (subcmd[0] == 's') {
 				/* get the num nodes at this level */
-				setenv_ulong(var, curIndex + 1);
+				env_set_ulong(var, curIndex + 1);
 			} else {
 				/* node index not found */
 				printf("libfdt node not found\n");
cmd/jffs2.c +1 -1
index dc94705ccd..add89dee6a 100644
@@ -512,7 +512,7 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (size > 0) {
 			printf("### %s load complete: %d bytes loaded to 0x%lx\n",
 				fsname, size, offset);
-			setenv_hex("filesize", size);
+			env_set_hex("filesize", size);
 		} else {
 			printf("### %s LOAD ERROR<%x> for %s!\n", fsname, size, filename);
 		}
cmd/load.c +3 -3
index 4597ec5618..ec3730e0f6 100644
@@ -182,7 +182,7 @@ static ulong load_serial(long offset)
 			    start_addr, end_addr, size, size
 		    );
 		    flush_cache(start_addr, size);
-		    setenv_hex("filesize", size);
+		    env_set_hex("filesize", size);
 		    return (addr);
 		case SREC_START:
 		    break;
@@ -529,7 +529,7 @@ static ulong load_serial_bin(ulong offset)
 	flush_cache(offset, size);
 
 	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return offset;
 }
@@ -1000,7 +1000,7 @@ static ulong load_serial_ymodem(ulong offset, int mode)
 	flush_cache(offset, ALIGN(size, ARCH_DMA_MINALIGN));
 
 	printf("## Total Size      = 0x%08x = %d Bytes\n", size, size);
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return offset;
 }
cmd/lzmadec.c +1 -1
index c78df825e8..1b482edb58 100644
@@ -42,7 +42,7 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		return 1;
 	printf("Uncompressed size: %ld = %#lX\n", (ulong)src_len,
 	       (ulong)src_len);
-	setenv_hex("filesize", src_len);
+	env_set_hex("filesize", src_len);
 
 	return 0;
 }
cmd/mtdparts.c +1 -1
index a2433503c4..d3fde77ef0 100644
@@ -239,7 +239,7 @@ static void index_partitions(void)
 			dev = list_entry(dentry, struct mtd_device, link);
 			if (dev == current_mtd_dev) {
 				mtddevnum += current_mtd_partnum;
-				setenv_ulong("mtddevnum", mtddevnum);
+				env_set_ulong("mtddevnum", mtddevnum);
 				break;
 			}
 			mtddevnum += dev->num_parts;
cmd/nand.c +3 -3
index a2152ec826..0f5d431e5c 100644
@@ -305,9 +305,9 @@ static void nand_print_and_set_info(int idx)
 	printf("  bbt options 0x%08x\n", chip->bbt_options);
 
 	/* Set geometry info */
-	setenv_hex("nand_writesize", mtd->writesize);
-	setenv_hex("nand_oobsize", mtd->oobsize);
-	setenv_hex("nand_erasesize", mtd->erasesize);
+	env_set_hex("nand_writesize", mtd->writesize);
+	env_set_hex("nand_oobsize", mtd->oobsize);
+	env_set_hex("nand_erasesize", mtd->erasesize);
 }
 
 static int raw_access(struct mtd_info *mtd, ulong addr, loff_t off,
cmd/nvedit.c +3 -3
index 1b1e9667b5..a649004850 100644
@@ -304,7 +304,7 @@ int env_set(const char *varname, const char *varvalue)
  * @param value		Value to set it to
  * @return 0 if ok, 1 on error
  */
-int setenv_ulong(const char *varname, ulong value)
+int env_set_ulong(const char *varname, ulong value)
 {
 	/* TODO: this should be unsigned */
 	char *str = simple_itoa(value);
@@ -319,7 +319,7 @@ int setenv_ulong(const char *varname, ulong value)
  * @param value		Value to set it to
  * @return 0 if ok, 1 on error
  */
-int setenv_hex(const char *varname, ulong value)
+int env_set_hex(const char *varname, ulong value)
 {
 	char str[17];
 
@@ -957,7 +957,7 @@ NXTARG:		;
 		envp->flags = ACTIVE_FLAG;
 #endif
 	}
-	setenv_hex("filesize", len + offsetof(env_t, data));
+	env_set_hex("filesize", len + offsetof(env_t, data));
 
 	return 0;
 
cmd/reiser.c +1 -1
index 9c3e9e9e58..4df9c5f5db 100644
@@ -157,7 +157,7 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	load_addr = addr;
 
 	printf ("\n%ld bytes read\n", filelen);
-	setenv_hex("filesize", filelen);
+	env_set_hex("filesize", filelen);
 
 	return filelen;
 }
cmd/setexpr.c +2 -2
index e9058c4a0a..91a5a9a770 100644
@@ -314,7 +314,7 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* plain assignment: "setexpr name value" */
 	if (argc == 3) {
-		setenv_hex(argv[1], a);
+		env_set_hex(argv[1], a);
 		return 0;
 	}
 
@@ -370,7 +370,7 @@ static int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 	}
 
-	setenv_hex(argv[1], value);
+	env_set_hex(argv[1], value);
 
 	return 0;
 }
cmd/tpm.c +2 -2
index 0c4bc73ca6..d9b433582c 100644
@@ -231,7 +231,7 @@ static int type_string_write_vars(const char *type_str, uint8_t *data,
 		default:
 			return -1;
 		}
-		if (setenv_ulong(*vars, value))
+		if (env_set_ulong(*vars, value))
 			return -1;
 	}
 
@@ -624,7 +624,7 @@ static int do_tpm_load_key_by_sha1(cmd_tbl_t *cmdtp, int flag, int argc, char *
 				 &key_handle);
 	if (!err) {
 		printf("Key handle is 0x%x\n", key_handle);
-		setenv_hex("key_handle", key_handle);
+		env_set_hex("key_handle", key_handle);
 	}
 
 	return report_return_code(err);
cmd/trace.c +6 -6
index 1a6d8c3047..e6c08e4ba5 100644
@@ -46,9 +46,9 @@ static int create_func_list(int argc, char * const argv[])
 	used = min(avail, (size_t)needed);
 	printf("Function trace dumped to %08lx, size %#zx\n",
 	       (ulong)map_to_sysmem(buff + buff_ptr), used);
-	setenv_hex("profbase", map_to_sysmem(buff));
-	setenv_hex("profsize", buff_size);
-	setenv_hex("profoffset", buff_ptr + used);
+	env_set_hex("profbase", map_to_sysmem(buff));
+	env_set_hex("profsize", buff_size);
+	env_set_hex("profoffset", buff_ptr + used);
 
 	return 0;
 }
@@ -71,9 +71,9 @@ static int create_call_list(int argc, char * const argv[])
 	printf("Call list dumped to %08lx, size %#zx\n",
 	       (ulong)map_to_sysmem(buff + buff_ptr), used);
 
-	setenv_hex("profbase", map_to_sysmem(buff));
-	setenv_hex("profsize", buff_size);
-	setenv_hex("profoffset", buff_ptr + used);
+	env_set_hex("profbase", map_to_sysmem(buff));
+	env_set_hex("profsize", buff_size);
+	env_set_hex("profoffset", buff_ptr + used);
 
 	return 0;
 }
cmd/unzip.c +1 -1
index a8bcb1f529..94f883f92a 100644
@@ -29,7 +29,7 @@ static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 
 	printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
-	setenv_hex("filesize", src_len);
+	env_set_hex("filesize", src_len);
 
 	return 0;
 }
cmd/ximg.c +2 -2
index d033c15b62..50dc00e4f8 100644
@@ -251,8 +251,8 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
 
 	flush_cache(dest, len);
 
-	setenv_hex("fileaddr", data);
-	setenv_hex("filesize", len);
+	env_set_hex("fileaddr", data);
+	env_set_hex("filesize", len);
 
 	return 0;
 }
cmd/zfs.c +1 -1
index 3ed9912d19..08b0062c10 100644
@@ -115,7 +115,7 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 	load_addr = addr;
 
 	printf("%llu bytes read\n", zfile.size);
-	setenv_hex("filesize", zfile.size);
+	env_set_hex("filesize", zfile.size);
 
 	return 0;
 }
cmd/zip.c +1 -1
index 7fcd9d5bf8..dac7527721 100644
@@ -30,7 +30,7 @@ static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		return 1;
 
 	printf("Compressed size: %ld = 0x%lX\n", dst_len, dst_len);
-	setenv_hex("filesize", dst_len);
+	env_set_hex("filesize", dst_len);
 
 	return 0;
 }
common/autoboot.c +3 -3
index c52bad84a4..41f18208c3 100644
@@ -278,12 +278,12 @@ static void process_fdt_options(const void *blob)
 	/* Add an env variable to point to a kernel payload, if available */
 	addr = fdtdec_get_config_int(gd->fdt_blob, "kernel-offset", 0);
 	if (addr)
-		setenv_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+		env_set_addr("kernaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
 
 	/* Add an env variable to point to a root disk, if available */
 	addr = fdtdec_get_config_int(gd->fdt_blob, "rootdisk-offset", 0);
 	if (addr)
-		setenv_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
+		env_set_addr("rootaddr", (void *)(CONFIG_SYS_TEXT_BASE + addr));
 #endif /* CONFIG_OF_CONTROL && CONFIG_SYS_TEXT_BASE */
 }
 
@@ -300,7 +300,7 @@ const char *bootdelay_process(void)
 	bootcount = bootcount_load();
 	bootcount++;
 	bootcount_store(bootcount);
-	setenv_ulong("bootcount", bootcount);
+	env_set_ulong("bootcount", bootcount);
 	bootlimit = getenv_ulong("bootlimit", 10, 0);
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
 
common/board_r.c +1 -1
index a4a7384f8b..016dc0262c 100644
@@ -486,7 +486,7 @@ static int initr_env(void)
 	else
 		set_default_env(NULL);
 #ifdef CONFIG_OF_CONTROL
-	setenv_addr("fdtcontroladdr", gd->fdt_blob);
+	env_set_addr("fdtcontroladdr", gd->fdt_blob);
 #endif
 
 	/* Initialize from environment */
common/bootm.c +2 -2
index f5ecc06d52..e34617a145 100644
@@ -645,8 +645,8 @@ int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 		ret = boot_ramdisk_high(&images->lmb, images->rd_start,
 			rd_len, &images->initrd_start, &images->initrd_end);
 		if (!ret) {
-			setenv_hex("initrd_start", images->initrd_start);
-			setenv_hex("initrd_end", images->initrd_end);
+			env_set_hex("initrd_start", images->initrd_start);
+			env_set_hex("initrd_end", images->initrd_end);
 		}
 	}
 #endif
common/bootm_os.c +1 -1
index d9e6e937f7..86a37cb925 100644
@@ -23,7 +23,7 @@ static int do_bootm_standalone(int flag, int argc, char * const argv[],
 	/* Don't start if "autostart" is set to "no" */
 	s = getenv("autostart");
 	if ((s != NULL) && !strcmp(s, "no")) {
-		setenv_hex("filesize", images->os.image_len);
+		env_set_hex("filesize", images->os.image_len);
 		return 0;
 	}
 	appl = (int (*)(int, char * const []))images->ep;
drivers/bootcount/bootcount_env.c +1 -1
index 7f22dd0748..ec5f942676 100644
@@ -13,7 +13,7 @@ void bootcount_store(ulong a)
 	int upgrade_available = getenv_ulong("upgrade_available", 10, 0);
 
 	if (upgrade_available) {
-		setenv_ulong("bootcount", a);
+		env_set_ulong("bootcount", a);
 		env_save();
 	}
 }
drivers/net/fm/fm.c +1 -1
index 9fe34ad4a9..451dfded77 100644
@@ -418,7 +418,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
 	rc = fman_upload_firmware(index, &reg->fm_imem, addr);
 	if (rc)
 		return rc;
-	setenv_addr("fman_ucode", addr);
+	env_set_addr("fman_ucode", addr);
 
 	fm_init_muram(index, &reg->muram);
 	fm_init_qmi(&reg->fm_qmi_common);
drivers/scsi/scsi.c +1 -1
index 7ec7ecc295..f47628b2de 100644
@@ -682,7 +682,7 @@ int scsi_scan(bool verbose)
 
 	printf("Found %d device(s).\n", scsi_max_devs);
 #ifndef CONFIG_SPL_BUILD
-	setenv_ulong("scsidevs", scsi_max_devs);
+	env_set_ulong("scsidevs", scsi_max_devs);
 #endif
 	return 0;
 }
fs/fs.c +3 -3
index ef41b74826..055dffdafd 100644
@@ -348,7 +348,7 @@ int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 	if (fs_size(argv[3], &size) < 0)
 		return CMD_RET_FAILURE;
 
-	setenv_hex("filesize", size);
+	env_set_hex("filesize", size);
 
 	return 0;
 }
@@ -417,8 +417,8 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 	}
 	puts("\n");
 
-	setenv_hex("fileaddr", addr);
-	setenv_hex("filesize", len_read);
+	env_set_hex("fileaddr", addr);
+	env_set_hex("filesize", len_read);
 
 	return 0;
 }
fs/ubifs/ubifs.c +1 -1
index db29489eca..8f1c9d167d 100644
@@ -941,7 +941,7 @@ int ubifs_load(char *filename, u32 addr, u32 size)
 
 	err = ubifs_read(filename, (void *)(uintptr_t)addr, 0, size, &actread);
 	if (err == 0) {
-		setenv_hex("filesize", actread);
+		env_set_hex("filesize", actread);
 		printf("Done\n");
 	}
 
include/common.h +21 -5
index fdbb07bffe..fc4b57c139 100644
@@ -348,18 +348,34 @@ int getenv_yesno(const char *var);
  */
 int env_set(const char *varname, const char *value);
 
-int setenv_ulong(const char *varname, ulong value);
-int setenv_hex(const char *varname, ulong value);
 /**
- * setenv_addr - Set an environment variable to an address in hex
+ * env_set_ulong() - set an environment variable to an integer
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (will be converted to a string)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_ulong(const char *varname, ulong value);
+
+/**
+ * env_set_hex() - set an environment variable to a hex value
+ *
+ * @varname: Variable to adjust
+ * @value: Value to set for the variable (will be converted to a hex string)
+ * @return 0 if OK, 1 on error
+ */
+int env_set_hex(const char *varname, ulong value);
+
+/**
+ * env_set_addr - Set an environment variable to an address in hex
  *
  * @varname:	Environment variable to set
  * @addr:	Value to set it to
  * @return 0 if ok, 1 on error
  */
-static inline int setenv_addr(const char *varname, const void *addr)
+static inline int env_set_addr(const char *varname, const void *addr)
 {
-	return setenv_hex(varname, (ulong)addr);
+	return env_set_hex(varname, (ulong)addr);
 }
 
 #ifdef CONFIG_AUTO_COMPLETE
net/net.c +2 -2
index 6e678770fa..2fed28092d 100644
@@ -616,8 +616,8 @@ restart:
 			if (net_boot_file_size > 0) {
 				printf("Bytes transferred = %d (%x hex)\n",
 				       net_boot_file_size, net_boot_file_size);
-				setenv_hex("filesize", net_boot_file_size);
-				setenv_hex("fileaddr", load_addr);
+				env_set_hex("filesize", net_boot_file_size);
+				env_set_hex("fileaddr", load_addr);
 			}
 			if (protocol != NETCONS)
 				eth_halt();
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#23 lore raw

PATCH v4 23/29 env: Rename eth_setenv_enetaddr() to eth_env_set_enetaddr()

In reply to Simon Glass

Rename this function for consistency with env_set().

---

Changes in v4:
- Add new patch to rename eth_setenv_enetaddr()

Changes in v3: None
Changes in v2: None

 arch/arm/mach-davinci/misc.c                      |  2 +-
 arch/arm/mach-omap2/utils.c                       |  2 +-
 board/BuR/common/common.c                         |  2 +-
 board/CZ.NIC/turris_omnia/turris_omnia.c          |  6 +++---
 board/LaCie/net2big_v2/net2big_v2.c               |  2 +-
 board/LaCie/netspace_v2/netspace_v2.c             |  2 +-
 board/amlogic/odroid-c2/odroid-c2.c               |  2 +-
 board/atmel/sama5d2_xplained/sama5d2_xplained.c   |  2 +-
 board/birdland/bav335x/board.c                    |  2 +-
 board/bosch/shc/board.c                           |  6 +++---
 board/compulab/cl-som-am57x/eth.c                 |  2 +-
 board/compulab/cm_fx6/cm_fx6.c                    |  2 +-
 board/compulab/cm_t335/cm_t335.c                  |  2 +-
 board/compulab/cm_t35/cm_t35.c                    |  2 +-
 board/compulab/cm_t3517/cm_t3517.c                |  2 +-
 board/compulab/cm_t54/cm_t54.c                    |  2 +-
 board/davinci/da8xxevm/da850evm.c                 |  2 +-
 board/gateworks/gw_ventana/gw_ventana.c           |  4 ++--
 board/grinn/chiliboard/board.c                    |  4 ++--
 board/gumstix/pepper/board.c                      |  2 +-
 board/isee/igep003x/board.c                       |  2 +-
 board/kosagi/novena/novena.c                      |  2 +-
 board/logicpd/zoom1/zoom1.c                       |  2 +-
 board/phytec/pcm051/board.c                       |  2 +-
 board/raspberrypi/rpi/rpi.c                       |  2 +-
 board/renesas/blanche/blanche.c                   |  2 +-
 board/rockchip/tinker_rk3288/tinker-rk3288.c      |  2 +-
 board/samtec/vining_2000/vining_2000.c            |  2 +-
 board/samtec/vining_fpga/socfpga.c                |  2 +-
 board/siemens/common/factoryset.c                 |  2 +-
 board/siemens/pxm2/board.c                        |  2 +-
 board/silica/pengwyn/board.c                      |  2 +-
 board/spear/common/spr_misc.c                     |  2 +-
 board/sunxi/board.c                               |  2 +-
 board/tcl/sl50/board.c                            |  6 +++---
 board/technologic/ts4800/ts4800.c                 |  2 +-
 board/theobroma-systems/puma_rk3399/puma-rk3399.c |  2 +-
 board/ti/am335x/board.c                           |  6 +++---
 board/ti/am43xx/board.c                           |  4 ++--
 board/ti/am57xx/board.c                           | 10 +++++-----
 board/ti/common/board_detect.c                    |  4 ++--
 board/ti/dra7xx/evm.c                             |  4 ++--
 board/ti/evm/evm.c                                |  2 +-
 board/ti/ti814x/evm.c                             |  2 +-
 board/ti/ti816x/evm.c                             |  2 +-
 board/timll/devkit8000/devkit8000.c               |  2 +-
 board/toradex/common/tdx-common.c                 |  4 ++--
 board/vscom/baltos/board.c                        |  2 +-
 doc/README.enetaddr                               |  4 ++--
 drivers/net/fec_mxc.c                             |  2 +-
 drivers/net/lan91c96.c                            |  2 +-
 drivers/net/ne2000_base.c                         |  2 +-
 drivers/usb/gadget/ether.c                        |  2 +-
 include/net.h                                     |  6 +++---
 net/eth-uclass.c                                  |  2 +-
 net/eth_common.c                                  |  6 +++---
 net/eth_internal.h                                |  4 ++--
 net/eth_legacy.c                                  |  4 ++--
 58 files changed, 83 insertions(+), 83 deletions(-)
arch/arm/mach-davinci/misc.c +1 -1
index ec331ba6bb..4441242cc7 100644
@@ -99,7 +99,7 @@ void davinci_sync_env_enetaddr(uint8_t *rom_enetaddr)
 		debug("### Setting environment from EEPROM MAC address = "
 			"\"%pM\"\n",
 			env_enetaddr);
-		ret = !eth_setenv_enetaddr("ethaddr", rom_enetaddr);
+		ret = !eth_env_set_enetaddr("ethaddr", rom_enetaddr);
 	}
 	if (!ret)
 		printf("Failed to set mac address from EEPROM: %d\n", ret);
arch/arm/mach-omap2/utils.c +1 -1
index b7074638bd..c03e93878d 100644
@@ -214,7 +214,7 @@ void omap_die_id_usbethaddr(void)
 		mac[4] = die_id[0] & 0xff;
 		mac[5] = (die_id[0] >> 8) & 0xff;
 
-		eth_setenv_enetaddr("usbethaddr", mac);
+		eth_env_set_enetaddr("usbethaddr", mac);
 	}
 }
 
board/BuR/common/common.c +1 -1
index 6bea9a4383..eb34de931e 100644
@@ -670,7 +670,7 @@ int board_eth_init(bd_t *bis)
 
 		if (mac) {
 			printf("using: %pM on ", mac);
-			eth_setenv_enetaddr("ethaddr", (const u8 *)mac);
+			eth_env_set_enetaddr("ethaddr", (const u8 *)mac);
 		}
 	}
 	writel(MII_MODE_ENABLE, &cdev->miisel);
board/CZ.NIC/turris_omnia/turris_omnia.c +3 -3
index b09bff0267..a4d1725b13 100644
@@ -510,17 +510,17 @@ int misc_init_r(void)
 	mac[5] = mac1[3];
 
 	if (is_valid_ethaddr(mac))
-		eth_setenv_enetaddr("ethaddr", mac);
+		eth_env_set_enetaddr("ethaddr", mac);
 
 	increment_mac(mac);
 
 	if (is_valid_ethaddr(mac))
-		eth_setenv_enetaddr("eth1addr", mac);
+		eth_env_set_enetaddr("eth1addr", mac);
 
 	increment_mac(mac);
 
 	if (is_valid_ethaddr(mac))
-		eth_setenv_enetaddr("eth2addr", mac);
+		eth_env_set_enetaddr("eth2addr", mac);
 
 out:
 #endif
board/LaCie/net2big_v2/net2big_v2.c +1 -1
index 2e6e9ef916..416af469fa 100644
@@ -224,7 +224,7 @@ int misc_init_r(void)
 	if (!getenv("ethaddr")) {
 		uchar mac[6];
 		if (lacie_read_mac_address(mac) == 0)
-			eth_setenv_enetaddr("ethaddr", mac);
+			eth_env_set_enetaddr("ethaddr", mac);
 	}
 #endif
 	init_leds();
board/LaCie/netspace_v2/netspace_v2.c +1 -1
index 16d694716f..fa07288d6e 100644
@@ -86,7 +86,7 @@ int misc_init_r(void)
 	if (!getenv("ethaddr")) {
 		uchar mac[6];
 		if (lacie_read_mac_address(mac) == 0)
-			eth_setenv_enetaddr("ethaddr", mac);
+			eth_env_set_enetaddr("ethaddr", mac);
 	}
 #endif
 	return 0;
board/amlogic/odroid-c2/odroid-c2.c +1 -1
index f2a394a72b..ca9c13bcc1 100644
@@ -48,7 +48,7 @@ int misc_init_r(void)
 		len = meson_sm_read_efuse(EFUSE_MAC_OFFSET,
 					  mac_addr, EFUSE_MAC_SIZE);
 		if (len == EFUSE_MAC_SIZE && is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	if (!getenv("serial#")) {
board/atmel/sama5d2_xplained/sama5d2_xplained.c +1 -1
index 48f45b35ce..4a06cda6f4 100644
@@ -192,7 +192,7 @@ static int set_ethaddr_from_eeprom(void)
 		return -1;
 	}
 
-	return eth_setenv_enetaddr(ETHADDR_NAME, ethaddr);
+	return eth_env_set_enetaddr(ETHADDR_NAME, ethaddr);
 }
 #else
 static int set_ethaddr_from_eeprom(void)
board/birdland/bav335x/board.c +1 -1
index c5122253cf..a9d9ce6fa5 100644
@@ -396,7 +396,7 @@ int board_eth_init(bd_t *bis)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 #ifdef CONFIG_DRIVER_TI_CPSW
board/bosch/shc/board.c +3 -3
index 2c830a219c..b4c6a0b45d 100644
@@ -460,7 +460,7 @@ int board_late_init(void)
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 	if (shc_eeprom_valid)
 		if (is_valid_ethaddr(header.mac_addr))
-			eth_setenv_enetaddr("ethaddr", header.mac_addr);
+			eth_env_set_enetaddr("ethaddr", header.mac_addr);
 #endif
 
 	return 0;
@@ -549,7 +549,7 @@ int board_eth_init(bd_t *bis)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	writel(MII_MODE_ENABLE, &cdev->miisel);
@@ -565,7 +565,7 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_USB_ETHER) && \
 	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
 	if (is_valid_ethaddr(mac_addr))
-		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+		eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
 	rv = usb_eth_initialize(bis);
 	if (rv < 0)
board/compulab/cl-som-am57x/eth.c +1 -1
index 0c4bf91c13..d2992d3a63 100644
@@ -107,7 +107,7 @@ static int cl_som_am57x_handle_mac_address(char *env_name, uint port_num)
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	ret = eth_setenv_enetaddr(env_name, enetaddr);
+	ret = eth_env_set_enetaddr(env_name, enetaddr);
 	if (ret)
 		printf("cl-som-am57x: Failed to set Eth port %d MAC address\n",
 		       port_num);
board/compulab/cm_fx6/cm_fx6.c +1 -1
index c59884a8c3..2368226546 100644
@@ -481,7 +481,7 @@ static int handle_mac_address(char *env_var, uint eeprom_bus)
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr(env_var, enetaddr);
+	return eth_env_set_enetaddr(env_var, enetaddr);
 }
 
 #define SB_FX6_I2C_EEPROM_BUS	0
board/compulab/cm_t335/cm_t335.c +1 -1
index c4506b910e..f6030ddf29 100644
@@ -117,7 +117,7 @@ static int handle_mac_address(void)
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("ethaddr", enetaddr);
+	return eth_env_set_enetaddr("ethaddr", enetaddr);
 }
 
 #define AR8051_PHY_DEBUG_ADDR_REG	0x1d
board/compulab/cm_t35/cm_t35.c +1 -1
index f1691257e7..a8696aea83 100644
@@ -445,7 +445,7 @@ static int handle_mac_address(void)
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("ethaddr", enetaddr);
+	return eth_env_set_enetaddr("ethaddr", enetaddr);
 }
 
 /*
board/compulab/cm_t3517/cm_t3517.c +1 -1
index 38eb641bc4..0568234f66 100644
@@ -182,7 +182,7 @@ static int cm_t3517_handle_mac_address(void)
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("ethaddr", enetaddr);
+	return eth_env_set_enetaddr("ethaddr", enetaddr);
 }
 
 #define SB_T35_ETH_RST_GPIO 164
board/compulab/cm_t54/cm_t54.c +1 -1
index 6437718415..582512dbe4 100644
@@ -172,7 +172,7 @@ static int handle_mac_address(void)
 	if (!is_valid_ethaddr(enetaddr))
 		return -1;
 
-	return eth_setenv_enetaddr("usbethaddr", enetaddr);
+	return eth_env_set_enetaddr("usbethaddr", enetaddr);
 }
 
 int board_eth_init(bd_t *bis)
board/davinci/da8xxevm/da850evm.c +1 -1
index 11ea52f240..8cab357a92 100644
@@ -147,7 +147,7 @@ int misc_init_r(void)
 	if (!enetaddr_found) {
 		if (!spi_mac_read) {
 			if (is_valid_ethaddr(buff)) {
-				if (eth_setenv_enetaddr("ethaddr", buff)) {
+				if (eth_env_set_enetaddr("ethaddr", buff)) {
 					printf("Warning: Failed to "
 					"set MAC address from SPI flash\n");
 				}
board/gateworks/gw_ventana/gw_ventana.c +2 -2
index efadb0c324..61298ab2fd 100644
@@ -771,11 +771,11 @@ int misc_init_r(void)
 		/* initialize env from EEPROM */
 		if (test_bit(EECONFIG_ETH0, info->config) &&
 		    !getenv("ethaddr")) {
-			eth_setenv_enetaddr("ethaddr", info->mac0);
+			eth_env_set_enetaddr("ethaddr", info->mac0);
 		}
 		if (test_bit(EECONFIG_ETH1, info->config) &&
 		    !getenv("eth1addr")) {
-			eth_setenv_enetaddr("eth1addr", info->mac1);
+			eth_env_set_enetaddr("eth1addr", info->mac1);
 		}
 
 		/* board serial-number */
board/grinn/chiliboard/board.c +2 -2
index e3f82b0a80..2900109bbd 100644
@@ -130,7 +130,7 @@ int board_late_init(void)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl(&cdev->macid1l);
@@ -144,7 +144,7 @@ int board_late_init(void)
 
 	if (!getenv("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 #endif
 
board/gumstix/pepper/board.c +1 -1
index d76c28bd3c..7e8b014e3d 100644
@@ -250,7 +250,7 @@ int board_eth_init(bd_t *bis)
 		mac_addr[4] = mac_lo & 0xFF;
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	writel((RGMII_MODE_ENABLE | RGMII_INT_DELAY), &cdev->miisel);
board/isee/igep003x/board.c +1 -1
index 24687e22e4..1aa2f52069 100644
@@ -275,7 +275,7 @@ int board_eth_init(bd_t *bis)
 		mac_addr[4] = mac_lo & 0xFF;
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	writel((GMII1_SEL_RMII | RMII1_IO_CLK_EN),
board/kosagi/novena/novena.c +1 -1
index 980cd6288c..baca7223fa 100644
@@ -264,7 +264,7 @@ int misc_init_r(void)
 	}
 
 	/* Set ethernet address from EEPROM. */
-	eth_setenv_enetaddr("ethaddr", data.mac);
+	eth_env_set_enetaddr("ethaddr", data.mac);
 
 	return ret;
 }
board/logicpd/zoom1/zoom1.c +1 -1
index e91f874a2b..f76223cacd 100644
@@ -133,7 +133,7 @@ int board_eth_init(bd_t *bis)
 	if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 		dev = eth_get_dev_by_index(0);
 		if (dev) {
-			eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
+			eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
 		} else {
 			printf("zoom1: Couldn't get eth device\n");
 			rc = -1;
board/phytec/pcm051/board.c +1 -1
index 4f3853ac42..0da96e7413 100644
@@ -229,7 +229,7 @@ int board_eth_init(bd_t *bis)
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			goto try_usbether;
 	}
board/raspberrypi/rpi/rpi.c +1 -1
index aaa3a42abf..7ff7b269f9 100644
@@ -300,7 +300,7 @@ static void set_usbethaddr(void)
 		return;
 	}
 
-	eth_setenv_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
+	eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
 
 	if (!getenv("ethaddr"))
 		env_set("ethaddr", getenv("usbethaddr"));
board/renesas/blanche/blanche.c +1 -1
index 5156eafeb4..e3262f779a 100644
@@ -421,7 +421,7 @@ int board_eth_init(bd_t *bis)
 	if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 		dev = eth_get_dev_by_index(0);
 		if (dev) {
-			eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
+			eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
 		} else {
 			printf("blanche: Couldn't get eth device\n");
 			rc = -1;
board/rockchip/tinker_rk3288/tinker-rk3288.c +1 -1
index c2872e7330..790a921515 100644
@@ -29,7 +29,7 @@ int rk_board_late_init(void)
 		return 0;
 
 	if (is_valid_ethaddr(ethaddr))
-		eth_setenv_enetaddr("ethaddr", ethaddr);
+		eth_env_set_enetaddr("ethaddr", ethaddr);
 
 	return 0;
 }
board/samtec/vining_2000/vining_2000.c +1 -1
index d15f2a9c1d..125f6e7070 100644
@@ -132,7 +132,7 @@ int board_eth_init(bd_t *bis)
 	/* just to get secound mac address */
 	imx_get_mac_from_fuse(1, eth1addr);
 	if (!getenv("eth1addr") && is_valid_ethaddr(eth1addr))
-		eth_setenv_enetaddr("eth1addr", eth1addr);
+		eth_env_set_enetaddr("eth1addr", eth1addr);
 
 	imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads));
 
board/samtec/vining_fpga/socfpga.c +1 -1
index 2ee6d3b554..760fc71217 100644
@@ -93,7 +93,7 @@ int misc_init_r(void)
 
 	/* Set ethernet address from EEPROM. */
 	if (!getenv("ethaddr") && is_valid_ethaddr(&data[0x62]))
-		eth_setenv_enetaddr("ethaddr", &data[0x62]);
+		eth_env_set_enetaddr("ethaddr", &data[0x62]);
 
 	return 0;
 }
board/siemens/common/factoryset.c +1 -1
index 4e5ad58d44..b4f027af28 100644
@@ -292,7 +292,7 @@ static int factoryset_mac_env_set(void)
 		}
 	}
 
-	eth_setenv_enetaddr("ethaddr", mac_addr);
+	eth_env_set_enetaddr("ethaddr", mac_addr);
 	return 0;
 }
 
board/siemens/pxm2/board.c +1 -1
index 012974d8eb..8bbb03561b 100644
@@ -225,7 +225,7 @@ int board_eth_init(bd_t *bis)
 	if (!is_valid_ethaddr(factory_dat.mac))
 		printf("Error: no valid mac address\n");
 	else
-		eth_setenv_enetaddr("ethaddr", factory_dat.mac);
+		eth_env_set_enetaddr("ethaddr", factory_dat.mac);
 #endif /* #ifdef CONFIG_FACTORYSET */
 
 	/* Set rgmii mode and enable rmii clock to be sourced from chip */
board/silica/pengwyn/board.c +1 -1
index 1f5a5868cb..057691b045 100644
@@ -184,7 +184,7 @@ int board_eth_init(bd_t *bis)
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			return n;
 	}
board/spear/common/spr_misc.c +1 -1
index 3bb4ff14d9..67de28e7ea 100644
@@ -54,7 +54,7 @@ int misc_init_r(void)
 	uchar mac_id[6];
 
 	if (!eth_getenv_enetaddr("ethaddr", mac_id) && !i2c_read_mac(mac_id))
-		eth_setenv_enetaddr("ethaddr", mac_id);
+		eth_env_set_enetaddr("ethaddr", mac_id);
 #endif
 	env_set("verify", "n");
 
board/sunxi/board.c +1 -1
index 92fa6c8974..26732dc40f 100644
@@ -705,7 +705,7 @@ static void setup_environment(const void *fdt)
 			mac_addr[4] = (sid[3] >>  8) & 0xff;
 			mac_addr[5] = (sid[3] >>  0) & 0xff;
 
-			eth_setenv_enetaddr(ethaddr, mac_addr);
+			eth_env_set_enetaddr(ethaddr, mac_addr);
 		}
 
 		if (!getenv("serial#")) {
board/tcl/sl50/board.c +3 -3
index d3c953e993..cc65c7b84b 100644
@@ -326,7 +326,7 @@ int board_eth_init(bd_t *bis)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 #ifdef CONFIG_DRIVER_TI_CPSW
@@ -342,7 +342,7 @@ int board_eth_init(bd_t *bis)
 
 	if (!getenv("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 
@@ -373,7 +373,7 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_USB_ETHER) && \
 	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
 	if (is_valid_ether_addr(mac_addr))
-		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+		eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
 	rv = usb_eth_initialize(bis);
 	if (rv < 0)
board/technologic/ts4800/ts4800.c +1 -1
index 94251c6d91..8fe26a75e8 100644
@@ -178,7 +178,7 @@ static int fec_get_mac_from_register(uint32_t base_addr)
 		ethaddr[i] = (reg_mac[i / 4] >> ((i % 4) * 8)) & 0xFF;
 
 	if (is_valid_ethaddr(ethaddr)) {
-		eth_setenv_enetaddr("ethaddr", ethaddr);
+		eth_env_set_enetaddr("ethaddr", ethaddr);
 		return 0;
 	}
 
board/theobroma-systems/puma_rk3399/puma-rk3399.c +1 -1
index fd3b638466..733fe96726 100644
@@ -89,7 +89,7 @@ static void setup_macaddr(void)
 	/* Make this a valid MAC address and set it */
 	mac_addr[0] &= 0xfe;  /* clear multicast bit */
 	mac_addr[0] |= 0x02;  /* set local assignment bit (IEEE802) */
-	eth_setenv_enetaddr("ethaddr", mac_addr);
+	eth_env_set_enetaddr("ethaddr", mac_addr);
 #endif
 
 	return;
board/ti/am335x/board.c +3 -3
index 5751b814ca..7bdbc89d5e 100644
@@ -749,7 +749,7 @@ int board_late_init(void)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl(&cdev->macid1l);
@@ -763,7 +763,7 @@ int board_late_init(void)
 
 	if (!getenv("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 #endif
 
@@ -908,7 +908,7 @@ int board_eth_init(bd_t *bis)
 #if defined(CONFIG_USB_ETHER) && \
 	(!defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_USBETH_SUPPORT))
 	if (is_valid_ethaddr(mac_addr))
-		eth_setenv_enetaddr("usbnet_devaddr", mac_addr);
+		eth_env_set_enetaddr("usbnet_devaddr", mac_addr);
 
 	rv = usb_eth_initialize(bis);
 	if (rv < 0)
board/ti/am43xx/board.c +2 -2
index 55098bf816..933ff31a8e 100644
@@ -794,7 +794,7 @@ int board_eth_init(bd_t *bis)
 	if (!getenv("ethaddr")) {
 		puts("<ethaddr> not set. Validating first E-fuse MAC\n");
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl(&cdev->macid1l);
@@ -808,7 +808,7 @@ int board_eth_init(bd_t *bis)
 
 	if (!getenv("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 	if (board_is_eposevm()) {
board/ti/am57xx/board.c +5 -5
index bd94a90f8f..aaa1464273 100644
@@ -937,7 +937,7 @@ int board_eth_init(bd_t *bis)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
@@ -951,7 +951,7 @@ int board_eth_init(bd_t *bis)
 
 	if (!getenv("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 	ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
@@ -986,9 +986,9 @@ int board_eth_init(bd_t *bis)
 			for (i = 0; i < num_macs; i++) {
 				u64_to_mac(mac1 + i, mac_addr);
 				if (is_valid_ethaddr(mac_addr)) {
-					eth_setenv_enetaddr_by_index("eth",
-								     i + 2,
-								     mac_addr);
+					eth_env_set_enetaddr_by_index("eth",
+								      i + 2,
+								      mac_addr);
 				}
 			}
 		}
board/ti/common/board_detect.c +2 -2
index c4ef28282f..6f07ec331a 100644
@@ -451,8 +451,8 @@ void board_ti_set_ethaddr(int index)
 		for (i = 0; i < num_macs; i++) {
 			u64_to_mac(mac1 + i, mac_addr);
 			if (is_valid_ethaddr(mac_addr)) {
-				eth_setenv_enetaddr_by_index("eth", i + index,
-							     mac_addr);
+				eth_env_set_enetaddr_by_index("eth", i + index,
+							      mac_addr);
 			}
 		}
 	}
board/ti/dra7xx/evm.c +2 -2
index 5c43561bb7..4252074e74 100644
@@ -897,7 +897,7 @@ int board_eth_init(bd_t *bis)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 	mac_lo = readl((*ctrl)->control_core_mac_id_1_lo);
@@ -911,7 +911,7 @@ int board_eth_init(bd_t *bis)
 
 	if (!getenv("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("eth1addr", mac_addr);
+			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
 
 	ctrl_val = readl((*ctrl)->control_core_control_io1) & (~0x33);
board/ti/evm/evm.c +1 -1
index fe8e79312f..ac8e093e5a 100644
@@ -248,7 +248,7 @@ int board_eth_init(bd_t *bis)
 	if (!eth_getenv_enetaddr(STR_ENV_ETHADDR, eth_addr)) {
 		dev = eth_get_dev_by_index(0);
 		if (dev) {
-			eth_setenv_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
+			eth_env_set_enetaddr(STR_ENV_ETHADDR, dev->enetaddr);
 		} else {
 			printf("omap3evm: Couldn't get eth device\n");
 			rc = -1;
board/ti/ti814x/evm.c +1 -1
index 055a29d9c6..38f9c57606 100644
@@ -179,7 +179,7 @@ int board_eth_init(bd_t *bis)
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			printf("Unable to read MAC address. Set <ethaddr>\n");
 	}
board/ti/ti816x/evm.c +1 -1
index 9d6c3d6b5d..1a8fe27c9f 100644
@@ -51,7 +51,7 @@ int board_eth_init(bd_t *bis)
 		mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 		else
 			printf("Unable to read MAC address. Set <ethaddr>\n");
 	}
board/timll/devkit8000/devkit8000.c +1 -1
index d31eeb878a..2f80d15666 100644
@@ -111,7 +111,7 @@ int misc_init_r(void)
 		enetaddr[3] = (die_id_0 & 0x00ff0000) >> 16;
 		enetaddr[4] = (die_id_0 & 0x0000ff00) >> 8;
 		enetaddr[5] = (die_id_0 & 0x000000ff);
-		eth_setenv_enetaddr("ethaddr", enetaddr);
+		eth_env_set_enetaddr("ethaddr", enetaddr);
 	}
 #endif
 
board/toradex/common/tdx-common.c +2 -2
index 77ebb88317..78b2bc0c2b 100644
@@ -87,7 +87,7 @@ int show_board_info(void)
 	 * set the one from config block if not
 	 */
 	if (!eth_getenv_enetaddr("ethaddr", ethaddr))
-		eth_setenv_enetaddr("ethaddr", (u8 *)&tdx_eth_addr);
+		eth_env_set_enetaddr("ethaddr", (u8 *)&tdx_eth_addr);
 
 #ifdef CONFIG_TDX_CFG_BLOCK_2ND_ETHADDR
 	if (!eth_getenv_enetaddr("eth1addr", ethaddr)) {
@@ -97,7 +97,7 @@ int show_board_info(void)
 		 */
 		memcpy(ethaddr, &tdx_eth_addr, 6);
 		ethaddr[3] += 0x10;
-		eth_setenv_enetaddr("eth1addr", ethaddr);
+		eth_env_set_enetaddr("eth1addr", ethaddr);
 	}
 #endif
 
board/vscom/baltos/board.c +1 -1
index 5f730b8fd0..2e3baeb118 100644
@@ -457,7 +457,7 @@ int board_eth_init(bd_t *bis)
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
-			eth_setenv_enetaddr("ethaddr", mac_addr);
+			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
 #ifdef CONFIG_DRIVER_TI_CPSW
doc/README.enetaddr +2 -2
index bf994d4e41..241d528ff7 100644
@@ -98,12 +98,12 @@ if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
 }
 /* enetaddr is now set to the value stored in the ethaddr env var */
 
-	* int eth_setenv_enetaddr(char *name, const uchar *enetaddr);
+	* int eth_env_set_enetaddr(char *name, const uchar *enetaddr);
 
 Store the MAC address into the named environment variable.  The return value is
 the same as the env_set() function.
 uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
-eth_setenv_enetaddr("ethaddr", enetaddr);
+eth_env_set_enetaddr("ethaddr", enetaddr);
 /* the "ethaddr" env var should now be set to "00:11:22:33:44:55" */
 
 	* the %pM format modifier
drivers/net/fec_mxc.c +1 -1
index 40be52070e..424c347e0e 100644
@@ -1097,7 +1097,7 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
 		else
 			strcpy(mac, "ethaddr");
 		if (!getenv(mac))
-			eth_setenv_enetaddr(mac, ethaddr);
+			eth_env_set_enetaddr(mac, ethaddr);
 	}
 	return ret;
 err4:
drivers/net/lan91c96.c +1 -1
index 3526876d14..255c7010cc 100644
@@ -710,7 +710,7 @@ static int smc_get_ethaddr(bd_t *bd, struct eth_device *dev)
 			printf("\n*** ERROR: ethaddr is NOT set !!\n");
 			return -1;
 		}
-		eth_setenv_enetaddr("ethaddr", v_mac);
+		eth_env_set_enetaddr("ethaddr", v_mac);
 	}
 
 	smc_set_mac_addr(v_mac); /* use old function to update smc default */
drivers/net/ne2000_base.c +1 -1
index 377d87f04b..f6e5eafba5 100644
@@ -723,7 +723,7 @@ static int ne2k_setup_driver(struct eth_device *dev)
 		 * returns -1 due to eth_getenv_enetaddr_by_index() failing,
 		 * and this causes "Warning: failed to set MAC address", and
 		 * cmd_bdinfo has no ethaddr value which it can show: */
-		eth_setenv_enetaddr("ethaddr", dev->enetaddr);
+		eth_env_set_enetaddr("ethaddr", dev->enetaddr);
 	}
 	return 0;
 }
drivers/usb/gadget/ether.c +1 -1
index 4137d76c42..d0105372cf 100644
@@ -2685,7 +2685,7 @@ static int usb_eth_probe(struct udevice *dev)
 	l_priv = priv;
 
 	get_ether_addr(CONFIG_USBNET_DEVADDR, pdata->enetaddr);
-	eth_setenv_enetaddr("usbnet_devaddr", pdata->enetaddr);
+	eth_env_set_enetaddr("usbnet_devaddr", pdata->enetaddr);
 
 	return 0;
 }
include/net.h +3 -3
index 2eaa88224c..65ab7b2c79 100644
@@ -240,10 +240,10 @@ 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_getenv_enetaddr(const char *name, uchar *enetaddr);
-int eth_setenv_enetaddr(const char *name, const uchar *enetaddr);
+int eth_env_set_enetaddr(const char *name, const uchar *enetaddr);
 
 /**
- * eth_setenv_enetaddr_by_index() - set the MAC address environment variable
+ * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
  *
  * This sets up an environment variable with the given MAC address (@enetaddr).
  * The environment variable to be set is defined by <@base_name><@index>addr.
@@ -255,7 +255,7 @@ int eth_setenv_enetaddr(const char *name, const uchar *enetaddr);
  * @enetaddr:   Pointer to MAC address to put into the variable
  * @return 0 if OK, other value on error
  */
-int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_set_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr);
 
 
net/eth-uclass.c +1 -1
index b659961a5d..d356576210 100644
@@ -510,7 +510,7 @@ static int eth_post_probe(struct udevice *dev)
 		/* Override the ROM MAC address */
 		memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);
 	} else if (is_valid_ethaddr(pdata->enetaddr)) {
-		eth_setenv_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
+		eth_env_set_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
 		printf("\nWarning: %s using MAC address from ROM\n",
 		       dev->name);
 	} else if (is_zero_ethaddr(pdata->enetaddr) ||
net/eth_common.c +3 -3
index ef97da7267..7b36532ee1 100644
@@ -30,7 +30,7 @@ int eth_getenv_enetaddr(const char *name, uchar *enetaddr)
 	return is_valid_ethaddr(enetaddr);
 }
 
-int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
+int eth_env_set_enetaddr(const char *name, const uchar *enetaddr)
 {
 	char buf[ARP_HLEN_ASCII + 1];
 
@@ -50,12 +50,12 @@ int eth_getenv_enetaddr_by_index(const char *base_name, int index,
 	return eth_getenv_enetaddr(enetvar, enetaddr);
 }
 
-int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_set_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr)
 {
 	char enetvar[32];
 	sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index);
-	return eth_setenv_enetaddr(enetvar, enetaddr);
+	return eth_env_set_enetaddr(enetvar, enetaddr);
 }
 
 void eth_common_init(void)
net/eth_internal.h +2 -2
index a14b20844f..4b0e716b73 100644
@@ -13,7 +13,7 @@
 void eth_common_init(void);
 
 /**
- * eth_setenv_enetaddr_by_index() - set the MAC address environment variable
+ * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
  *
  * This sets up an environment variable with the given MAC address (@enetaddr).
  * The environment variable to be set is defined by <@base_name><@index>addr.
@@ -25,7 +25,7 @@ void eth_common_init(void);
  * @enetaddr:	Pointer to MAC address to put into the variable
  * @return 0 if OK, other value on error
  */
-int eth_setenv_enetaddr_by_index(const char *base_name, int index,
+int eth_env_set_enetaddr_by_index(const char *base_name, int index,
 				 uchar *enetaddr);
 
 int eth_mac_skip(int index);
net/eth_legacy.c +2 -2
index e4bd0f4c1a..2608302648 100644
@@ -152,8 +152,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,
 
 		memcpy(dev->enetaddr, env_enetaddr, ARP_HLEN);
 	} else if (is_valid_ethaddr(dev->enetaddr)) {
-		eth_setenv_enetaddr_by_index(base_name, eth_number,
-					     dev->enetaddr);
+		eth_env_set_enetaddr_by_index(base_name, eth_number,
+					      dev->enetaddr);
 	} else if (is_zero_ethaddr(dev->enetaddr)) {
 #ifdef CONFIG_NET_RANDOM_ETHADDR
 		net_random_ethaddr(dev->enetaddr);
Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog
#24 lore raw

PATCH v4 24/29 env: Rename getenv/_f() to env_get()

In reply to Simon Glass

We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h.

Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also.

---

Changes in v4:
- Reduce patch to only change getenv() and getenv_f()
- Update comment message to mention use of getenv() in condition context

Changes in v3: None
Changes in v2:
- Add new patch to rename getenv() and friends to env_get()

 README                                             |  2 +-
 api/api.c                                          |  2 +-
 arch/arc/lib/bootm.c                               |  2 +-
 arch/arm/cpu/armv8/fsl-layerscape/soc.c            |  2 +-
 arch/arm/lib/bootm.c                               |  6 ++--
 arch/arm/mach-imx/video.c                          |  2 +-
 arch/arm/mach-keystone/ddr3.c                      |  2 +-
 arch/arm/mach-keystone/keystone.c                  |  2 +-
 arch/arm/mach-kirkwood/cpu.c                       |  4 +--
 arch/arm/mach-omap2/utils.c                        |  8 ++---
 arch/arm/mach-tegra/tegra186/nvtboot_board.c       |  2 +-
 arch/arm/mach-uniphier/board_late_init.c           |  2 +-
 arch/m68k/lib/bootm.c                              |  3 +-
 arch/microblaze/lib/bootm.c                        |  2 +-
 arch/mips/lib/bootm.c                              |  6 ++--
 arch/nds32/lib/bootm.c                             |  4 +--
 arch/nios2/lib/bootm.c                             |  2 +-
 arch/powerpc/cpu/mpc85xx/cpu_init.c                | 10 +++---
 arch/powerpc/cpu/mpc85xx/fdt.c                     |  2 +-
 arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c      |  2 +-
 arch/powerpc/lib/bootm.c                           |  3 +-
 arch/sh/lib/bootm.c                                |  2 +-
 arch/sh/lib/zimageboot.c                           |  2 +-
 arch/x86/lib/zimage.c                              |  8 ++---
 arch/xtensa/lib/bootm.c                            |  2 +-
 board/Arcturus/ucp1020/cmd_arc.c                   |  6 ++--
 board/Arcturus/ucp1020/ucp1020.c                   | 10 +++---
 board/Barix/ipam390/ipam390.c                      |  2 +-
 board/BuR/common/common.c                          | 12 ++++----
 board/BuS/eb_cpu5282/eb_cpu5282.c                  |  8 ++---
 board/CarMediaLab/flea3/flea3.c                    |  2 +-
 board/LaCie/net2big_v2/net2big_v2.c                |  2 +-
 board/LaCie/netspace_v2/netspace_v2.c              |  2 +-
 board/amazon/kc1/kc1.c                             |  2 +-
 board/amlogic/odroid-c2/odroid-c2.c                |  2 +-
 board/aristainetos/aristainetos-v2.c               |  4 +--
 board/atmel/sama5d2_xplained/sama5d2_xplained.c    |  2 +-
 board/birdland/bav335x/board.c                     |  2 +-
 board/bluegiga/apx4devkit/apx4devkit.c             |  4 +--
 board/bluewater/gurnard/gurnard.c                  |  6 ++--
 board/bosch/shc/board.c                            |  2 +-
 board/boundary/nitrogen6x/nitrogen6x.c             |  8 ++---
 board/broadcom/bcm23550_w1d/bcm23550_w1d.c         |  2 +-
 board/broadcom/bcm28155_ap/bcm28155_ap.c           |  2 +-
 board/cadence/xtfpga/xtfpga.c                      |  2 +-
 board/compulab/cl-som-am57x/eth.c                  |  2 +-
 board/compulab/cm_fx6/cm_fx6.c                     |  4 +--
 board/compulab/common/omap3_display.c              |  4 +--
 board/congatec/cgtqmx6eval/cgtqmx6eval.c           |  4 +--
 board/davinci/da8xxevm/da850evm.c                  |  2 +-
 board/davinci/da8xxevm/omapl138_lcdk.c             |  4 +--
 board/esd/meesc/meesc.c                            |  7 +++--
 board/freescale/b4860qds/b4860qds.c                |  4 +--
 board/freescale/common/sys_eeprom.c                |  2 +-
 board/freescale/common/vid.c                       |  4 +--
 board/freescale/ls2080aqds/eth.c                   |  6 ++--
 board/freescale/ls2080aqds/ls2080aqds.c            |  2 +-
 board/freescale/ls2080ardb/ls2080ardb.c            |  2 +-
 board/freescale/mpc837xemds/pci.c                  |  2 +-
 board/freescale/mpc837xerdb/mpc837xerdb.c          |  2 +-
 board/freescale/mx51evk/mx51evk_video.c            |  2 +-
 board/freescale/mx53loco/mx53loco_video.c          |  2 +-
 board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c        |  3 +-
 board/freescale/t4qds/t4240qds.c                   |  2 +-
 board/gateworks/gw_ventana/common.c                |  2 +-
 board/gateworks/gw_ventana/gw_ventana.c            | 34 ++++++++++----------
 board/gateworks/gw_ventana/gw_ventana_spl.c        |  2 +-
 board/gdsys/a38x/keyprogram.c                      |  4 +--
 board/gdsys/mpc8308/hrcon.c                        |  2 +-
 board/gdsys/mpc8308/strider.c                      |  2 +-
 board/gdsys/p1022/controlcenterd-id.c              |  6 ++--
 board/gdsys/p1022/controlcenterd.c                 |  2 +-
 board/grinn/chiliboard/board.c                     |  4 +--
 board/grinn/liteboard/board.c                      |  2 +-
 board/highbank/highbank.c                          |  2 +-
 board/intel/edison/edison.c                        |  4 +--
 board/keymile/common/common.c                      | 10 +++---
 board/keymile/common/ivm.c                         |  2 +-
 board/keymile/km_arm/km_arm.c                      |  2 +-
 board/keymile/kmp204x/kmp204x.c                    |  2 +-
 board/kosagi/novena/novena.c                       |  2 +-
 board/lg/sniper/sniper.c                           |  2 +-
 board/liebherr/mccmon6/mccmon6.c                   |  4 +--
 board/logicpd/omap3som/omap3logic.c                |  2 +-
 board/micronas/vct/vct.c                           |  2 +-
 board/nokia/rx51/rx51.c                            |  8 ++---
 board/raspberrypi/rpi/rpi.c                        | 12 ++++----
 board/samsung/common/exynos5-dt.c                  |  2 +-
 board/samsung/odroid/odroid.c                      |  2 +-
 board/samtec/vining_2000/vining_2000.c             |  2 +-
 board/samtec/vining_fpga/socfpga.c                 |  6 ++--
 board/siemens/common/board.c                       |  4 +--
 board/siemens/taurus/taurus.c                      | 18 +++++------
 board/socrates/socrates.c                          |  4 +--
 board/st/stm32f429-discovery/stm32f429-discovery.c |  2 +-
 board/sunxi/board.c                                |  6 ++--
 board/syteco/zmx25/zmx25.c                         |  2 +-
 board/tcl/sl50/board.c                             |  4 +--
 board/technexion/twister/twister.c                 |  2 +-
 board/teejet/mt_ventoux/mt_ventoux.c               |  4 +--
 board/theobroma-systems/puma_rk3399/puma-rk3399.c  |  6 ++--
 board/ti/am335x/board.c                            |  4 +--
 board/ti/am43xx/board.c                            |  4 +--
 board/ti/am57xx/board.c                            |  4 +--
 board/ti/dra7xx/evm.c                              |  4 +--
 board/ti/ks2_evm/board.c                           | 12 ++++----
 board/toradex/apalis_imx6/apalis_imx6.c            |  2 +-
 board/toradex/common/tdx-cfg-block.c               |  2 +-
 board/varisys/common/sys_eeprom.c                  |  2 +-
 board/vscom/baltos/board.c                         |  2 +-
 .../work-microwave/work_92105/work_92105_display.c |  2 +-
 board/xes/common/board.c                           |  6 ++--
 board/xilinx/zynqmp/zynqmp.c                       |  4 +--
 cmd/bdinfo.c                                       |  6 ++--
 cmd/bootm.c                                        |  4 +--
 cmd/bootmenu.c                                     |  4 +--
 cmd/cramfs.c                                       |  8 ++---
 cmd/elf.c                                          | 26 ++++++++--------
 cmd/fpga.c                                         |  4 +--
 cmd/gpt.c                                          |  4 +--
 cmd/ini.c                                          |  4 +--
 cmd/itest.c                                        |  2 +-
 cmd/jffs2.c                                        |  4 +--
 cmd/load.c                                         | 10 +++---
 cmd/log.c                                          |  6 ++--
 cmd/md5sum.c                                       |  2 +-
 cmd/mtdparts.c                                     | 10 +++---
 cmd/mvebu/bubt.c                                   |  2 +-
 cmd/nand.c                                         |  6 ++--
 cmd/net.c                                          |  4 +--
 cmd/nvedit.c                                       | 14 ++++-----
 cmd/pxe.c                                          | 30 +++++++++---------
 cmd/qfw.c                                          |  4 +--
 cmd/reiser.c                                       |  6 ++--
 cmd/setexpr.c                                      |  2 +-
 cmd/zfs.c                                          |  4 +--
 common/autoboot.c                                  | 16 +++++-----
 common/bootm.c                                     |  4 +--
 common/bootm_os.c                                  | 10 +++---
 common/bootretry.c                                 |  2 +-
 common/cli.c                                       |  2 +-
 common/cli_hush.c                                  | 14 ++++-----
 common/cli_simple.c                                |  4 +--
 common/console.c                                   | 10 +++---
 common/fb_mmc.c                                    |  2 +-
 common/fdt_support.c                               |  6 ++--
 common/hash.c                                      |  2 +-
 common/hwconfig.c                                  |  2 +-
 common/image-android.c                             |  2 +-
 common/image-fdt.c                                 |  2 +-
 common/image.c                                     | 14 +++++----
 common/lcd.c                                       |  2 +-
 common/main.c                                      |  2 +-
 common/spl/Kconfig                                 |  2 +-
 common/spl/spl_dfu.c                               |  2 +-
 common/spl/spl_ext.c                               |  4 +--
 common/spl/spl_fat.c                               |  4 +--
 common/splash.c                                    |  2 +-
 common/splash_source.c                             |  6 ++--
 common/update.c                                    |  7 +++--
 common/usb_hub.c                                   |  2 +-
 common/usb_kbd.c                                   |  6 ++--
 disk/part.c                                        |  2 +-
 disk/part_amiga.c                                  |  4 +--
 drivers/ddr/fsl/fsl_ddr_gen4.c                     |  2 +-
 drivers/ddr/fsl/interactive.c                      |  8 ++---
 drivers/ddr/fsl/options.c                          |  6 ++--
 drivers/dfu/dfu.c                                  |  6 ++--
 drivers/dfu/dfu_mmc.c                              |  2 +-
 drivers/input/i8042.c                              |  2 +-
 drivers/input/input.c                              |  2 +-
 drivers/mtd/cfi_flash.c                            |  2 +-
 drivers/net/fec_mxc.c                              |  2 +-
 drivers/net/fm/b4860.c                             |  2 +-
 drivers/net/fm/fdt.c                               |  2 +-
 drivers/net/fsl-mc/mc.c                            |  6 ++--
 drivers/net/netconsole.c                           |  8 ++---
 drivers/net/phy/micrel.c                           |  2 +-
 drivers/pci/fsl_pci_init.c                         |  4 +--
 drivers/pci/pci.c                                  |  4 +--
 drivers/pci/pci_common.c                           |  2 +-
 drivers/rtc/m41t60.c                               |  2 +-
 drivers/serial/usbtty.c                            |  9 +++---
 drivers/usb/gadget/designware_udc.c                |  2 +-
 drivers/usb/gadget/ether.c                         | 12 ++++----
 drivers/usb/gadget/f_dfu.c                         |  2 +-
 drivers/usb/gadget/f_fastboot.c                    |  6 ++--
 drivers/usb/host/ehci-fsl.c                        |  2 +-
 drivers/video/ati_radeon_fb.c                      |  3 +-
 drivers/video/cfb_console.c                        |  2 +-
 drivers/video/ct69000.c                            |  3 +-
 drivers/video/mb862xx.c                            |  3 +-
 drivers/video/mx3fb.c                              |  2 +-
 drivers/video/mxsfb.c                              |  2 +-
 drivers/video/videomodes.c                         |  5 +--
 env/callback.c                                     |  2 +-
 env/common.c                                       |  4 +--
 env/flags.c                                        |  4 +--
 fs/fs.c                                            |  4 +--
 include/_exports.h                                 |  2 +-
 include/asm-generic/global_data.h                  |  2 +-
 include/common.h                                   | 32 ++++++++++++++-----
 include/exports.h                                  |  2 +-
 include/image.h                                    |  2 +-
 lib/smbios.c                                       |  2 +-
 net/bootp.c                                        | 10 +++---
 net/eth-uclass.c                                   |  6 ++--
 net/eth_common.c                                   | 14 ++++-----
 net/eth_legacy.c                                   |  2 +-
 net/net.c                                          |  6 ++--
 net/tftp.c                                         | 10 +++---
 post/post.c                                        |  2 +-
 test/command_ut.c                                  | 16 +++++-----
 test/dm/eth.c                                      | 36 +++++++++++-----------
 214 files changed, 530 insertions(+), 500 deletions(-)
README +1 -1
index 1527dee040..e4a2479bf6 100644
@@ -3435,7 +3435,7 @@ but it can not erase, write this NOR flash by SRIO or PCIE interface.
 
 Please note that the environment is read-only until the monitor
 has been relocated to RAM and a RAM copy of the environment has been
-created; also, when using EEPROM you will have to use getenv_f()
+created; also, when using EEPROM you will have to use env_get_f()
 until then to read environment variables.
 
 The environment is protected by a CRC32 checksum. Before the monitor
api/api.c +1 -1
index 2e620e2a0f..24be170148 100644
@@ -458,7 +458,7 @@ static int API_env_get(va_list ap)
 	if ((value = (char **)va_arg(ap, uintptr_t)) == NULL)
 		return API_EINVAL;
 
-	*value = getenv(name);
+	*value = env_get(name);
 
 	return 0;
 }
arch/arc/lib/bootm.c +1 -1
index 5798149046..a498ce5b29 100644
@@ -85,7 +85,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 		r2 = (unsigned int)images->ft_addr;
 	} else {
 		r0 = 1;
-		r2 = (unsigned int)getenv("bootargs");
+		r2 = (unsigned int)env_get("bootargs");
 	}
 
 	smp_set_core_boot_addr((unsigned long)kernel_entry, -1);
arch/arm/cpu/armv8/fsl-layerscape/soc.c +1 -1
index aee1ffa7d4..639e9d2ddc 100644
@@ -95,7 +95,7 @@ static void erratum_a008514(void)
 
 static unsigned long get_internval_val_mhz(void)
 {
-	char *interval = getenv(PLATFORM_CYCLE_ENV_VAR);
+	char *interval = env_get(PLATFORM_CYCLE_ENV_VAR);
 	/*
 	 *  interval is the number of platform cycles(MHz) between
 	 *  wake up events generated by EPU.
arch/arm/lib/bootm.c +3 -3
index 704849bd0c..5c62d9c144 100644
@@ -216,7 +216,7 @@ static void do_nonsec_virt_switch(void)
 /* Subcommand: PREP */
 static void boot_prep_linux(bootm_headers_t *images)
 {
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 
 	if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
 #ifdef CONFIG_OF_LIBFDT
@@ -273,7 +273,7 @@ __weak bool armv7_boot_nonsec_default(void)
 #ifdef CONFIG_ARMV7_NONSEC
 bool armv7_boot_nonsec(void)
 {
-	char *s = getenv("bootm_boot_mode");
+	char *s = env_get("bootm_boot_mode");
 	bool nonsec = armv7_boot_nonsec_default();
 
 	if (s && !strcmp(s, "sec"))
@@ -361,7 +361,7 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
 	ulong addr = (ulong)kernel_entry | 1;
 	kernel_entry = (void *)addr;
 #endif
-	s = getenv("machid");
+	s = env_get("machid");
 	if (s) {
 		if (strict_strtoul(s, 16, &machid) < 0) {
 			debug("strict_strtoul failed!\n");
arch/arm/mach-imx/video.c +1 -1
index 55242f0eaa..c670c5dfc9 100644
@@ -10,7 +10,7 @@ int board_video_skip(void)
 {
 	int i;
 	int ret;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 
 	if (!panel) {
 		for (i = 0; i < display_count; i++) {
arch/arm/mach-keystone/ddr3.c +1 -1
index 4cad6a2d81..b2f5414a5c 100644
@@ -331,7 +331,7 @@ void ddr3_check_ecc_int(u32 base)
 	int ecc_test = 0;
 	u32 value = __raw_readl(base + KS2_DDR3_ECC_INT_STATUS_OFFSET);
 
-	env = getenv("ecc_test");
+	env = env_get("ecc_test");
 	if (env)
 		ecc_test = simple_strtol(env, NULL, 0);
 
arch/arm/mach-keystone/keystone.c +1 -1
index beb8a767c4..fcabfbd5c3 100644
@@ -46,7 +46,7 @@ int misc_init_r(void)
 	char *env;
 	long ks2_debug = 0;
 
-	env = getenv("ks2_debug");
+	env = env_get("ks2_debug");
 
 	if (env)
 		ks2_debug = simple_strtol(env, NULL, 0);
arch/arm/mach-kirkwood/cpu.c +2 -2
index 4c9d3fde47..db2ff0311c 100644
@@ -129,7 +129,7 @@ int kw_config_adr_windows(void)
 static void kw_sysrst_action(void)
 {
 	int ret;
-	char *s = getenv("sysrstcmd");
+	char *s = env_get("sysrstcmd");
 
 	if (!s) {
 		debug("Error.. %s failed, check sysrstcmd\n",
@@ -153,7 +153,7 @@ static void kw_sysrst_check(void)
 	/*
 	 * no action if sysrstdelay environment variable is not defined
 	 */
-	s = getenv("sysrstdelay");
+	s = env_get("sysrstdelay");
 	if (s == NULL)
 		return;
 
arch/arm/mach-omap2/utils.c +4 -4
index c03e93878d..0b0bf1837c 100644
@@ -70,7 +70,7 @@ static void omap_set_fastboot_board_rev(void)
 {
 	const char *board_rev;
 
-	board_rev = getenv("board_rev");
+	board_rev = env_get("board_rev");
 	if (board_rev == NULL)
 		printf("Warning: fastboot.board_rev: unknown board revision\n");
 
@@ -169,7 +169,7 @@ void omap_die_id_serial(void)
 
 	omap_die_id((unsigned int *)&die_id);
 
-	if (!getenv("serial#")) {
+	if (!env_get("serial#")) {
 		snprintf(serial_string, sizeof(serial_string),
 			"%08x%08x", die_id[0], die_id[3]);
 
@@ -182,7 +182,7 @@ void omap_die_id_get_board_serial(struct tag_serialnr *serialnr)
 	char *serial_string;
 	unsigned long long serial;
 
-	serial_string = getenv("serial#");
+	serial_string = env_get("serial#");
 
 	if (serial_string) {
 		serial = simple_strtoull(serial_string, NULL, 16);
@@ -202,7 +202,7 @@ void omap_die_id_usbethaddr(void)
 
 	omap_die_id((unsigned int *)&die_id);
 
-	if (!getenv("usbethaddr")) {
+	if (!env_get("usbethaddr")) {
 		/*
 		 * Create a fake MAC address from the processor ID code.
 		 * First byte is 0x02 to signify locally administered.
arch/arm/mach-tegra/tegra186/nvtboot_board.c +1 -1
index 9cd3fe2f30..b94eb424aa 100644
@@ -35,7 +35,7 @@ static int set_ethaddr_from_nvtboot(void)
 	const u32 *prop;
 
 	/* Already a valid address in the environment? If so, keep it */
-	if (getenv("ethaddr"))
+	if (env_get("ethaddr"))
 		return 0;
 
 	node = fdt_path_offset(nvtboot_blob, "/chosen");
arch/arm/mach-uniphier/board_late_init.c +1 -1
index e6d600e41f..b9a2cbe148 100644
@@ -37,7 +37,7 @@ static int uniphier_set_fdt_file(void)
 	char dtb_name[256];
 	int buf_len = sizeof(dtb_name);
 
-	if (getenv("fdt_file"))
+	if (env_get("fdt_file"))
 		return 0;	/* do nothing if it is already set */
 
 	compat = fdt_stringlist_get(gd->fdt_blob, 0, "compatible", 0, NULL);
arch/m68k/lib/bootm.c +2 -1
index fa9c493081..c976904fa9 100644
@@ -113,7 +113,8 @@ static void set_clocks_in_mhz (bd_t *kbd)
 {
 	char *s;
 
-	if ((s = getenv("clocks_in_mhz")) != NULL) {
+	s = env_get("clocks_in_mhz");
+	if (s) {
 		/* convert all clock information to MHz */
 		kbd->bi_intfreq /= 1000000L;
 		kbd->bi_busfreq /= 1000000L;
arch/microblaze/lib/bootm.c +1 -1
index 2732203b93..0a286e82c2 100644
@@ -27,7 +27,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[],
 {
 	/* First parameter is mapped to $r5 for kernel boot args */
 	void	(*thekernel) (char *, ulong, ulong);
-	char	*commandline = getenv("bootargs");
+	char	*commandline = env_get("bootargs");
 	ulong	rd_data_start, rd_data_end;
 
 	/*
arch/mips/lib/bootm.c +3 -3
index 2b6790524c..5a9a2811ff 100644
@@ -80,7 +80,7 @@ static void linux_cmdline_legacy(bootm_headers_t *images)
 
 	linux_cmdline_init();
 
-	bootargs = getenv("bootargs");
+	bootargs = env_get("bootargs");
 	if (!bootargs)
 		return;
 
@@ -202,11 +202,11 @@ static void linux_env_legacy(bootm_headers_t *images)
 	sprintf(env_buf, "0x%X", (uint) (gd->bd->bi_flashsize));
 	linux_env_set("flash_size", env_buf);
 
-	cp = getenv("ethaddr");
+	cp = env_get("ethaddr");
 	if (cp)
 		linux_env_set("ethaddr", cp);
 
-	cp = getenv("eth1addr");
+	cp = env_get("eth1addr");
 	if (cp)
 		linux_env_set("eth1addr", cp);
 
arch/nds32/lib/bootm.c +2 -2
index 21aadf284f..e834329e0b 100644
@@ -50,7 +50,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 	void	(*theKernel)(int zero, int arch, uint params);
 
 #ifdef CONFIG_CMDLINE_TAG
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 #endif
 
 	/*
@@ -64,7 +64,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 
 	theKernel = (void (*)(int, int, uint))images->ep;
 
-	s = getenv("machid");
+	s = env_get("machid");
 	if (s) {
 		machid = simple_strtoul(s, NULL, 16);
 		printf("Using machid 0x%x from environment\n", machid);
arch/nios2/lib/bootm.c +1 -1
index 4e5c269193..00ade2c573 100644
@@ -12,7 +12,7 @@
 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
 {
 	void (*kernel)(int, int, int, char *) = (void *)images->ep;
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 	ulong initrd_start = images->rd_start;
 	ulong initrd_end = images->rd_end;
 	char *of_flat_tree = NULL;
arch/powerpc/cpu/mpc85xx/cpu_init.c +5 -5
index a3076d8d71..ea46e49853 100644
@@ -256,7 +256,7 @@ static void enable_tdm_law(void)
 	 * is not setup properly yet. Search for tdm entry in
 	 * hwconfig.
 	 */
-	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
+	ret = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (ret > 0) {
 		tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
 		/* If tdm is defined in hwconfig, set law for tdm workaround */
@@ -280,7 +280,7 @@ void enable_cpc(void)
 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
 
 	/* Extract hwconfig from environment */
-	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
+	ret = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (ret > 0) {
 		/*
 		 * If "en_cpc" is not defined in hwconfig then by default all
@@ -754,7 +754,7 @@ int cpu_init_r(void)
 	char *buf = NULL;
 	int n, res;
 
-	n = getenv_f("hwconfig", buffer, sizeof(buffer));
+	n = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (n > 0)
 		buf = buffer;
 
@@ -794,7 +794,7 @@ int cpu_init_r(void)
 #endif
 
 #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
-	spin = getenv("spin_table_compat");
+	spin = env_get("spin_table_compat");
 	if (spin && (*spin == 'n'))
 		spin_table_compat = 0;
 	else
@@ -845,7 +845,7 @@ int cpu_init_r(void)
 #ifdef CONFIG_SYS_SRIO
 	srio_init();
 #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
-	char *s = getenv("bootmaster");
+	char *s = env_get("bootmaster");
 	if (s) {
 		if (!strcmp(s, "SRIO1")) {
 			srio_boot_master(1);
arch/powerpc/cpu/mpc85xx/fdt.c +1 -1
index a9ea947305..27d3b3ffe9 100644
@@ -92,7 +92,7 @@ void ft_fixup_cpu(void *blob, u64 memory_limit)
 	 * Extract hwconfig from environment.
 	 * Search for tdm entry in hwconfig.
 	 */
-	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
+	ret = env_get_f("hwconfig", buffer, sizeof(buffer));
 	if (ret > 0)
 		tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
 
arch/powerpc/cpu/mpc85xx/fsl_corenet_serdes.c +1 -1
index 1bc0c64cfc..79d6544a09 100644
@@ -514,7 +514,7 @@ void fsl_serdes_init(void)
 	 * Extract hwconfig from environment since we have not properly setup
 	 * the environment but need it for ddr config params
 	 */
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		buf = buffer;
 #endif
 	if (serdes_prtcl_map & (1 << NONE))
arch/powerpc/lib/bootm.c +2 -1
index 0e204027af..932c38ab4c 100644
@@ -275,7 +275,8 @@ static void set_clocks_in_mhz (bd_t *kbd)
 {
 	char	*s;
 
-	if ((s = getenv ("clocks_in_mhz")) != NULL) {
+	s = env_get("clocks_in_mhz");
+	if (s) {
 		/* convert all clock information to MHz */
 		kbd->bi_intfreq /= 1000000L;
 		kbd->bi_busfreq /= 1000000L;
arch/sh/lib/bootm.c +1 -1
index 8a0010be23..09fbd5e5df 100644
@@ -61,7 +61,7 @@ int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima
 	char *cmdline = (char *)param + COMMAND_LINE;
 	/* PAGE_SIZE */
 	unsigned long size = images->ep - (unsigned long)param;
-	char *bootargs = getenv("bootargs");
+	char *bootargs = env_get("bootargs");
 
 	/*
 	 * allow the PREP bootm subcommand, it is required for bootm to work
arch/sh/lib/zimageboot.c +1 -1
index 3fea5f5b53..cd4abba10a 100644
@@ -42,7 +42,7 @@ int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* Linux kernel command line */
 	cmdline = (char *)param + COMMAND_LINE;
-	bootargs = getenv("bootargs");
+	bootargs = env_get("bootargs");
 
 	/* Clear zero page */
 	/* cppcheck-suppress nullPointer */
arch/x86/lib/zimage.c +4 -4
index aafbeb01f9..00172dc7c1 100644
@@ -48,15 +48,15 @@ static void build_command_line(char *command_line, int auto_boot)
 
 	command_line[0] = '\0';
 
-	env_command_line =  getenv("bootargs");
+	env_command_line =  env_get("bootargs");
 
 	/* set console= argument if we use a serial console */
 	if (!strstr(env_command_line, "console=")) {
-		if (!strcmp(getenv("stdout"), "serial")) {
+		if (!strcmp(env_get("stdout"), "serial")) {
 
 			/* We seem to use serial console */
 			sprintf(command_line, "console=ttyS0,%s ",
-				getenv("baudrate"));
+				env_get("baudrate"));
 		}
 	}
 
@@ -285,7 +285,7 @@ int do_zboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		/* argv[1] holds the address of the bzImage */
 		s = argv[1];
 	} else {
-		s = getenv("fileaddr");
+		s = env_get("fileaddr");
 	}
 
 	if (s)
arch/xtensa/lib/bootm.c +1 -1
index 1604bb9536..16961acba5 100644
@@ -136,7 +136,7 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 {
 	struct bp_tag *params, *params_start;
 	ulong initrd_start, initrd_end;
-	char *commandline = getenv("bootargs");
+	char *commandline = env_get("bootargs");
 
 	if (!(flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)))
 		return 0;
board/Arcturus/ucp1020/cmd_arc.c +3 -3
index c32f7df454..0d3ac88fff 100644
@@ -149,7 +149,7 @@ int get_arc_info(void)
 	if (smac[2][0] == 0xFF) {
 		printf("\t<not found>\n");
 	} else {
-		char *ret = getenv("ethaddr");
+		char *ret = env_get("ethaddr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETHADDR)) == 0) {
 			env_set("ethaddr", smac[2]);
@@ -169,7 +169,7 @@ int get_arc_info(void)
 	if (smac[1][0] == 0xFF) {
 		printf("\t<not found>\n");
 	} else {
-		char *ret = getenv("eth1addr");
+		char *ret = env_get("eth1addr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETH1ADDR)) == 0) {
 			env_set("eth1addr", smac[1]);
@@ -188,7 +188,7 @@ int get_arc_info(void)
 	if (smac[0][0] == 0xFF) {
 		printf("\t<not found>\n");
 	} else {
-		char *ret = getenv("eth2addr");
+		char *ret = env_get("eth2addr");
 
 		if (strcmp(ret, __stringify(CONFIG_ETH2ADDR)) == 0) {
 			env_set("eth2addr", smac[0]);
board/Arcturus/ucp1020/ucp1020.c +5 -5
index 2cc2e54d5b..dfdaf0441c 100644
@@ -64,7 +64,7 @@ void board_gpio_init(void)
 
 	for (i = 0; i < GPIO_MAX_NUM; i++) {
 		sprintf(envname, "GPIO%d", i);
-		val = getenv(envname);
+		val = env_get(envname);
 		if (val) {
 			char direction = toupper(val[0]);
 			char level = toupper(val[1]);
@@ -82,7 +82,7 @@ void board_gpio_init(void)
 		}
 	}
 
-	val = getenv("PCIE_OFF");
+	val = env_get("PCIE_OFF");
 	if (val) {
 		gpio_direction_input(GPIO_PCIE1_EN);
 		gpio_direction_input(GPIO_PCIE2_EN);
@@ -91,7 +91,7 @@ void board_gpio_init(void)
 		gpio_direction_output(GPIO_PCIE2_EN, 1);
 	}
 
-	val = getenv("SDHC_CDWP_OFF");
+	val = env_get("SDHC_CDWP_OFF");
 	if (!val) {
 		ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 
@@ -214,7 +214,7 @@ int last_stage_init(void)
 	else
 		printf("NCT72(0x%x): ready\n", id2);
 
-	kval = getenv("kernelargs");
+	kval = env_get("kernelargs");
 
 	mmc = find_mmc_device(0);
 	if (mmc)
@@ -238,7 +238,7 @@ int last_stage_init(void)
 	get_arc_info();
 
 	if (kval) {
-		sval = getenv("SERIAL");
+		sval = env_get("SERIAL");
 		if (sval) {
 			strcpy(newkernelargs, "SN=");
 			strcat(newkernelargs, sval);
board/Barix/ipam390/ipam390.c +1 -1
index 3a584021ac..d203429738 100644
@@ -157,7 +157,7 @@ u32 get_board_rev(void)
 	u32 maxcpuclk = CONFIG_DA850_EVM_MAX_CPU_CLK;
 	u32 rev = 0;
 
-	s = getenv("maxcpuclk");
+	s = env_get("maxcpuclk");
 	if (s)
 		maxcpuclk = simple_strtoul(s, NULL, 10);
 
board/BuR/common/common.c +6 -6
index eb34de931e..39a600b5c1 100644
@@ -263,9 +263,9 @@ static int load_devicetree(void)
 				(size_t *)&dtbsize,
 				NULL, 0x20000, (u_char *)dtbaddr);
 #else
-	char *dtbname = getenv("dtb");
-	char *dtbdev = getenv("dtbdev");
-	char *dtbpart = getenv("dtbpart");
+	char *dtbname = env_get("dtb");
+	char *dtbdev = env_get("dtbdev");
+	char *dtbpart = env_get("dtbpart");
 	if (!dtbdev || !dtbpart || !dtbname) {
 		printf("%s: <dtbdev>/<dtbpart>/<dtb> missing.\n", __func__);
 		return -1;
@@ -405,11 +405,11 @@ static void br_summaryscreen_printenv(char *prefix,
 				       char *name, char *altname,
 				       char *suffix)
 {
-	char *envval = getenv(name);
+	char *envval = env_get(name);
 	if (0 != envval) {
 		lcd_printf("%s %s %s", prefix, envval, suffix);
 	} else if (0 != altname) {
-		envval = getenv(altname);
+		envval = env_get(altname);
 		if (0 != envval)
 			lcd_printf("%s %s %s", prefix, envval, suffix);
 	} else {
@@ -657,7 +657,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		#if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USE_FDT)
 		printf("<ethaddr> not set. trying DTB ... ");
 		mac = dtbmacaddr(0);
board/BuS/eb_cpu5282/eb_cpu5282.c +4 -4
index a00a83a4a5..d23b9f3a4f 100644
@@ -139,7 +139,7 @@ void hw_watchdog_init(void)
 	int enable;
 
 	enable = 1;
-	s = getenv("watchdog");
+	s = env_get("watchdog");
 	if (s != NULL)
 		if ((strncmp(s, "off", 3) == 0) || (strncmp(s, "0", 1) == 0))
 			enable = 0;
@@ -191,13 +191,13 @@ int drv_video_init(void)
 	unsigned long splash;
 #endif
 	printf("Init Video as ");
-	s = getenv("displaywidth");
+	s = env_get("displaywidth");
 	if (s != NULL)
 		display_width = simple_strtoul(s, NULL, 10);
 	else
 		display_width = 256;
 
-	s = getenv("displayheight");
+	s = env_get("displayheight");
 	if (s != NULL)
 		display_height = simple_strtoul(s, NULL, 10);
 	else
@@ -211,7 +211,7 @@ int drv_video_init(void)
 	vcxk_init(display_width, display_height);
 
 #ifdef CONFIG_SPLASH_SCREEN
-	s = getenv("splashimage");
+	s = env_get("splashimage");
 	if (s != NULL) {
 		splash = simple_strtoul(s, NULL, 16);
 		vcxk_acknowledge_wait();
board/CarMediaLab/flea3/flea3.c +1 -1
index 3cd4dc95fe..5e75eb0b64 100644
@@ -211,7 +211,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 		{ "mxc_nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */
 	};
 
-	if (getenv("fdt_noauto")) {
+	if (env_get("fdt_noauto")) {
 		puts("   Skiping ft_board_setup (fdt_noauto defined)\n");
 		return 0;
 	}
board/LaCie/net2big_v2/net2big_v2.c +1 -1
index 416af469fa..f639a37d4d 100644
@@ -221,7 +221,7 @@ int misc_init_r(void)
 {
 	init_fan();
 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		uchar mac[6];
 		if (lacie_read_mac_address(mac) == 0)
 			eth_env_set_enetaddr("ethaddr", mac);
board/LaCie/netspace_v2/netspace_v2.c +1 -1
index fa07288d6e..52f36644a3 100644
@@ -83,7 +83,7 @@ int board_init(void)
 int misc_init_r(void)
 {
 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		uchar mac[6];
 		if (lacie_read_mac_address(mac) == 0)
 			eth_env_set_enetaddr("ethaddr", mac);
board/amazon/kc1/kc1.c +1 -1
index 2d8be1804a..eead98b24e 100644
@@ -118,7 +118,7 @@ int misc_init_r(void)
 	}
 
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
-		if (!getenv("reboot-mode"))
+		if (!env_get("reboot-mode"))
 			env_set("reboot-mode", (char *)reboot_mode);
 	}
 
board/amlogic/odroid-c2/odroid-c2.c +1 -1
index ca9c13bcc1..611155d3e5 100644
@@ -51,7 +51,7 @@ int misc_init_r(void)
 			eth_env_set_enetaddr("ethaddr", mac_addr);
 	}
 
-	if (!getenv("serial#")) {
+	if (!env_get("serial#")) {
 		len = meson_sm_read_efuse(EFUSE_SN_OFFSET, serial,
 			EFUSE_SN_SIZE);
 		if (len == EFUSE_SN_SIZE) 
board/aristainetos/aristainetos-v2.c +2 -2
index bdf41b99c8..698715ca20 100644
@@ -651,7 +651,7 @@ int board_late_init(void)
 {
 	char *my_bootdelay;
 	char bootmode = 0;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 
 	/*
 	 * Check the boot-source. If booting from NOR Flash,
@@ -668,7 +668,7 @@ int board_late_init(void)
 	bootmode |= (gpio_get_value(IMX_GPIO_NR(7, 1)) ? 1 : 0) << 2;
 
 	if (bootmode == 7) {
-		my_bootdelay = getenv("nor_bootdelay");
+		my_bootdelay = env_get("nor_bootdelay");
 		if (my_bootdelay != NULL)
 			env_set("bootdelay", my_bootdelay);
 		else
board/atmel/sama5d2_xplained/sama5d2_xplained.c +1 -1
index 4a06cda6f4..3f0860c555 100644
@@ -169,7 +169,7 @@ static int set_ethaddr_from_eeprom(void)
 	const char *ETHADDR_NAME = "ethaddr";
 	struct udevice *bus, *dev;
 
-	if (getenv(ETHADDR_NAME))
+	if (env_get(ETHADDR_NAME))
 		return 0;
 
 	if (uclass_get_device_by_seq(UCLASS_I2C, 1, &bus)) {
board/birdland/bav335x/board.c +1 -1
index a9d9ce6fa5..e174336e2c 100644
@@ -392,7 +392,7 @@ int board_eth_init(bd_t *bis)
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
board/bluegiga/apx4devkit/apx4devkit.c +2 -2
index 2215c29c9c..25e5c3d80c 100644
@@ -133,8 +133,8 @@ void get_board_serial(struct tag_serialnr *serialnr)
 #ifdef CONFIG_REVISION_TAG
 u32 get_board_rev(void)
 {
-	if (getenv("revision#") != NULL)
-		return simple_strtoul(getenv("revision#"), NULL, 10);
+	if (env_get("revision#") != NULL)
+		return simple_strtoul(env_get("revision#"), NULL, 10);
 	return 0;
 }
 #endif
board/bluewater/gurnard/gurnard.c +3 -3
index e82c691841..8733a9af16 100644
@@ -341,7 +341,7 @@ int board_init(void)
 	at91_set_A_periph(AT91_PIN_PE6, 1);	/* power up */
 
 	/* Select the second timing index for board rev 2 */
-	rev_str = getenv("board_rev");
+	rev_str = env_get("board_rev");
 	if (rev_str && !strncmp(rev_str, "2", 1)) {
 		struct udevice *dev;
 
@@ -368,7 +368,7 @@ int board_late_init(void)
 	 * Set MAC address so we do not need to init Ethernet before Linux
 	 * boot
 	 */
-	env_str = getenv("ethaddr");
+	env_str = env_get("ethaddr");
 	if (env_str) {
 		struct at91_emac *emac = (struct at91_emac *)ATMEL_BASE_EMAC;
 		/* Parse MAC address */
@@ -385,7 +385,7 @@ int board_late_init(void)
 		       &emac->sa2l);
 		writel((env_enetaddr[4] | env_enetaddr[5] << 8), &emac->sa2h);
 
-		printf("MAC:   %s\n", getenv("ethaddr"));
+		printf("MAC:   %s\n", env_get("ethaddr"));
 	} else {
 		/* Not set in environment */
 		printf("MAC:   not set\n");
board/bosch/shc/board.c +1 -1
index b4c6a0b45d..999ed95c31 100644
@@ -545,7 +545,7 @@ int board_eth_init(bd_t *bis)
 
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
board/boundary/nitrogen6x/nitrogen6x.c +4 -4
index 0e2c4fc0ef..3b92b64f6a 100644
@@ -749,7 +749,7 @@ size_t display_count = ARRAY_SIZE(displays);
 
 int board_cfb_skip(void)
 {
-	return NULL != getenv("novideo");
+	return NULL != env_get("novideo");
 }
 
 static void setup_display(void)
@@ -974,7 +974,7 @@ static void preboot_keys(void)
 	char keypress[ARRAY_SIZE(buttons)+1];
 	numpressed = read_keys(keypress);
 	if (numpressed) {
-		char *kbd_magic_keys = getenv("magic_keys");
+		char *kbd_magic_keys = env_get("magic_keys");
 		char *suffix;
 		/*
 		 * loop over all magic keys
@@ -983,7 +983,7 @@ static void preboot_keys(void)
 			char *keys;
 			char magic[sizeof(kbd_magic_prefix) + 1];
 			sprintf(magic, "%s%c", kbd_magic_prefix, *suffix);
-			keys = getenv(magic);
+			keys = env_get(magic);
 			if (keys) {
 				if (!strcmp(keys, keypress))
 					break;
@@ -993,7 +993,7 @@ static void preboot_keys(void)
 			char cmd_name[sizeof(kbd_command_prefix) + 1];
 			char *cmd;
 			sprintf(cmd_name, "%s%c", kbd_command_prefix, *suffix);
-			cmd = getenv(cmd_name);
+			cmd = env_get(cmd_name);
 			if (cmd) {
 				env_set("preboot", cmd);
 				return;
board/broadcom/bcm23550_w1d/bcm23550_w1d.c +1 -1
index 5f4c634362..0267582186 100644
@@ -103,7 +103,7 @@ int board_usb_init(int index, enum usb_init_type init)
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 {
 	debug("%s\n", __func__);
-	if (!getenv("serial#"))
+	if (!env_get("serial#"))
 		g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
 	return 0;
 }
board/broadcom/bcm28155_ap/bcm28155_ap.c +1 -1
index f5b94f6430..8f48ccbf1c 100644
@@ -110,7 +110,7 @@ int board_usb_init(int index, enum usb_init_type init)
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 {
 	debug("%s\n", __func__);
-	if (!getenv("serial#"))
+	if (!env_get("serial#"))
 		g_dnl_set_serialnumber(CONFIG_USB_SERIALNO);
 	return 0;
 }
board/cadence/xtfpga/xtfpga.c +1 -1
index 83244c3ad4..f81fa95c18 100644
@@ -86,7 +86,7 @@ int misc_init_r(void)
 	 * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6.
 	 */
 
-	char *s = getenv("ethaddr");
+	char *s = env_get("ethaddr");
 	if (s == 0) {
 		unsigned int x;
 		char s[] = __stringify(CONFIG_ETHBASE);
board/compulab/cl-som-am57x/eth.c +1 -1
index d2992d3a63..0ad10056fe 100644
@@ -181,7 +181,7 @@ int board_eth_init(bd_t *bis)
 	gpio_set_value(CL_SOM_AM57X_GPIO_PHY1_RST, 1);
 	mdelay(20);
 
-	cpsw_phy_envval = getenv("cpsw_phy");
+	cpsw_phy_envval = env_get("cpsw_phy");
 	if (cpsw_phy_envval != NULL)
 		cpsw_act_phy = simple_strtoul(cpsw_phy_envval, NULL, 0);
 
board/compulab/cm_fx6/cm_fx6.c +2 -2
index 2368226546..5a8ee13c8b 100644
@@ -114,10 +114,10 @@ int board_video_skip(void)
 {
 	int ret;
 	struct display_info_t *preset;
-	char const *panel = getenv("displaytype");
+	char const *panel = env_get("displaytype");
 
 	if (!panel) /* Also accept panel for backward compatibility */
-		panel = getenv("panel");
+		panel = env_get("panel");
 
 	if (!panel)
 		return -ENOENT;
board/compulab/common/omap3_display.c +2 -2
index 61707f5b90..ed2077e361 100644
@@ -400,7 +400,7 @@ void lcd_ctrl_init(void *lcdbase)
 {
 	struct prcm *prcm = (struct prcm *)PRCM_BASE;
 	char *custom_lcd;
-	char *displaytype = getenv("displaytype");
+	char *displaytype = env_get("displaytype");
 
 	if (displaytype == NULL)
 		return;
@@ -408,7 +408,7 @@ void lcd_ctrl_init(void *lcdbase)
 	lcd_def = env_parse_displaytype(displaytype);
 	/* If we did not recognize the preset, check if it's an env variable */
 	if (lcd_def == NONE) {
-		custom_lcd = getenv(displaytype);
+		custom_lcd = env_get(displaytype);
 		if (custom_lcd == NULL || parse_customlcd(custom_lcd) < 0)
 			return;
 	}
board/congatec/cgtqmx6eval/cgtqmx6eval.c +2 -2
index ac66248b3f..8cd0090887 100644
@@ -235,7 +235,7 @@ int power_init_board(void)
 		return 0;
 
 	/* set level of MIPI if specified */
-	lv_mipi = getenv("lv_mipi");
+	lv_mipi = env_get("lv_mipi");
 	if (lv_mipi)
 		return 0;
 
@@ -583,7 +583,7 @@ int board_video_skip(void)
 {
 	int i;
 	int ret;
-	char const *panel = getenv("panel");
+	char const *panel = env_get("panel");
 	if (!panel) {
 		for (i = 0; i < ARRAY_SIZE(displays); i++) {
 			struct display_info_t const *dev = displays + i;
board/davinci/da8xxevm/da850evm.c +1 -1
index 8cab357a92..f8c8bff64c 100644
@@ -292,7 +292,7 @@ u32 get_board_rev(void)
 	u32 maxcpuclk = CONFIG_DA850_EVM_MAX_CPU_CLK;
 	u32 rev = 0;
 
-	s = getenv("maxcpuclk");
+	s = env_get("maxcpuclk");
 	if (s)
 		maxcpuclk = simple_strtoul(s, NULL, 10);
 
board/davinci/da8xxevm/omapl138_lcdk.c +2 -2
index 29296b0478..565020760d 100644
@@ -293,7 +293,7 @@ static void dspwake(void)
 	if ((REG(CHIP_REV_ID_REG) & 0x3f) == 0x10)
 		return;
 
-	if (!strcmp(getenv("dspwake"), "no"))
+	if (!strcmp(env_get("dspwake"), "no"))
 		return;
 
 	*resetvect++ = 0x1E000; /* DSP Idle */
@@ -323,7 +323,7 @@ int misc_init_r(void)
 	uint8_t tmp[20], addr[10];
 
 
-	if (getenv("ethaddr") == NULL) {
+	if (env_get("ethaddr") == NULL) {
 		/* Read Ethernet MAC address from EEPROM */
 		if (dvevm_read_mac_address(addr)) {
 			/* Set Ethernet MAC address from EEPROM */
board/esd/meesc/meesc.c +4 -3
index e4bda7909a..7cc3fdd2f2 100644
@@ -181,7 +181,7 @@ int checkboard(void)
 		puts("Board: EtherCAN/2 Gateway");
 		break;
 	}
-	if (getenv_f("serial#", str, sizeof(str)) > 0) {
+	if (env_get_f("serial#", str, sizeof(str)) > 0) {
 		puts(", serial# ");
 		puts(str);
 	}
@@ -198,7 +198,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
 {
 	char *str;
 
-	char *serial = getenv("serial#");
+	char *serial = env_get("serial#");
 	if (serial) {
 		str = strchr(serial, '_');
 		if (str && (strlen(str) >= 4)) {
@@ -231,7 +231,8 @@ int misc_init_r(void)
 	 * In some cases this this needs to be set to 4.
 	 * Check the user has set environment mdiv to 4 to change the divisor.
 	 */
-	if ((str = getenv("mdiv")) && (strcmp(str, "4") == 0)) {
+	str = env_get("mdiv");
+	if (str && (strcmp(str, "4") == 0)) {
 		writel((readl(&pmc->mckr) & ~AT91_PMC_MDIV) |
 			AT91SAM9_PMC_MDIV_4, &pmc->mckr);
 		at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
board/freescale/b4860qds/b4860qds.c +2 -2
index 83a70153e8..1fea91b3b5 100644
@@ -195,7 +195,7 @@ static int adjust_vdd(ulong vdd_override)
 	      vid, vdd_target/10);
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv("b4qds_vdd_mv");
+	vdd_string = env_get("b4qds_vdd_mv");
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
@@ -542,7 +542,7 @@ int configure_vsc3316_3308(void)
 			 * Extract hwconfig from environment since environment
 			 * is not setup properly yet
 			 */
-			getenv_f("hwconfig", buffer, sizeof(buffer));
+			env_get_f("hwconfig", buffer, sizeof(buffer));
 			buf = buffer;
 
 			if (hwconfig_subarg_cmp_f("fsl_b4860_serdes2",
board/freescale/common/sys_eeprom.c +1 -1
index c593cff5e7..152ad84672 100644
@@ -478,7 +478,7 @@ int mac_read_from_eeprom(void)
 			/* Only initialize environment variables that are blank
 			 * (i.e. have not yet been set)
 			 */
-			if (!getenv(enetvar))
+			if (!env_get(enetvar))
 				env_set(enetvar, ethaddr);
 		}
 	}
board/freescale/common/vid.c +2 -2
index 9b65c13b1a..d6d1bfc861 100644
@@ -376,7 +376,7 @@ int adjust_vdd(ulong vdd_override)
 	vdd_target = vdd[vid];
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv(CONFIG_VID_FLS_ENV);
+	vdd_string = env_get(CONFIG_VID_FLS_ENV);
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
@@ -560,7 +560,7 @@ int adjust_vdd(ulong vdd_override)
 	vdd_target = vdd[vid];
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv(CONFIG_VID_FLS_ENV);
+	vdd_string = env_get(CONFIG_VID_FLS_ENV);
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
board/freescale/ls2080aqds/eth.c +3 -3
index defcac5263..aca29bc361 100644
@@ -449,7 +449,7 @@ static void initialize_dpmac_to_slot(void)
 		>> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
 
 	char *env_hwconfig;
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	switch (serdes1_prtcl) {
 	case 0x07:
@@ -603,7 +603,7 @@ void ls2080a_handle_phy_interface_sgmii(int dpmac_id)
 		>> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
 
 	int *riser_phy_addr;
-	char *env_hwconfig = getenv("hwconfig");
+	char *env_hwconfig = env_get("hwconfig");
 
 	if (hwconfig_f("xqsgmii", env_hwconfig))
 		riser_phy_addr = &xqsgii_riser_phy_addr[0];
@@ -849,7 +849,7 @@ int board_eth_init(bd_t *bis)
 	unsigned int i;
 	char *env_hwconfig;
 
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	initialize_dpmac_to_slot();
 
board/freescale/ls2080aqds/ls2080aqds.c +1 -1
index f36fb9810b..83773d0af5 100644
@@ -204,7 +204,7 @@ int board_init(void)
 
 	val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
 
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	if (hwconfig_f("dspi", env_hwconfig) &&
 	    DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
board/freescale/ls2080ardb/ls2080ardb.c +1 -1
index df2d768718..ed1fbb23fe 100644
@@ -215,7 +215,7 @@ int board_init(void)
 
 	val = in_le32(dcfg_ccsr + DCFG_RCWSR13 / 4);
 
-	env_hwconfig = getenv("hwconfig");
+	env_hwconfig = env_get("hwconfig");
 
 	if (hwconfig_f("dspi", env_hwconfig) &&
 	    DCFG_RCWSR13_DSPI == (val & (u32)(0xf << 8)))
board/freescale/mpc837xemds/pci.c +1 -1
index 39c40e5cc9..e5d3dfd454 100644
@@ -67,7 +67,7 @@ static struct pci_region pcie_regions_1[] = {
 
 static int is_pex_x2(void)
 {
-	const char *pex_x2 = getenv("pex_x2");
+	const char *pex_x2 = env_get("pex_x2");
 
 	if (pex_x2 && !strcmp(pex_x2, "yes"))
 		return 1;
board/freescale/mpc837xerdb/mpc837xerdb.c +1 -1
index 319f0479e2..9a0ab7f2ad 100644
@@ -173,7 +173,7 @@ int board_mmc_init(bd_t *bd)
 	char buffer[HWCONFIG_BUFFER_SIZE] = {0};
 	int esdhc_hwconfig_enabled = 0;
 
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		esdhc_hwconfig_enabled = hwconfig_f("esdhc", buffer);
 
 	if (esdhc_hwconfig_enabled == 0)
board/freescale/mx51evk/mx51evk_video.c +1 -1
index 86ec7508db..cc2c855b88 100644
@@ -76,7 +76,7 @@ void setup_iomux_lcd(void)
 int board_video_skip(void)
 {
 	int ret;
-	char const *e = getenv("panel");
+	char const *e = env_get("panel");
 
 	if (e) {
 		if (strcmp(e, "claa") == 0) {
board/freescale/mx53loco/mx53loco_video.c +1 -1
index bc5e8a9d3e..5fb0f04387 100644
@@ -92,7 +92,7 @@ void setup_iomux_lcd(void)
 int board_video_skip(void)
 {
 	int ret;
-	char const *e = getenv("panel");
+	char const *e = env_get("panel");
 
 	if (e) {
 		if (strcmp(e, "seiko") == 0) {
board/freescale/p1_p2_rdb_pc/p1_p2_rdb_pc.c +2 -1
index 51217c58e5..9ae38ce115 100644
@@ -350,7 +350,8 @@ int board_eth_init(bd_t *bis)
 
 #ifdef CONFIG_VSC7385_ENET
 	/* If a VSC7385 microcode image is present, then upload it. */
-	if ((tmp = getenv("vscfw_addr")) != NULL) {
+	tmp = env_get("vscfw_addr");
+	if (tmp) {
 		vscfw_addr = simple_strtoul(tmp, NULL, 16);
 		printf("uploading VSC7385 microcode from %x\n", vscfw_addr);
 		if (vsc7385_upload_firmware((void *) vscfw_addr,
board/freescale/t4qds/t4240qds.c +1 -1
index 8f9e7e8255..2bdd6a349d 100644
@@ -265,7 +265,7 @@ static int adjust_vdd(ulong vdd_override)
 	vdd_target = vdd[vid];
 
 	/* check override variable for overriding VDD */
-	vdd_string = getenv("t4240qds_vdd_mv");
+	vdd_string = env_get("t4240qds_vdd_mv");
 	if (vdd_override == 0 && vdd_string &&
 	    !strict_strtoul(vdd_string, 10, &vdd_string_override))
 		vdd_override = vdd_string_override;
board/gateworks/gw_ventana/common.c +1 -1
index 46404b4d59..e9865b4adb 100644
@@ -1160,7 +1160,7 @@ void setup_board_gpio(int board, struct ventana_board_info *info)
 	char arg[10];
 	size_t len;
 	int i;
-	int quiet = simple_strtol(getenv("quiet"), NULL, 10);
+	int quiet = simple_strtol(env_get("quiet"), NULL, 10);
 
 	if (board >= GW_UNKNOWN)
 		return;
board/gateworks/gw_ventana/gw_ventana.c +17 -17
index 61298ab2fd..4ddc7e1fa2 100644
@@ -298,11 +298,11 @@ int board_eth_init(bd_t *bis)
 #endif
 
 	/* default to the first detected enet dev */
-	if (!getenv("ethprime")) {
+	if (!env_get("ethprime")) {
 		struct eth_device *dev = eth_get_dev_by_index(0);
 		if (dev) {
 			env_set("ethprime", dev->name);
-			printf("set ethprime to %s\n", getenv("ethprime"));
+			printf("set ethprime to %s\n", env_get("ethprime"));
 		}
 	}
 
@@ -579,7 +579,7 @@ void board_pci_fixup_dev(struct pci_controller *hose, pci_dev_t dev,
  */
 void get_board_serial(struct tag_serialnr *serialnr)
 {
-	char *serial = getenv("serial#");
+	char *serial = env_get("serial#");
 
 	if (serial) {
 		serialnr->high = 0;
@@ -658,7 +658,7 @@ int checkboard(void)
 	int quiet; /* Quiet or minimal output mode */
 
 	quiet = 0;
-	p = getenv("quiet");
+	p = env_get("quiet");
 	if (p)
 		quiet = simple_strtol(p, NULL, 10);
 	else
@@ -746,7 +746,7 @@ int misc_init_r(void)
 		for (i = 0; i < (sizeof(str)-1) && info->model[i]; i++)
 			str[i] = tolower(info->model[i]);
 		env_set("model", str);
-		if (!getenv("fdt_file")) {
+		if (!env_get("fdt_file")) {
 			sprintf(fdt, "%s-%s.dtb", cputype, str);
 			env_set("fdt_file", fdt);
 		}
@@ -770,11 +770,11 @@ int misc_init_r(void)
 
 		/* initialize env from EEPROM */
 		if (test_bit(EECONFIG_ETH0, info->config) &&
-		    !getenv("ethaddr")) {
+		    !env_get("ethaddr")) {
 			eth_env_set_enetaddr("ethaddr", info->mac0);
 		}
 		if (test_bit(EECONFIG_ETH1, info->config) &&
-		    !getenv("eth1addr")) {
+		    !env_get("eth1addr")) {
 			eth_env_set_enetaddr("eth1addr", info->mac1);
 		}
 
@@ -788,7 +788,7 @@ int misc_init_r(void)
 	}
 
 	/* Set a non-initialized hwconfig based on board configuration */
-	if (!strcmp(getenv("hwconfig"), "_UNKNOWN_")) {
+	if (!strcmp(env_get("hwconfig"), "_UNKNOWN_")) {
 		buf[0] = 0;
 		if (gpio_cfg[board_type].rs232_en)
 			strcat(buf, "rs232;");
@@ -1035,7 +1035,7 @@ int fdt_fixup_sky2(void *blob, int np, struct pci_dev *dev)
 	int j;
 
 	sprintf(mac, "eth1addr");
-	tmp = getenv(mac);
+	tmp = env_get(mac);
 	if (tmp) {
 		for (j = 0; j < 6; j++) {
 			mac_addr[j] = tmp ?
@@ -1118,8 +1118,8 @@ int ft_board_setup(void *blob, bd_t *bd)
 		{ "sst,w25q256",          MTD_DEV_TYPE_NOR, },  /* SPI flash */
 		{ "fsl,imx6q-gpmi-nand",  MTD_DEV_TYPE_NAND, }, /* NAND flash */
 	};
-	const char *model = getenv("model");
-	const char *display = getenv("display");
+	const char *model = env_get("model");
+	const char *display = env_get("display");
 	int i;
 	char rev = 0;
 
@@ -1131,7 +1131,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 		}
 	}
 
-	if (getenv("fdt_noauto")) {
+	if (env_get("fdt_noauto")) {
 		puts("   Skiping ft_board_setup (fdt_noauto defined)\n");
 		return 0;
 	}
@@ -1152,15 +1152,15 @@ int ft_board_setup(void *blob, bd_t *bd)
 	printf("   Adjusting FDT per EEPROM for %s...\n", model);
 
 	/* board serial number */
-	fdt_setprop(blob, 0, "system-serial", getenv("serial#"),
-		    strlen(getenv("serial#")) + 1);
+	fdt_setprop(blob, 0, "system-serial", env_get("serial#"),
+		    strlen(env_get("serial#")) + 1);
 
 	/* board (model contains model from device-tree) */
 	fdt_setprop(blob, 0, "board", info->model,
 		    strlen((const char *)info->model) + 1);
 
 	/* set desired digital video capture format */
-	ft_sethdmiinfmt(blob, getenv("hdmiinfmt"));
+	ft_sethdmiinfmt(blob, env_get("hdmiinfmt"));
 
 	/*
 	 * Board model specific fixups
@@ -1315,7 +1315,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 	}
 
 #if defined(CONFIG_CMD_PCI)
-	if (!getenv("nopcifixup"))
+	if (!env_get("nopcifixup"))
 		ft_board_pci_fixup(blob, bd);
 #endif
 
@@ -1324,7 +1324,7 @@ int ft_board_setup(void *blob, bd_t *bd)
 	 *  remove nodes by alias path if EEPROM config tells us the
 	 *  peripheral is not loaded on the board.
 	 */
-	if (getenv("fdt_noconfig")) {
+	if (env_get("fdt_noconfig")) {
 		puts("   Skiping periperhal config (fdt_noconfig defined)\n");
 		return 0;
 	}
board/gateworks/gw_ventana/gw_ventana_spl.c +1 -1
index baa8480b6c..feea228b3d 100644
@@ -691,7 +691,7 @@ int spl_start_uboot(void)
 #ifdef CONFIG_SPL_ENV_SUPPORT
 	env_init();
 	env_load();
-	debug("boot_os=%s\n", getenv("boot_os"));
+	debug("boot_os=%s\n", env_get("boot_os"));
 	if (getenv_yesno("boot_os") == 1)
 		ret = 0;
 #else
board/gdsys/a38x/keyprogram.c +2 -2
index a4a6f1cca5..d75e08b39f 100644
@@ -129,12 +129,12 @@ int load_and_run_keyprog(void)
 	char *hexprog;
 	struct key_program *prog;
 
-	cmd = getenv("loadkeyprogram");
+	cmd = env_get("loadkeyprogram");
 
 	if (!cmd || run_command(cmd, 0))
 		return 1;
 
-	hexprog = getenv("keyprogram");
+	hexprog = env_get("keyprogram");
 
 	if (decode_hexstr(hexprog, &binprog))
 		return 1;
board/gdsys/mpc8308/hrcon.c +1 -1
index c6566e9196..7e485074ce 100644
@@ -103,7 +103,7 @@ int fpga_get_reg(u32 fpga, u16 *reg, off_t regoff, u16 *data)
 
 int checkboard(void)
 {
-	char *s = getenv("serial#");
+	char *s = env_get("serial#");
 	bool hw_type_cat = pca9698_get_value(0x20, 20);
 
 	puts("Board: ");
board/gdsys/mpc8308/strider.c +1 -1
index 34e9d1956e..fec691515d 100644
@@ -106,7 +106,7 @@ int fpga_get_reg(u32 fpga, u16 *reg, off_t regoff, u16 *data)
 
 int checkboard(void)
 {
-	char *s = getenv("serial#");
+	char *s = env_get("serial#");
 	bool hw_type_cat = pca9698_get_value(0x20, 18);
 
 	puts("Board: ");
board/gdsys/p1022/controlcenterd-id.c +3 -3
index 95f11fb69f..61c030a458 100644
@@ -1043,13 +1043,13 @@ static int second_stage_init(void)
 		goto failure;
 
 	/* run "prepboot" from env to get "mmcdev" set */
-	cptr = getenv("prepboot");
+	cptr = env_get("prepboot");
 	if (cptr && !run_command(cptr, 0))
-		mmcdev = getenv("mmcdev");
+		mmcdev = env_get("mmcdev");
 	if (!mmcdev)
 		goto failure;
 
-	cptr = getenv("ramdiskimage");
+	cptr = env_get("ramdiskimage");
 	if (cptr)
 		image_path = cptr;
 
board/gdsys/p1022/controlcenterd.c +1 -1
index 01064dcfde..24e58cbf00 100644
@@ -223,7 +223,7 @@ void hw_watchdog_reset(void)
 #ifdef CONFIG_TRAILBLAZER
 int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	return run_command(getenv("bootcmd"), flag);
+	return run_command(env_get("bootcmd"), flag);
 }
 
 int board_early_init_r(void)
board/grinn/chiliboard/board.c +2 -2
index 2900109bbd..2f5974a246 100644
@@ -126,7 +126,7 @@ int board_late_init(void)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
@@ -142,7 +142,7 @@ int board_late_init(void)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
board/grinn/liteboard/board.c +1 -1
index 24956927ac..941e7ea2c8 100644
@@ -149,7 +149,7 @@ int board_mmc_init(bd_t *bis)
 
 static int check_mmc_autodetect(void)
 {
-	char *autodetect_str = getenv("mmcautodetect");
+	char *autodetect_str = env_get("mmcautodetect");
 
 	if ((autodetect_str != NULL) &&
 	    (strcmp(autodetect_str, "yes") == 0)) {
board/highbank/highbank.c +1 -1
index e51043aa91..f7c05ab08f 100644
@@ -80,7 +80,7 @@ int misc_init_r(void)
 
 	boot_choice = readl(HB_SREG_A9_BOOT_SRC_STAT) & 0xff;
 	sprintf(envbuffer, "bootcmd%d", boot_choice);
-	if (getenv(envbuffer)) {
+	if (env_get(envbuffer)) {
 		sprintf(envbuffer, "run bootcmd%d", boot_choice);
 		env_set("bootcmd", envbuffer);
 	} else
board/intel/edison/edison.c +2 -2
index aaafae86a8..4b1e6d0f47 100644
@@ -95,10 +95,10 @@ static void assign_hardware_id(void)
 
 int board_late_init(void)
 {
-	if (!getenv("serial#"))
+	if (!env_get("serial#"))
 		assign_serial();
 
-	if (!getenv("hardware_id"))
+	if (!env_get("hardware_id"))
 		assign_hardware_id();
 
 	return 0;
board/keymile/common/common.c +5 -5
index 56d3044241..6cd281218e 100644
@@ -54,7 +54,7 @@ int set_km_env(void)
 	env_set("pnvramaddr", (char *)buf);
 
 	/* try to read rootfssize (ram image) from environment */
-	p = getenv("rootfssize");
+	p = env_get("rootfssize");
 	if (p != NULL)
 		strict_strtoul(p, 16, &rootfssize);
 	pram = (rootfssize + CONFIG_KM_RESERVED_PRAM + CONFIG_KM_PHRAM +
@@ -236,10 +236,10 @@ static int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc,
 	}
 
 	/* now try to read values from environment if available */
-	p = getenv("boardid");
+	p = env_get("boardid");
 	if (p != NULL)
 		rc = strict_strtoul(p, 16, &envbid);
-	p = getenv("hwkey");
+	p = env_get("hwkey");
 	if (p != NULL)
 		rc = strict_strtoul(p, 16, &envhwkey);
 
@@ -253,7 +253,7 @@ static int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc,
 		 * BoardId/HWkey not available in the environment, so try the
 		 * environment variable for BoardId/HWkey list
 		 */
-		char *bidhwklist = getenv("boardIdListHex");
+		char *bidhwklist = env_get("boardIdListHex");
 
 		if (bidhwklist) {
 			int found = 0;
@@ -355,7 +355,7 @@ static int do_checktestboot(cmd_tbl_t *cmdtp, int flag, int argc,
 #if defined(CONFIG_POST)
 	testpin = post_hotkeys_pressed();
 #endif
-	s = getenv("test_bank");
+	s = env_get("test_bank");
 	/* when test_bank is not set, act as if testpin is not asserted */
 	testboot = (testpin != 0) && (s);
 	if (verbose) {
board/keymile/common/ivm.c +1 -1
index dc40a83fc0..f1321d9899 100644
@@ -261,7 +261,7 @@ int ivm_analyze_eeprom(unsigned char *buf, int len)
 
 	GET_STRING("IVM_Symbol", IVM_POS_SYMBOL_ONLY, 8)
 	GET_STRING("IVM_DeviceName", IVM_POS_SHORT_TEXT, 64)
-	tmp = (unsigned char *) getenv("IVM_DeviceName");
+	tmp = (unsigned char *)env_get("IVM_DeviceName");
 	if (tmp) {
 		int	len = strlen((char *)tmp);
 		int	i = 0;
board/keymile/km_arm/km_arm.c +1 -1
index 08ae9ae346..af1ebc4101 100644
@@ -201,7 +201,7 @@ int misc_init_r(void)
 #if defined(CONFIG_KM_MGCOGE3UN)
 	char *wait_for_ne;
 	u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
-	wait_for_ne = getenv("waitforne");
+	wait_for_ne = env_get("waitforne");
 
 	if ((wait_for_ne != NULL) && (dip_switch == 0)) {
 		if (strcmp(wait_for_ne, "true") == 0) {
board/keymile/kmp204x/kmp204x.c +1 -1
index 095e467ac0..671bddfa1c 100644
@@ -239,7 +239,7 @@ void fdt_fixup_fman_mac_addresses(void *blob)
 	unsigned char mac_addr[6];
 
 	/* get the mac addr from env */
-	tmp = getenv("ethaddr");
+	tmp = env_get("ethaddr");
 	if (!tmp) {
 		printf("ethaddr env variable not defined\n");
 		return;
board/kosagi/novena/novena.c +1 -1
index baca7223fa..f0ace03009 100644
@@ -240,7 +240,7 @@ int misc_init_r(void)
 	int ret;
 
 	/* If 'ethaddr' is already set, do nothing. */
-	if (getenv("ethaddr"))
+	if (env_get("ethaddr"))
 		return 0;
 
 	/* EEPROM is at bus 2. */
board/lg/sniper/sniper.c +1 -1
index 4906e4f9d2..a299f761f9 100644
@@ -133,7 +133,7 @@ int misc_init_r(void)
 	}
 
 	if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
-		if (!getenv("reboot-mode"))
+		if (!env_get("reboot-mode"))
 			env_set("reboot-mode", (char *)reboot_mode);
 	}
 
board/liebherr/mccmon6/mccmon6.c +2 -2
index 8d0a66621d..4f7e018dea 100644
@@ -467,7 +467,7 @@ int spl_start_uboot(void)
 		return 1;
 
 	env_init();
-	ret = getenv_f("boot_os", s, sizeof(s));
+	ret = env_get_f("boot_os", s, sizeof(s));
 	if ((ret != -1) && (strcmp(s, "no") == 0))
 		return 1;
 
@@ -481,7 +481,7 @@ int spl_start_uboot(void)
 	 * recovery_status = <any value> -> start SWUpdate
 	 *
 	 */
-	ret = getenv_f("recovery_status", s, sizeof(s));
+	ret = env_get_f("recovery_status", s, sizeof(s));
 	if (ret != -1)
 		return 1;
 
board/logicpd/omap3som/omap3logic.c +1 -1
index 8885d1e6a9..faf04df99f 100644
@@ -219,7 +219,7 @@ int board_late_init(void)
 			gd->bd->bi_arch_number = board->machine_id;
 
 		/* If the user has not set fdtimage, set the default */
-		if (!getenv("fdtimage"))
+		if (!env_get("fdtimage"))
 			env_set("fdtimage", board->fdtfile);
 	}
 
board/micronas/vct/vct.c +1 -1
index 8bf8d5f4e8..510746d35c 100644
@@ -72,7 +72,7 @@ int dram_init(void)
 int checkboard(void)
 {
 	char buf[64];
-	int i = getenv_f("serial#", buf, sizeof(buf));
+	int i = env_get_f("serial#", buf, sizeof(buf));
 	u32 config0 = read_c0_prid();
 
 	if ((config0 & 0xff0000) == PRID_COMP_LEGACY
board/nokia/rx51/rx51.c +4 -4
index 889e748f98..7764288811 100644
@@ -234,18 +234,18 @@ void setup_board_tags(struct tag **in_params)
 	params->u.core.rootdev = 0x0;
 
 	/* append omap atag only if env setup_omap_atag is set to 1 */
-	str = getenv("setup_omap_atag");
+	str = env_get("setup_omap_atag");
 	if (!str || str[0] != '1')
 		return;
 
-	str = getenv("setup_console_atag");
+	str = env_get("setup_console_atag");
 	if (str && str[0] == '1')
 		setup_console_atag = 1;
 	else
 		setup_console_atag = 0;
 
-	setup_boot_reason_atag = getenv("setup_boot_reason_atag");
-	setup_boot_mode_atag = getenv("setup_boot_mode_atag");
+	setup_boot_reason_atag = env_get("setup_boot_reason_atag");
+	setup_boot_mode_atag = env_get("setup_boot_mode_atag");
 
 	params = *in_params;
 	t = (struct tag_omap *)&params->u;
board/raspberrypi/rpi/rpi.c +6 -6
index 7ff7b269f9..530f149617 100644
@@ -247,7 +247,7 @@ static void set_fdtfile(void)
 {
 	const char *fdtfile;
 
-	if (getenv("fdtfile"))
+	if (env_get("fdtfile"))
 		return;
 
 	fdtfile = model->fdtfile;
@@ -260,7 +260,7 @@ static void set_fdtfile(void)
  */
 static void set_fdt_addr(void)
 {
-	if (getenv("fdt_addr"))
+	if (env_get("fdt_addr"))
 		return;
 
 	if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
@@ -287,7 +287,7 @@ static void set_usbethaddr(void)
 	if (!model->has_onboard_eth)
 		return;
 
-	if (getenv("usbethaddr"))
+	if (env_get("usbethaddr"))
 		return;
 
 	BCM2835_MBOX_INIT_HDR(msg);
@@ -302,8 +302,8 @@ static void set_usbethaddr(void)
 
 	eth_env_set_enetaddr("usbethaddr", msg->get_mac_address.body.resp.mac);
 
-	if (!getenv("ethaddr"))
-		env_set("ethaddr", getenv("usbethaddr"));
+	if (!env_get("ethaddr"))
+		env_set("ethaddr", env_get("usbethaddr"));
 
 	return;
 }
@@ -330,7 +330,7 @@ static void set_serial_number(void)
 	int ret;
 	char serial_string[17] = { 0 };
 
-	if (getenv("serial#"))
+	if (env_get("serial#"))
 		return;
 
 	BCM2835_MBOX_INIT_HDR(msg);
board/samsung/common/exynos5-dt.c +1 -1
index 44f412db5d..ae2a6e6bfa 100644
@@ -179,7 +179,7 @@ char *get_dfu_alt_system(char *interface, char *devstr)
 	if (board_is_odroidxu4())
 		return info;
 
-	return getenv("dfu_alt_system");
+	return env_get("dfu_alt_system");
 }
 
 char *get_dfu_alt_boot(char *interface, char *devstr)
board/samsung/odroid/odroid.c +1 -1
index b4cb33240e..e40a2f6e3a 100644
@@ -66,7 +66,7 @@ const char *get_board_type(void)
 #ifdef CONFIG_SET_DFU_ALT_INFO
 char *get_dfu_alt_system(char *interface, char *devstr)
 {
-	return getenv("dfu_alt_system");
+	return env_get("dfu_alt_system");
 }
 
 char *get_dfu_alt_boot(char *interface, char *devstr)
board/samtec/vining_2000/vining_2000.c +1 -1
index 125f6e7070..af1a3e75cb 100644
@@ -131,7 +131,7 @@ int board_eth_init(bd_t *bis)
 
 	/* just to get secound mac address */
 	imx_get_mac_from_fuse(1, eth1addr);
-	if (!getenv("eth1addr") && is_valid_ethaddr(eth1addr))
+	if (!env_get("eth1addr") && is_valid_ethaddr(eth1addr))
 		eth_env_set_enetaddr("eth1addr", eth1addr);
 
 	imx_iomux_v3_setup_multiple_pads(fec1_pads, ARRAY_SIZE(fec1_pads));
board/samtec/vining_fpga/socfpga.c +3 -3
index 760fc71217..229b12f308 100644
@@ -76,7 +76,7 @@ int misc_init_r(void)
 	}
 
 	/* If 'unit_serial' is already set, do nothing. */
-	if (!getenv("unit_serial")) {
+	if (!env_get("unit_serial")) {
 		/* This field is Big Endian ! */
 		serial = (data[0x54] << 24) | (data[0x55] << 16) |
 			 (data[0x56] << 8) | (data[0x57] << 0);
@@ -85,14 +85,14 @@ int misc_init_r(void)
 		env_set("unit_serial", str);
 	}
 
-	if (!getenv("unit_ident")) {
+	if (!env_get("unit_ident")) {
 		memset(str, 0, sizeof(str));
 		memcpy(str, &data[0x2e], 18);
 		env_set("unit_ident", str);
 	}
 
 	/* Set ethernet address from EEPROM. */
-	if (!getenv("ethaddr") && is_valid_ethaddr(&data[0x62]))
+	if (!env_get("ethaddr") && is_valid_ethaddr(&data[0x62]))
 		eth_env_set_enetaddr("ethaddr", &data[0x62]);
 
 	return 0;
board/siemens/common/board.c +2 -2
index b967227411..65fa6af2d4 100644
@@ -121,7 +121,7 @@ unsigned char get_button_state(char * const envname, unsigned char def)
 	char *ptr_env;
 
 	/* If button is not found we take default */
-	ptr_env = getenv(envname);
+	ptr_env = env_get(envname);
 	if (NULL == ptr_env) {
 		gpio = def;
 	} else {
@@ -199,7 +199,7 @@ void set_env_gpios(unsigned char state)
 		strcat(str_tmp, num);
 
 		/* If env var is not found we stop */
-		ptr_env = getenv(str_tmp);
+		ptr_env = env_get(str_tmp);
 		if (NULL == ptr_env)
 			break;
 
board/siemens/taurus/taurus.c +9 -9
index d877a9c771..8390bdd5f8 100644
@@ -377,7 +377,7 @@ static int upgrade_failure_fallback(void)
 	char *kern_size;
 	char *kern_size_fb;
 
-	partitionset_active = getenv("partitionset_active");
+	partitionset_active = env_get("partitionset_active");
 	if (partitionset_active) {
 		if (partitionset_active[0] == 'A')
 			env_set("partitionset_active", "B");
@@ -388,18 +388,18 @@ static int upgrade_failure_fallback(void)
 		return -ENOENT;
 	}
 
-	rootfs = getenv("rootfs");
-	rootfs_fallback = getenv("rootfs_fallback");
+	rootfs = env_get("rootfs");
+	rootfs_fallback = env_get("rootfs_fallback");
 	env_set("rootfs", rootfs_fallback);
 	env_set("rootfs_fallback", rootfs);
 
-	kern_size = getenv("kernel_size");
-	kern_size_fb = getenv("kernel_size_fallback");
+	kern_size = env_get("kernel_size");
+	kern_size_fb = env_get("kernel_size_fallback");
 	env_set("kernel_size", kern_size_fb);
 	env_set("kernel_size_fallback", kern_size);
 
-	kern_off = getenv("kernel_Off");
-	kern_off_fb = getenv("kernel_Off_fallback");
+	kern_off = env_get("kernel_Off");
+	kern_off_fb = env_get("kernel_Off_fallback");
 	env_set("kernel_Off", kern_off_fb);
 	env_set("kernel_Off_fallback", kern_off);
 
@@ -418,10 +418,10 @@ static int do_upgrade_available(cmd_tbl_t *cmdtp, int flag, int argc,
 	unsigned long boot_retry = 0;
 	char boot_buf[10];
 
-	upgrade_available = simple_strtoul(getenv("upgrade_available"), NULL,
+	upgrade_available = simple_strtoul(env_get("upgrade_available"), NULL,
 					   10);
 	if (upgrade_available) {
-		boot_retry = simple_strtoul(getenv("boot_retries"), NULL, 10);
+		boot_retry = simple_strtoul(env_get("boot_retries"), NULL, 10);
 		boot_retry++;
 		sprintf(boot_buf, "%lx", boot_retry);
 		env_set("boot_retries", boot_buf);
board/socrates/socrates.c +2 -2
index fb691c22d9..004f37009a 100644
@@ -38,7 +38,7 @@ int checkboard (void)
 	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
 	char buf[64];
 	int f;
-	int i = getenv_f("serial#", buf, sizeof(buf));
+	int i = env_get_f("serial#", buf, sizeof(buf));
 #ifdef CONFIG_PCI
 	char *src;
 #endif
@@ -409,7 +409,7 @@ void board_backlight_switch (int flag)
 		printf ("hwmon IC init failed\n");
 
 	if (flag) {
-		param = getenv("brightness");
+		param = env_get("brightness");
 		rc = param ? simple_strtol(param, NULL, 10) : -1;
 		if (rc < 0)
 			rc = DEFAULT_BRIGHTNESS;
board/st/stm32f429-discovery/stm32f429-discovery.c +1 -1
index 673e7728f1..d6763c306f 100644
@@ -314,7 +314,7 @@ int misc_init_r(void)
 	char serialno[25];
 	uint32_t u_id_low, u_id_mid, u_id_high;
 
-	if (!getenv("serial#")) {
+	if (!env_get("serial#")) {
 		u_id_low  = readl(&STM32_U_ID->u_id_low);
 		u_id_mid  = readl(&STM32_U_ID->u_id_mid);
 		u_id_high = readl(&STM32_U_ID->u_id_high);
board/sunxi/board.c +3 -3
index 26732dc40f..70e01437c4 100644
@@ -602,7 +602,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
 	char *serial_string;
 	unsigned long long serial;
 
-	serial_string = getenv("serial#");
+	serial_string = env_get("serial#");
 
 	if (serial_string) {
 		serial = simple_strtoull(serial_string, NULL, 16);
@@ -694,7 +694,7 @@ static void setup_environment(const void *fdt)
 			else
 				sprintf(ethaddr, "eth%daddr", i);
 
-			if (getenv(ethaddr))
+			if (env_get(ethaddr))
 				continue;
 
 			/* Non OUI / registered MAC address */
@@ -708,7 +708,7 @@ static void setup_environment(const void *fdt)
 			eth_env_set_enetaddr(ethaddr, mac_addr);
 		}
 
-		if (!getenv("serial#")) {
+		if (!env_get("serial#")) {
 			snprintf(serial_string, sizeof(serial_string),
 				"%08x%08x", sid[0], sid[3]);
 
board/syteco/zmx25/zmx25.c +1 -1
index e02dcf2995..85fda13188 100644
@@ -146,7 +146,7 @@ int board_late_init(void)
 	udelay(5000);
 #endif
 
-	e = getenv("gs_base_board");
+	e = env_get("gs_base_board");
 	if (e != NULL) {
 		if (strcmp(e, "G283") == 0) {
 			int key = gpio_get_value(IMX_GPIO_NR(2, 29));
board/tcl/sl50/board.c +2 -2
index cc65c7b84b..08af279751 100644
@@ -322,7 +322,7 @@ int board_eth_init(bd_t *bis)
 
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
@@ -340,7 +340,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
board/technexion/twister/twister.c +1 -1
index 25aeebc8d0..8c38f14cde 100644
@@ -94,7 +94,7 @@ int misc_init_r(void)
 
 	omap_die_id_display();
 
-	eth_addr = getenv("ethaddr");
+	eth_addr = env_get("ethaddr");
 	if (eth_addr)
 		return 0;
 
board/teejet/mt_ventoux/mt_ventoux.c +2 -2
index 6e73ae114a..9eaae50f27 100644
@@ -261,7 +261,7 @@ int misc_init_r(void)
 
 	if (ret)
 		return 0;
-	eth_addr = getenv("ethaddr");
+	eth_addr = env_get("ethaddr");
 	if (!eth_addr)
 		TAM3517_READ_MAC_FROM_EEPROM(&info);
 
@@ -311,7 +311,7 @@ int board_video_init(void)
 
 	fb = (void *)0x88000000;
 
-	s = getenv("panel");
+	s = env_get("panel");
 	if (s) {
 		index = simple_strtoul(s, NULL, 10);
 		if (index < ARRAY_SIZE(lcd_cfg))
board/theobroma-systems/puma_rk3399/puma-rk3399.c +3 -3
index 733fe96726..c6f8eed0c9 100644
@@ -63,13 +63,13 @@ static void setup_macaddr(void)
 {
 #if CONFIG_IS_ENABLED(CMD_NET)
 	int ret;
-	const char *cpuid = getenv("cpuid#");
+	const char *cpuid = env_get("cpuid#");
 	u8 hash[SHA256_SUM_LEN];
 	int size = sizeof(hash);
 	u8 mac_addr[6];
 
 	/* Only generate a MAC address, if none is set in the environment */
-	if (getenv("ethaddr"))
+	if (env_get("ethaddr"))
 		return;
 
 	if (!cpuid) {
@@ -165,7 +165,7 @@ void get_board_serial(struct tag_serialnr *serialnr)
 	char *serial_string;
 	u64 serial = 0;
 
-	serial_string = getenv("serial#");
+	serial_string = env_get("serial#");
 
 	if (serial_string)
 		serial = simple_strtoull(serial_string, NULL, 16);
board/ti/am335x/board.c +2 -2
index 7bdbc89d5e..ab835856e5 100644
@@ -745,7 +745,7 @@ int board_late_init(void)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
@@ -761,7 +761,7 @@ int board_late_init(void)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
board/ti/am43xx/board.c +2 -2
index 933ff31a8e..2c417e7545 100644
@@ -791,7 +791,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		puts("<ethaddr> not set. Validating first E-fuse MAC\n");
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("ethaddr", mac_addr);
@@ -806,7 +806,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = mac_lo & 0xFF;
 	mac_addr[5] = (mac_lo & 0xFF00) >> 8;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
board/ti/am57xx/board.c +2 -2
index aaa1464273..7bcbc31042 100644
@@ -933,7 +933,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
@@ -949,7 +949,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
board/ti/dra7xx/evm.c +2 -2
index 4252074e74..bdbf7f6796 100644
@@ -893,7 +893,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
@@ -909,7 +909,7 @@ int board_eth_init(bd_t *bis)
 	mac_addr[4] = (mac_lo & 0xFF00) >> 8;
 	mac_addr[5] = mac_lo & 0xFF;
 
-	if (!getenv("eth1addr")) {
+	if (!env_get("eth1addr")) {
 		if (is_valid_ethaddr(mac_addr))
 			eth_env_set_enetaddr("eth1addr", mac_addr);
 	}
board/ti/ks2_evm/board.c +6 -6
index c61baeeb8c..ae86dfbe0a 100644
@@ -74,7 +74,7 @@ int get_eth_env_param(char *env_name)
 	char *env;
 	int res = -1;
 
-	env = getenv(env_name);
+	env = env_get(env_name);
 	if (env)
 		res = simple_strtol(env, NULL, 0);
 
@@ -151,9 +151,9 @@ int ft_board_setup(void *blob, bd_t *bd)
 	u32 ddr3a_size;
 	int unitrd_fixup = 0;
 
-	env = getenv("mem_lpae");
+	env = env_get("mem_lpae");
 	lpae = env && simple_strtol(env, NULL, 0);
-	env = getenv("uinitrd_fixup");
+	env = env_get("uinitrd_fixup");
 	unitrd_fixup = env && simple_strtol(env, NULL, 0);
 
 	ddr3a_size = 0;
@@ -180,13 +180,13 @@ int ft_board_setup(void *blob, bd_t *bd)
 	}
 
 	/* reserve memory at start of bank */
-	env = getenv("mem_reserve_head");
+	env = env_get("mem_reserve_head");
 	if (env) {
 		start[0] += ustrtoul(env, &endp, 0);
 		size[0] -= ustrtoul(env, &endp, 0);
 	}
 
-	env = getenv("mem_reserve");
+	env = env_get("mem_reserve");
 	if (env)
 		size[0] -= ustrtoul(env, &endp, 0);
 
@@ -251,7 +251,7 @@ void ft_board_setup_ex(void *blob, bd_t *bd)
 	char *env;
 	u64 *reserve_start;
 
-	env = getenv("mem_lpae");
+	env = env_get("mem_lpae");
 	lpae = env && simple_strtol(env, NULL, 0);
 
 	if (lpae) {
board/toradex/apalis_imx6/apalis_imx6.c +1 -1
index 86a7a159e8..7a3e493faf 100644
@@ -814,7 +814,7 @@ int board_late_init(void)
 		setup_iomux_dce_uart();
 
 		/* if using the default device tree, use version for V1.0 HW */
-		fdt_env = getenv("fdt_file");
+		fdt_env = env_get("fdt_file");
 		if ((fdt_env != NULL) && (strcmp(FDT_FILE, fdt_env) == 0)) {
 			env_set("fdt_file", FDT_FILE_V1_0);
 			printf("patching fdt_file to " FDT_FILE_V1_0 "\n");
board/toradex/common/tdx-cfg-block.c +1 -1
index 1bf8ca8f76..328c4c0200 100644
@@ -278,7 +278,7 @@ static int get_cfgblock_interactive(void)
 	len = cli_readline(message);
 	it = console_buffer[0];
 
-	soc = getenv("soc");
+	soc = env_get("soc");
 	if (!strcmp("mx6", soc)) {
 #ifdef CONFIG_MACH_TYPE
 		if (it == 'y' || it == 'Y')
board/varisys/common/sys_eeprom.c +1 -1
index d235897311..69f596a4cc 100644
@@ -486,7 +486,7 @@ int mac_read_from_eeprom_common(void)
 			/* Only initialize environment variables that are blank
 			 * (i.e. have not yet been set)
 			 */
-			if (!getenv(enetvar))
+			if (!env_get(enetvar))
 				env_set(enetvar, ethaddr);
 		}
 	}
board/vscom/baltos/board.c +1 -1
index 2e3baeb118..cb39190c28 100644
@@ -453,7 +453,7 @@ int board_eth_init(bd_t *bis)
 
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
-	if (!getenv("ethaddr")) {
+	if (!env_get("ethaddr")) {
 		printf("<ethaddr> not set. Validating first E-fuse MAC\n");
 
 		if (is_valid_ethaddr(mac_addr))
board/work-microwave/work_92105/work_92105_display.c +1 -1
index 37a736351c..c997cea6f0 100644
@@ -228,7 +228,7 @@ void work_92105_display_init(void)
 	i2c_write(0x2c, 0x01, 1, &enable_backlight, 1);
 
 	/* set display contrast */
-	display_contrast_str = getenv("fwopt_dispcontrast");
+	display_contrast_str = env_get("fwopt_dispcontrast");
 	if (display_contrast_str)
 		display_contrast = simple_strtoul(display_contrast_str,
 			NULL, 10);
board/xes/common/board.c +3 -3
index 4ed6f50e5c..b76eb948d5 100644
@@ -51,13 +51,13 @@ int checkboard(void)
 
 	/* Display board specific information */
 	puts("       ");
-	i = getenv_f("board_rev", buf, sizeof(buf));
+	i = env_get_f("board_rev", buf, sizeof(buf));
 	if (i > 0)
 		printf("Rev %s, ", buf);
-	i = getenv_f("serial#", buf, sizeof(buf));
+	i = env_get_f("serial#", buf, sizeof(buf));
 	if (i > 0)
 		printf("Serial# %s, ", buf);
-	i = getenv_f("board_cfg", buf, sizeof(buf));
+	i = env_get_f("board_cfg", buf, sizeof(buf));
 	if (i > 0)
 		printf("Cfg %s", buf);
 	puts("\n");
board/xilinx/zynqmp/zynqmp.c +2 -2
index 89ab24417d..ddbb5ce8fd 100644
@@ -282,9 +282,9 @@ int board_late_init(void)
 	 * and default boot_targets
 	 */
 	new_targets = calloc(1, strlen(mode) +
-				strlen(getenv("boot_targets")) + 2);
+				strlen(env_get("boot_targets")) + 2);
 
-	sprintf(new_targets, "%s %s", mode, getenv("boot_targets"));
+	sprintf(new_targets, "%s %s", mode, env_get("boot_targets"));
 	env_set("boot_targets", new_targets);
 
 	return 0;
cmd/bdinfo.c +3 -3
index 81ac78da94..3323d93393 100644
@@ -28,7 +28,7 @@ static void print_eth(int idx)
 		sprintf(name, "eth%iaddr", idx);
 	else
 		strcpy(name, "ethaddr");
-	val = getenv(name);
+	val = env_get(name);
 	if (!val)
 		val = "(not set)";
 	printf("%-12s= %s\n", name, val);
@@ -51,7 +51,7 @@ static void print_eths(void)
 	} while (dev);
 
 	printf("current eth = %s\n", eth_get_name());
-	printf("ip_addr     = %s\n", getenv("ipaddr"));
+	printf("ip_addr     = %s\n", env_get("ipaddr"));
 }
 #endif
 
@@ -141,7 +141,7 @@ static inline void print_eth_ip_addr(void)
 #if defined(CONFIG_HAS_ETH5)
 	print_eth(5);
 #endif
-	printf("IP addr     = %s\n", getenv("ipaddr"));
+	printf("IP addr     = %s\n", env_get("ipaddr"));
 #endif
 }
 
cmd/bootm.c +2 -2
index daf15d9e80..df0bbe19ca 100644
@@ -138,7 +138,7 @@ int do_bootm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 int bootm_maybe_autostart(cmd_tbl_t *cmdtp, const char *cmd)
 {
-	const char *ep = getenv("autostart");
+	const char *ep = env_get("autostart");
 
 	if (ep && !strcmp(ep, "yes")) {
 		char *local_args[2];
@@ -202,7 +202,7 @@ U_BOOT_CMD(
 #if defined(CONFIG_CMD_BOOTD)
 int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	return run_command(getenv("bootcmd"), flag);
+	return run_command(env_get("bootcmd"), flag);
 }
 
 U_BOOT_CMD(
cmd/bootmenu.c +2 -2
index 5879065c2e..870db7c1de 100644
@@ -53,7 +53,7 @@ static char *bootmenu_getoption(unsigned short int n)
 		return NULL;
 
 	sprintf(name, "bootmenu_%d", n);
-	return getenv(name);
+	return env_get(name);
 }
 
 static void bootmenu_print_entry(void *data)
@@ -483,7 +483,7 @@ int do_bootmenu(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		delay_str = argv[1];
 
 	if (!delay_str)
-		delay_str = getenv("bootmenu_delay");
+		delay_str = env_get("bootmenu_delay");
 
 	if (delay_str)
 		delay = (int)simple_strtol(delay_str, NULL, 10);
cmd/cramfs.c +4 -4
index 7b23c5b3dd..86f1bac272 100644
@@ -104,7 +104,7 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	struct mtdids id;
 
 	ulong addr;
-	addr = simple_strtoul(getenv("cramfsaddr"), NULL, 16);
+	addr = simple_strtoul(env_get("cramfsaddr"), NULL, 16);
 
 	/* hack! */
 	/* cramfs_* only supports NOR flash chips */
@@ -117,9 +117,9 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	part.offset = (u64)(uintptr_t) map_sysmem(addr - OFFSET_ADJUSTMENT, 0);
 
 	/* pre-set Boot file name */
-	if ((filename = getenv("bootfile")) == NULL) {
+	filename = env_get("bootfile");
+	if (!filename)
 		filename = "uImage";
-	}
 
 	if (argc == 2) {
 		filename = argv[1];
@@ -169,7 +169,7 @@ int do_cramfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	struct mtdids id;
 
 	ulong addr;
-	addr = simple_strtoul(getenv("cramfsaddr"), NULL, 16);
+	addr = simple_strtoul(env_get("cramfsaddr"), NULL, 16);
 
 	/* hack! */
 	/* cramfs_* only supports NOR flash chips */
cmd/elf.c +13 -13
index ed9625b221..5d071ee26c 100644
@@ -148,7 +148,7 @@ int do_bootelf(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	unsigned long addr; /* Address of the ELF image */
 	unsigned long rc; /* Return value from user code */
 	char *sload = NULL;
-	const char *ep = getenv("autostart");
+	const char *ep = env_get("autostart");
 	int rcode = 0;
 
 	/* Consume 'bootelf' */
@@ -258,7 +258,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	 * (LOCAL_MEM_LOCAL_ADRS + BOOT_LINE_OFFSET) as defined by
 	 * VxWorks BSP. For example, on PowerPC it defaults to 0x4200.
 	 */
-	tmp = getenv("bootaddr");
+	tmp = env_get("bootaddr");
 	if (!tmp) {
 		printf("## VxWorks bootline address not specified\n");
 	} else {
@@ -269,21 +269,21 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		 * parameter. If it is not defined, we may be able to
 		 * construct the info.
 		 */
-		bootline = getenv("bootargs");
+		bootline = env_get("bootargs");
 		if (bootline) {
 			memcpy((void *)bootaddr, bootline,
 			       max(strlen(bootline), (size_t)255));
 			flush_cache(bootaddr, max(strlen(bootline),
 						  (size_t)255));
 		} else {
-			tmp = getenv("bootdev");
+			tmp = env_get("bootdev");
 			if (tmp) {
 				strcpy(build_buf, tmp);
 				ptr = strlen(tmp);
 			} else
 				printf("## VxWorks boot device not specified\n");
 
-			tmp = getenv("bootfile");
+			tmp = env_get("bootfile");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr,
 					       "host:%s ", tmp);
@@ -295,10 +295,10 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			 * The following parameters are only needed if 'bootdev'
 			 * is an ethernet device, otherwise they are optional.
 			 */
-			tmp = getenv("ipaddr");
+			tmp = env_get("ipaddr");
 			if (tmp) {
 				ptr += sprintf(build_buf + ptr, "e=%s", tmp);
-				tmp = getenv("netmask");
+				tmp = env_get("netmask");
 				if (tmp) {
 					u32 mask = getenv_ip("netmask").s_addr;
 					ptr += sprintf(build_buf + ptr,
@@ -308,19 +308,19 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				}
 			}
 
-			tmp = getenv("serverip");
+			tmp = env_get("serverip");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr, "h=%s ", tmp);
 
-			tmp = getenv("gatewayip");
+			tmp = env_get("gatewayip");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr, "g=%s ", tmp);
 
-			tmp = getenv("hostname");
+			tmp = env_get("hostname");
 			if (tmp)
 				ptr += sprintf(build_buf + ptr, "tn=%s ", tmp);
 
-			tmp = getenv("othbootargs");
+			tmp = env_get("othbootargs");
 			if (tmp) {
 				strcpy(build_buf + ptr, tmp);
 				ptr += strlen(tmp);
@@ -341,12 +341,12 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	 * Since E820 information is critical to the kernel, if we don't
 	 * specify these in the environments, use a default one.
 	 */
-	tmp = getenv("e820data");
+	tmp = env_get("e820data");
 	if (tmp)
 		data = (struct e820entry *)simple_strtoul(tmp, NULL, 16);
 	else
 		data = (struct e820entry *)VXWORKS_E820_DATA_ADDR;
-	tmp = getenv("e820info");
+	tmp = env_get("e820info");
 	if (tmp)
 		info = (struct e820info *)simple_strtoul(tmp, NULL, 16);
 	else
cmd/fpga.c +2 -2
index 016349f560..ac6f504140 100644
@@ -43,8 +43,8 @@ int do_fpga(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	int op, dev = FPGA_INVALID_DEVICE;
 	size_t data_size = 0;
 	void *fpga_data = NULL;
-	char *devstr = getenv("fpga");
-	char *datastr = getenv("fpgadata");
+	char *devstr = env_get("fpga");
+	char *datastr = env_get("fpgadata");
 	int rc = FPGA_FAIL;
 	int wrong_parms = 0;
 #if defined(CONFIG_FIT)
cmd/gpt.c +2 -2
index cb76d5e540..e0ff9b9291 100644
@@ -50,14 +50,14 @@ static int extract_env(const char *str, char **env)
 	memset(s + strlen(s) - 1, '\0', 1);
 	memmove(s, s + 2, strlen(s) - 1);
 
-	e = getenv(s);
+	e = env_get(s);
 	if (e == NULL) {
 #ifdef CONFIG_RANDOM_UUID
 		debug("%s unset. ", str);
 		gen_rand_uuid_str(uuid_str, UUID_STR_FORMAT_GUID);
 		env_set(s, uuid_str);
 
-		e = getenv(s);
+		e = env_get(s);
 		if (e) {
 			debug("Set to random.\n");
 			ret = 0;
cmd/ini.c +2 -2
index 449f6e9f51..8656299447 100644
@@ -238,9 +238,9 @@ static int do_ini(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	section = argv[1];
 	file_address = (char *)simple_strtoul(
-		argc < 3 ? getenv("loadaddr") : argv[2], NULL, 16);
+		argc < 3 ? env_get("loadaddr") : argv[2], NULL, 16);
 	file_size = (size_t)simple_strtoul(
-		argc < 4 ? getenv("filesize") : argv[3], NULL, 16);
+		argc < 4 ? env_get("filesize") : argv[3], NULL, 16);
 
 	return ini_parse(file_address, file_size, ini_handler, (void *)section);
 }
cmd/itest.c +1 -1
index e1896d9f97..70db04a04f 100644
@@ -101,7 +101,7 @@ static char * evalstr(char *s)
 			i++;
 		}
 		s[i] = 0;
-		return  getenv((const char *)&s[2]);
+		return  env_get((const char *)&s[2]);
 	} else {
 		return s;
 	}
cmd/jffs2.c +2 -2
index add89dee6a..aee2f4513d 100644
@@ -479,9 +479,9 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	ulong offset = load_addr;
 
 	/* pre-set Boot file name */
-	if ((filename = getenv("bootfile")) == NULL) {
+	filename = env_get("bootfile");
+	if (!filename)
 		filename = "uImage";
-	}
 
 	if (argc == 2) {
 		filename = argv[1];
cmd/load.c +5 -5
index ec3730e0f6..519c309a61 100644
@@ -50,11 +50,11 @@ static int do_load_serial(cmd_tbl_t *cmdtp, int flag, int argc,
 	load_baudrate = current_baudrate = gd->baudrate;
 #endif
 
-	if (((env_echo = getenv("loads_echo")) != NULL) && (*env_echo == '1')) {
+	env_echo = env_get("loads_echo");
+	if (env_echo && *env_echo == '1')
 		do_echo = 1;
-	} else {
+	else
 		do_echo = 0;
-	}
 
 #ifdef	CONFIG_SYS_LOADS_BAUD_CHANGE
 	if (argc >= 2) {
@@ -427,9 +427,9 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int flag, int argc,
 	offset = CONFIG_SYS_LOAD_ADDR;
 
 	/* pre-set offset from $loadaddr */
-	if ((s = getenv("loadaddr")) != NULL) {
+	s = env_get("loadaddr");
+	if (s)
 		offset = simple_strtoul(s, NULL, 16);
-	}
 
 	load_baudrate = current_baudrate = gd->baudrate;
 
cmd/log.c +4 -2
index 873ee40371..7a3bd5cd69 100644
@@ -71,7 +71,8 @@ void logbuff_init_ptrs(void)
 #endif
 
 	/* Set up log version */
-	if ((s = getenv ("logversion")) != NULL)
+	s = env_get("logversion");
+	if (s)
 		log_version = (int)simple_strtoul(s, NULL, 10);
 
 	if (log_version == 2)
@@ -94,7 +95,8 @@ void logbuff_init_ptrs(void)
 		log->v2.start = log->v2.con;
 
 	/* Initialize default loglevel if present */
-	if ((s = getenv ("loglevel")) != NULL)
+	s = env_get("loglevel");
+	if (s)
 		console_loglevel = (int)simple_strtoul(s, NULL, 10);
 
 	gd->flags |= GD_FLG_LOGINIT;
cmd/md5sum.c +1 -1
index 1b2352ea55..c737cb23b5 100644
@@ -54,7 +54,7 @@ static int parse_verify_sum(char *verify_str, u8 *vsum)
 		if (strlen(verify_str) == 32)
 			vsum_str = verify_str;
 		else {
-			vsum_str = getenv(verify_str);
+			vsum_str = env_get(verify_str);
 			if (vsum_str == NULL || strlen(vsum_str) != 32)
 				return 1;
 		}
cmd/mtdparts.c +5 -5
index d3fde77ef0..a72668119d 100644
@@ -1536,8 +1536,8 @@ static int spread_partitions(void)
 static const char *getenv_mtdparts(char *buf)
 {
 	if (gd->flags & GD_FLG_ENV_READY)
-		return getenv("mtdparts");
-	if (getenv_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
+		return env_get("mtdparts");
+	if (env_get_f("mtdparts", buf, MTDPARTS_MAXLEN) != -1)
 		return buf;
 	return NULL;
 }
@@ -1741,9 +1741,9 @@ int mtdparts_init(void)
 	}
 
 	/* get variables */
-	ids = getenv("mtdids");
+	ids = env_get("mtdids");
 	parts = getenv_mtdparts(tmp_parts);
-	current_partition = getenv("partition");
+	current_partition = env_get("partition");
 
 	/* save it for later parsing, cannot rely on current partition pointer
 	 * as 'partition' variable may be updated during init */
@@ -1850,7 +1850,7 @@ int mtdparts_init(void)
 			current_mtd_partnum = pnum;
 			current_save();
 		}
-	} else if (getenv("partition") == NULL) {
+	} else if (env_get("partition") == NULL) {
 		debug("no partition variable set, setting...\n");
 		current_save();
 	}
cmd/mvebu/bubt.c +1 -1
index ea46e7b108..a1997ac0d3 100644
@@ -98,7 +98,7 @@ static ulong get_load_addr(void)
 	const char *addr_str;
 	unsigned long addr;
 
-	addr_str = getenv("loadaddr");
+	addr_str = env_get("loadaddr");
 	if (addr_str)
 		addr = simple_strtoul(addr_str, NULL, 16);
 	else
cmd/nand.c +3 -3
index 0f5d431e5c..a22945d144 100644
@@ -383,7 +383,7 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #else
 	int quiet = 0;
 #endif
-	const char *quiet_str = getenv("quiet");
+	const char *quiet_str = env_get("quiet");
 	int dev = nand_curr_device;
 	int repeat = flag & CMD_FLAG_REPEAT;
 
@@ -966,11 +966,11 @@ static int do_nandboot(cmd_tbl_t *cmdtp, int flag, int argc,
 	switch (argc) {
 	case 1:
 		addr = CONFIG_SYS_LOAD_ADDR;
-		boot_device = getenv("bootdevice");
+		boot_device = env_get("bootdevice");
 		break;
 	case 2:
 		addr = simple_strtoul(argv[1], NULL, 16);
-		boot_device = getenv("bootdevice");
+		boot_device = env_get("bootdevice");
 		break;
 	case 3:
 		addr = simple_strtoul(argv[1], NULL, 16);
cmd/net.c +2 -2
index fa6d02f90d..f40379f4f0 100644
@@ -181,7 +181,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 	ulong addr;
 
 	/* pre-set load_addr */
-	s = getenv("loadaddr");
+	s = env_get("loadaddr");
 	if (s != NULL)
 		load_addr = simple_strtoul(s, NULL, 16);
 
@@ -344,7 +344,7 @@ int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		}
 	}
 
-	toff = getenv("timeoffset");
+	toff = env_get("timeoffset");
 	if (toff == NULL)
 		net_ntp_time_offset = 0;
 	else
cmd/nvedit.c +7 -7
index a649004850..0468a4b7e9 100644
@@ -333,7 +333,7 @@ ulong getenv_hex(const char *varname, ulong default_val)
 	ulong value;
 	char *endp;
 
-	s = getenv(varname);
+	s = env_get(varname);
 	if (s)
 		value = simple_strtoul(s, &endp, 16);
 	if (!s || endp == s)
@@ -594,7 +594,7 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
 		return 1;
 
 	/* Set read buffer to initial value or empty sting */
-	init_val = getenv(argv[1]);
+	init_val = env_get(argv[1]);
 	if (init_val)
 		snprintf(buffer, CONFIG_SYS_CBSIZE, "%s", init_val);
 	else
@@ -622,7 +622,7 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
  * return address of storage for that variable,
  * or NULL if not found
  */
-char *getenv(const char *name)
+char *env_get(const char *name)
 {
 	if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */
 		ENTRY e, *ep;
@@ -637,7 +637,7 @@ char *getenv(const char *name)
 	}
 
 	/* restricted capabilities before import */
-	if (getenv_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
+	if (env_get_f(name, (char *)(gd->env_buf), sizeof(gd->env_buf)) > 0)
 		return (char *)(gd->env_buf);
 
 	return NULL;
@@ -646,7 +646,7 @@ char *getenv(const char *name)
 /*
  * Look up variable from environment for restricted C runtime env.
  */
-int getenv_f(const char *name, char *buf, unsigned len)
+int env_get_f(const char *name, char *buf, unsigned len)
 {
 	int i, nxt;
 
@@ -693,10 +693,10 @@ int getenv_f(const char *name, char *buf, unsigned len)
 ulong getenv_ulong(const char *name, int base, ulong default_val)
 {
 	/*
-	 * We can use getenv() here, even before relocation, since the
+	 * We can use env_get() here, even before relocation, since the
 	 * environment variable value is an integer and thus short.
 	 */
-	const char *str = getenv(name);
+	const char *str = env_get(name);
 
 	return str ? simple_strtoul(str, NULL, base) : default_val;
 }
cmd/pxe.c +15 -15
index 357b96940c..c0579079b8 100644
@@ -33,15 +33,15 @@ const char *pxe_default_paths[] = {
 static bool is_pxe;
 
 /*
- * Like getenv, but prints an error if envvar isn't defined in the
- * environment.  It always returns what getenv does, so it can be used in
- * place of getenv without changing error handling otherwise.
+ * Like env_get, but prints an error if envvar isn't defined in the
+ * environment.  It always returns what env_get does, so it can be used in
+ * place of env_get without changing error handling otherwise.
  */
 static char *from_env(const char *envvar)
 {
 	char *ret;
 
-	ret = getenv(envvar);
+	ret = env_get(envvar);
 
 	if (!ret)
 		printf("missing environment variable: %s\n", envvar);
@@ -649,9 +649,9 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		}
 
 		bootm_argv[2] = initrd_str;
-		strcpy(bootm_argv[2], getenv("ramdisk_addr_r"));
+		strcpy(bootm_argv[2], env_get("ramdisk_addr_r"));
 		strcat(bootm_argv[2], ":");
-		strcat(bootm_argv[2], getenv("filesize"));
+		strcat(bootm_argv[2], env_get("filesize"));
 	}
 
 	if (get_relfile_envaddr(cmdtp, label->kernel, "kernel_addr_r") < 0) {
@@ -662,8 +662,8 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 
 	if (label->ipappend & 0x1) {
 		sprintf(ip_str, " ip=%s:%s:%s:%s",
-			getenv("ipaddr"), getenv("serverip"),
-			getenv("gatewayip"), getenv("netmask"));
+			env_get("ipaddr"), env_get("serverip"),
+			env_get("gatewayip"), env_get("netmask"));
 	}
 
 #ifdef CONFIG_CMD_NET
@@ -699,7 +699,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		printf("append: %s\n", finalbootargs);
 	}
 
-	bootm_argv[1] = getenv("kernel_addr_r");
+	bootm_argv[1] = env_get("kernel_addr_r");
 
 	/*
 	 * fdt usage is optional:
@@ -714,7 +714,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 	 *
 	 * Scenario 3: fdt blob is not available.
 	 */
-	bootm_argv[3] = getenv("fdt_addr_r");
+	bootm_argv[3] = env_get("fdt_addr_r");
 
 	/* if fdt label is defined then get fdt from server */
 	if (bootm_argv[3]) {
@@ -726,7 +726,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 		} else if (label->fdtdir) {
 			char *f1, *f2, *f3, *f4, *slash;
 
-			f1 = getenv("fdtfile");
+			f1 = env_get("fdtfile");
 			if (f1) {
 				f2 = "";
 				f3 = "";
@@ -739,9 +739,9 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 				 * or the boot scripts should set $fdtfile
 				 * before invoking "pxe" or "sysboot".
 				 */
-				f1 = getenv("soc");
+				f1 = env_get("soc");
 				f2 = "-";
-				f3 = getenv("board");
+				f3 = env_get("board");
 				f4 = ".dtb";
 			}
 
@@ -781,7 +781,7 @@ static int label_boot(cmd_tbl_t *cmdtp, struct pxe_label *label)
 	}
 
 	if (!bootm_argv[3])
-		bootm_argv[3] = getenv("fdt_addr");
+		bootm_argv[3] = env_get("fdt_addr");
 
 	if (bootm_argv[3]) {
 		if (!bootm_argv[2])
@@ -1671,7 +1671,7 @@ static int do_sysboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	if (argc < 6)
-		filename = getenv("bootfile");
+		filename = env_get("bootfile");
 	else {
 		filename = argv[5];
 		env_set("bootfile", filename);
cmd/qfw.c +2 -2
index 9b12ab40ca..b38026ba81 100644
@@ -123,7 +123,7 @@ static int qemu_fwcfg_do_load(cmd_tbl_t *cmdtp, int flag,
 	void *load_addr;
 	void *initrd_addr;
 
-	env = getenv("loadaddr");
+	env = env_get("loadaddr");
 	load_addr = env ?
 		(void *)simple_strtoul(env, NULL, 16) :
 #ifdef CONFIG_LOADADDR
@@ -132,7 +132,7 @@ static int qemu_fwcfg_do_load(cmd_tbl_t *cmdtp, int flag,
 		NULL;
 #endif
 
-	env = getenv("ramdiskaddr");
+	env = env_get("ramdiskaddr");
 	initrd_addr = env ?
 		(void *)simple_strtoul(env, NULL, 16) :
 #ifdef CONFIG_RAMDISK_ADDR
cmd/reiser.c +3 -3
index 4df9c5f5db..e10c7b9eba 100644
@@ -88,18 +88,18 @@ int do_reiserload (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	switch (argc) {
 	case 3:
-		addr_str = getenv("loadaddr");
+		addr_str = env_get("loadaddr");
 		if (addr_str != NULL) {
 			addr = simple_strtoul (addr_str, NULL, 16);
 		} else {
 			addr = CONFIG_SYS_LOAD_ADDR;
 		}
-		filename = getenv ("bootfile");
+		filename = env_get("bootfile");
 		count = 0;
 		break;
 	case 4:
 		addr = simple_strtoul (argv[3], NULL, 16);
-		filename = getenv ("bootfile");
+		filename = env_get("bootfile");
 		count = 0;
 		break;
 	case 5:
cmd/setexpr.c +1 -1
index 91a5a9a770..af210225f1 100644
@@ -145,7 +145,7 @@ static int regex_sub(const char *name,
 	}
 
 	if (t == NULL) {
-		value = getenv(name);
+		value = env_get(name);
 
 		if (value == NULL) {
 			printf("## Error: variable \"%s\" not defined\n", name);
cmd/zfs.c +2 -2
index 08b0062c10..6913043d7f 100644
@@ -51,10 +51,10 @@ static int do_zfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]
 
 	count = 0;
 	addr = simple_strtoul(argv[3], NULL, 16);
-	filename = getenv("bootfile");
+	filename = env_get("bootfile");
 	switch (argc) {
 	case 3:
-		addr_str = getenv("loadaddr");
+		addr_str = env_get("loadaddr");
 		if (addr_str != NULL)
 			addr = simple_strtoul(addr_str, NULL, 16);
 		else
common/autoboot.c +8 -8
index 41f18208c3..35c1e972c6 100644
@@ -50,7 +50,7 @@ static int slow_equals(u8 *a, u8 *b, int len)
 
 static int passwd_abort(uint64_t etime)
 {
-	const char *sha_env_str = getenv("bootstopkeysha256");
+	const char *sha_env_str = env_get("bootstopkeysha256");
 	u8 sha_env[SHA256_SUM_LEN];
 	u8 sha[SHA256_SUM_LEN];
 	char presskey[MAX_DELAY_STOP_STR];
@@ -109,8 +109,8 @@ static int passwd_abort(uint64_t etime)
 		int retry;
 	}
 	delaykey[] = {
-		{ .str = getenv("bootdelaykey"),  .retry = 1 },
-		{ .str = getenv("bootstopkey"),   .retry = 0 },
+		{ .str = env_get("bootdelaykey"),  .retry = 1 },
+		{ .str = env_get("bootstopkey"),   .retry = 0 },
 	};
 
 	char presskey[MAX_DELAY_STOP_STR];
@@ -304,7 +304,7 @@ const char *bootdelay_process(void)
 	bootlimit = getenv_ulong("bootlimit", 10, 0);
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
 
-	s = getenv("bootdelay");
+	s = env_get("bootdelay");
 	bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;
 
 #ifdef CONFIG_OF_CONTROL
@@ -321,17 +321,17 @@ const char *bootdelay_process(void)
 
 #ifdef CONFIG_POST
 	if (gd->flags & GD_FLG_POSTFAIL) {
-		s = getenv("failbootcmd");
+		s = env_get("failbootcmd");
 	} else
 #endif /* CONFIG_POST */
 #ifdef CONFIG_BOOTCOUNT_LIMIT
 	if (bootlimit && (bootcount > bootlimit)) {
 		printf("Warning: Bootlimit (%u) exceeded. Using altbootcmd.\n",
 		       (unsigned)bootlimit);
-		s = getenv("altbootcmd");
+		s = env_get("altbootcmd");
 	} else
 #endif /* CONFIG_BOOTCOUNT_LIMIT */
-		s = getenv("bootcmd");
+		s = env_get("bootcmd");
 
 	process_fdt_options(gd->fdt_blob);
 	stored_bootdelay = bootdelay;
@@ -357,7 +357,7 @@ void autoboot_command(const char *s)
 
 #ifdef CONFIG_MENUKEY
 	if (menukey == CONFIG_MENUKEY) {
-		s = getenv("menucmd");
+		s = env_get("menucmd");
 		if (s)
 			run_command_list(s, -1, 0);
 	}
common/bootm.c +2 -2
index e34617a145..0c380e742f 100644
@@ -524,7 +524,7 @@ static void fixup_silent_linux(void)
 {
 	char *buf;
 	const char *env_val;
-	char *cmdline = getenv("bootargs");
+	char *cmdline = env_get("bootargs");
 	int want_silent;
 
 	/*
@@ -691,7 +691,7 @@ int do_bootm_states(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],
 #ifdef CONFIG_TRACE
 	/* Pretend to run the OS, then run a user command */
 	if (!ret && (states & BOOTM_STATE_OS_FAKE_GO)) {
-		char *cmd_list = getenv("fakegocmd");
+		char *cmd_list = env_get("fakegocmd");
 
 		ret = boot_selected_os(argc, argv, BOOTM_STATE_OS_FAKE_GO,
 				images, boot_fn);
common/bootm_os.c +5 -5
index 86a37cb925..1feea8af17 100644
@@ -21,7 +21,7 @@ static int do_bootm_standalone(int flag, int argc, char * const argv[],
 	int (*appl)(int, char *const[]);
 
 	/* Don't start if "autostart" is set to "no" */
-	s = getenv("autostart");
+	s = env_get("autostart");
 	if ((s != NULL) && !strcmp(s, "no")) {
 		env_set_hex("filesize", images->os.image_len);
 		return 0;
@@ -96,7 +96,7 @@ static int do_bootm_netbsd(int flag, int argc, char * const argv[],
 		cmdline = malloc(len);
 		copy_args(cmdline, argc, argv, ' ');
 	} else {
-		cmdline = getenv("bootargs");
+		cmdline = env_get("bootargs");
 		if (cmdline == NULL)
 			cmdline = "";
 	}
@@ -227,14 +227,14 @@ static int do_bootm_plan9(int flag, int argc, char * const argv[],
 #endif
 
 	/* See README.plan9 */
-	s = getenv("confaddr");
+	s = env_get("confaddr");
 	if (s != NULL) {
 		char *confaddr = (char *)simple_strtoul(s, NULL, 16);
 
 		if (argc > 0) {
 			copy_args(confaddr, argc, argv, '\n');
 		} else {
-			s = getenv("bootargs");
+			s = env_get("bootargs");
 			if (s != NULL)
 				strcpy(confaddr, s);
 		}
@@ -278,7 +278,7 @@ void do_bootvx_fdt(bootm_headers_t *images)
 
 		ret = fdt_add_subnode(*of_flat_tree, 0, "chosen");
 		if ((ret >= 0 || ret == -FDT_ERR_EXISTS)) {
-			bootline = getenv("bootargs");
+			bootline = env_get("bootargs");
 			if (bootline) {
 				ret = fdt_find_and_setprop(*of_flat_tree,
 						"/chosen", "bootargs",
common/bootretry.c +1 -1
index 2d82798cd0..b3b8271a92 100644
@@ -23,7 +23,7 @@ static int      retry_time = -1; /* -1 so can call readline before main_loop */
  */
 void bootretry_init_cmd_timeout(void)
 {
-	char *s = getenv("bootretry");
+	char *s = env_get("bootretry");
 
 	if (s != NULL)
 		retry_time = (int)simple_strtol(s, NULL, 10);
common/cli.c +1 -1
index a433ef2166..57874d8797 100644
@@ -129,7 +129,7 @@ int do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	for (i = 1; i < argc; ++i) {
 		char *arg;
 
-		arg = getenv(argv[i]);
+		arg = env_get(argv[i]);
 		if (arg == NULL) {
 			printf("## Error: \"%s\" not defined\n", argv[i]);
 			return 1;
common/cli_hush.c +7 -7
index 280289639c..07c048ec6a 100644
@@ -560,7 +560,7 @@ static int builtin_cd(struct child_prog *child)
 {
 	char *newdir;
 	if (child->argv[1] == NULL)
-		newdir = getenv("HOME");
+		newdir = env_get("HOME");
 	else
 		newdir = child->argv[1];
 	if (chdir(newdir)) {
@@ -948,7 +948,7 @@ static inline void cmdedit_set_initial_prompt(void)
 #ifndef CONFIG_FEATURE_SH_FANCY_PROMPT
 	PS1 = NULL;
 #else
-	PS1 = getenv("PS1");
+	PS1 = env_get("PS1");
 	if(PS1==0)
 		PS1 = "\\w \\$ ";
 #endif
@@ -987,9 +987,9 @@ static int uboot_cli_readline(struct in_str *i)
 
 #ifdef CONFIG_CMDLINE_PS_SUPPORT
 	if (i->promptmode == 1)
-		ps_prompt = getenv("PS1");
+		ps_prompt = env_get("PS1");
 	else
-		ps_prompt = getenv("PS2");
+		ps_prompt = env_get("PS2");
 	if (ps_prompt)
 		prompt = ps_prompt;
 #endif
@@ -2172,7 +2172,7 @@ int set_local_var(const char *s, int flg_export)
 	name=strdup(s);
 
 #ifdef __U_BOOT__
-	if (getenv(name) != NULL) {
+	if (env_get(name) != NULL) {
 		printf ("ERROR: "
 				"There is a global environment variable with the same name.\n");
 		free(name);
@@ -2793,7 +2793,7 @@ static char *lookup_param(char *src)
 		}
 	}
 
-	p = getenv(src);
+	p = env_get(src);
 	if (!p)
 		p = get_local_var(src);
 
@@ -3157,7 +3157,7 @@ static void mapset(const unsigned char *set, int code)
 static void update_ifs_map(void)
 {
 	/* char *ifs and char map[256] are both globals. */
-	ifs = (uchar *)getenv("IFS");
+	ifs = (uchar *)env_get("IFS");
 	if (ifs == NULL) ifs=(uchar *)" \t\n";
 	/* Precompute a list of 'flow through' behavior so it can be treated
 	 * quickly up front.  Computation is necessary because of IFS.
common/cli_simple.c +2 -2
index bb96aaead6..cb642d2ff3 100644
@@ -131,7 +131,7 @@ void cli_simple_process_macros(const char *input, char *output)
 				envname[i] = 0;
 
 				/* Get its value */
-				envval = getenv(envname);
+				envval = env_get(envname);
 
 				/* Copy into the line if it exists */
 				if (envval != NULL)
@@ -168,7 +168,7 @@ void cli_simple_process_macros(const char *input, char *output)
  * WARNING:
  *
  * We must create a temporary copy of the command since the command we get
- * may be the result from getenv(), which returns a pointer directly to
+ * may be the result from env_get(), which returns a pointer directly to
  * the environment data, which may change magicly when the command we run
  * creates or modifies environment variables (like "bootp" does).
  */
common/console.c +5 -5
index daf155500d..fb629f4875 100644
@@ -642,7 +642,7 @@ int console_assign(int file, const char *devname)
 static void console_update_silent(void)
 {
 #ifdef CONFIG_SILENT_CONSOLE
-	if (getenv("silent") != NULL)
+	if (env_get("silent") != NULL)
 		gd->flags |= GD_FLG_SILENT;
 	else
 		gd->flags &= ~GD_FLG_SILENT;
@@ -721,9 +721,9 @@ int console_init_r(void)
 
 	/* stdin stdout and stderr are in environment */
 	/* scan for it */
-	stdinname  = getenv("stdin");
-	stdoutname = getenv("stdout");
-	stderrname = getenv("stderr");
+	stdinname  = env_get("stdin");
+	stdoutname = env_get("stdout");
+	stderrname = env_get("stderr");
 
 	if (OVERWRITE_CONSOLE == 0) {	/* if not overwritten by config switch */
 		inputdev  = search_device(DEV_FLAGS_INPUT,  stdinname);
@@ -812,7 +812,7 @@ int console_init_r(void)
 	 * console to serial console in this case or suppress it if
 	 * "silent" mode was requested.
 	 */
-	if (getenv("splashimage") != NULL) {
+	if (env_get("splashimage") != NULL) {
 		if (!(gd->flags & GD_FLG_SILENT))
 			outputdev = search_device (DEV_FLAGS_OUTPUT, "serial");
 	}
common/fb_mmc.c +1 -1
index 2113b6c372..5065ad5f73 100644
@@ -49,7 +49,7 @@ static int part_get_info_by_name_or_alias(struct blk_desc *dev_desc,
 		/* check for alias */
 		strcpy(env_alias_name, "fastboot_partition_alias_");
 		strncat(env_alias_name, name, 32);
-		aliased_part_name = getenv(env_alias_name);
+		aliased_part_name = env_get(env_alias_name);
 		if (aliased_part_name != NULL)
 			ret = part_get_info_by_name(dev_desc,
 					aliased_part_name, info);
common/fdt_support.c +3 -3
index 5aa8e3422e..b0d7f82894 100644
@@ -197,7 +197,7 @@ int fdt_root(void *fdt)
 		return err;
 	}
 
-	serial = getenv("serial#");
+	serial = env_get("serial#");
 	if (serial) {
 		err = fdt_setprop(fdt, 0, "serial-number", serial,
 				  strlen(serial) + 1);
@@ -289,7 +289,7 @@ int fdt_chosen(void *fdt)
 	if (nodeoffset < 0)
 		return nodeoffset;
 
-	str = getenv("bootargs");
+	str = env_get("bootargs");
 	if (str) {
 		err = fdt_setprop(fdt, nodeoffset, "bootargs", str,
 				  strlen(str) + 1);
@@ -509,7 +509,7 @@ void fdt_fixup_ethernet(void *fdt)
 			} else {
 				continue;
 			}
-			tmp = getenv(mac);
+			tmp = env_get(mac);
 			if (!tmp)
 				continue;
 
common/hash.c +1 -1
index fda636d34a..dcf016d8a7 100644
@@ -362,7 +362,7 @@ static int parse_verify_sum(struct hash_algo *algo, char *verify_str,
 		if (strlen(verify_str) == digits)
 			vsum_str = verify_str;
 		else {
-			vsum_str = getenv(verify_str);
+			vsum_str = env_get(verify_str);
 			if (vsum_str == NULL || strlen(vsum_str) != digits) {
 				printf("Expected %d hex digits in env var\n",
 				       digits);
common/hwconfig.c +1 -1
index 85aaabbb85..e5186d7796 100644
@@ -81,7 +81,7 @@ static const char *__hwconfig(const char *opt, size_t *arglen,
 					"and before environment is ready\n");
 			return NULL;
 		}
-		env_hwconfig = getenv("hwconfig");
+		env_hwconfig = env_get("hwconfig");
 	}
 
 	if (env_hwconfig) {
common/image-android.c +1 -1
index 018c7594fe..e74d0aafca 100644
@@ -72,7 +72,7 @@ int android_image_get_kernel(const struct andr_img_hdr *hdr, int verify,
 		len += strlen(hdr->cmdline);
 	}
 
-	char *bootargs = getenv("bootargs");
+	char *bootargs = env_get("bootargs");
 	if (bootargs)
 		len += strlen(bootargs);
 
common/image-fdt.c +1 -1
index c6e8832d66..2c499467c3 100644
@@ -132,7 +132,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 	of_len = *of_size + CONFIG_SYS_FDT_PAD;
 
 	/* If fdt_high is set use it to select the relocation address */
-	fdt_high = getenv("fdt_high");
+	fdt_high = env_get("fdt_high");
 	if (fdt_high) {
 		void *desired_addr = (void *)simple_strtoul(fdt_high, NULL, 16);
 
common/image.c +8 -6
index 0f88984f2d..98c0eaa4c7 100644
@@ -467,7 +467,7 @@ U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
 
 ulong getenv_bootm_low(void)
 {
-	char *s = getenv("bootm_low");
+	char *s = env_get("bootm_low");
 	if (s) {
 		ulong tmp = simple_strtoul(s, NULL, 16);
 		return tmp;
@@ -486,7 +486,7 @@ phys_size_t getenv_bootm_size(void)
 {
 	phys_size_t tmp, size;
 	phys_addr_t start;
-	char *s = getenv("bootm_size");
+	char *s = env_get("bootm_size");
 	if (s) {
 		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
 		return tmp;
@@ -500,7 +500,7 @@ phys_size_t getenv_bootm_size(void)
 	size = gd->bd->bi_memsize;
 #endif
 
-	s = getenv("bootm_low");
+	s = env_get("bootm_low");
 	if (s)
 		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
 	else
@@ -512,7 +512,7 @@ phys_size_t getenv_bootm_size(void)
 phys_size_t getenv_bootm_mapsize(void)
 {
 	phys_size_t tmp;
-	char *s = getenv("bootm_mapsize");
+	char *s = env_get("bootm_mapsize");
 	if (s) {
 		tmp = (phys_size_t)simple_strtoull(s, NULL, 16);
 		return tmp;
@@ -1224,7 +1224,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
 	ulong	initrd_high;
 	int	initrd_copy_to_ram = 1;
 
-	if ((s = getenv("initrd_high")) != NULL) {
+	s = env_get("initrd_high");
+	if (s) {
 		/* a value of "no" or a similar string will act like 0,
 		 * turning the "load high" feature off. This is intentional.
 		 */
@@ -1524,7 +1525,8 @@ int boot_get_cmdline(struct lmb *lmb, ulong *cmd_start, ulong *cmd_end)
 	if (cmdline == NULL)
 		return -1;
 
-	if ((s = getenv("bootargs")) == NULL)
+	s = env_get("bootargs");
+	if (!s)
 		s = "";
 
 	strcpy(cmdline, s);
common/lcd.c +1 -1
index 7e399cee2d..c3ff9599ed 100644
@@ -223,7 +223,7 @@ void lcd_clear(void)
 	/* Paint the logo and retrieve LCD base address */
 	debug("[LCD] Drawing the logo...\n");
 	if (do_splash) {
-		s = getenv("splashimage");
+		s = env_get("splashimage");
 		if (s) {
 			do_splash = 0;
 			addr = simple_strtoul(s, NULL, 16);
common/main.c +1 -1
index 07fc31b716..6a1159879e 100644
@@ -25,7 +25,7 @@ static void run_preboot_environment_command(void)
 #ifdef CONFIG_PREBOOT
 	char *p;
 
-	p = getenv("preboot");
+	p = env_get("preboot");
 	if (p != NULL) {
 # ifdef CONFIG_AUTOBOOT_KEYED
 		int prev = disable_ctrlc(1);	/* disable Control C checking */
common/spl/Kconfig +1 -1
index 60a73311d9..c96e7bfceb 100644
@@ -248,7 +248,7 @@ config SPL_ENV_SUPPORT
 	  needed in SPL as it has a much simpler task with less
 	  configuration. But some boards use this to support 'Falcon' boot
 	  on EXT2 and FAT, where SPL boots directly into Linux without
-	  starting U-Boot first. Enabling this option will make getenv()
+	  starting U-Boot first. Enabling this option will make env_get()
 	  and env_set() available in SPL.
 
 config SPL_SAVEENV
common/spl/spl_dfu.c +1 -1
index f5ec0fb396..2c974735b1 100644
@@ -40,7 +40,7 @@ int spl_dfu_cmd(int usbctrl, char *dfu_alt_info, char *interface, char *devstr)
 
 	/* set default environment */
 	set_default_env(0);
-	str_env = getenv(dfu_alt_info);
+	str_env = env_get(dfu_alt_info);
 	if (!str_env) {
 		error("\"dfu_alt_info\" env variable not defined!\n");
 		return -EINVAL;
common/spl/spl_ext.c +2 -2
index f17c6b9494..559ba0b797 100644
@@ -89,7 +89,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
 		return -1;
 	}
 #if defined(CONFIG_SPL_ENV_SUPPORT)
-	file = getenv("falcon_args_file");
+	file = env_get("falcon_args_file");
 	if (file) {
 		err = ext4fs_open(file, &filelen);
 		if (err < 0) {
@@ -102,7 +102,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image,
 			       file, err);
 			goto defaults;
 		}
-		file = getenv("falcon_image_file");
+		file = env_get("falcon_image_file");
 		if (file) {
 			err = spl_load_image_ext(spl_image, block_dev,
 						 partition, file);
common/spl/spl_fat.c +2 -2
index 5e312160d9..60b85f082d 100644
@@ -113,7 +113,7 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
 		return err;
 
 #if defined(CONFIG_SPL_ENV_SUPPORT) && defined(CONFIG_SPL_OS_BOOT)
-	file = getenv("falcon_args_file");
+	file = env_get("falcon_args_file");
 	if (file) {
 		err = file_fat_read(file, (void *)CONFIG_SYS_SPL_ARGS_ADDR, 0);
 		if (err <= 0) {
@@ -121,7 +121,7 @@ int spl_load_image_fat_os(struct spl_image_info *spl_image,
 			       file, err);
 			goto defaults;
 		}
-		file = getenv("falcon_image_file");
+		file = env_get("falcon_image_file");
 		if (file) {
 			err = spl_load_image_fat(spl_image, block_dev,
 						 partition, file);
common/splash.c +1 -1
index 89af437f2c..d251b3b654 100644
@@ -60,7 +60,7 @@ __weak int splash_screen_prepare(void)
 #ifdef CONFIG_SPLASH_SCREEN_ALIGN
 void splash_get_pos(int *x, int *y)
 {
-	char *s = getenv("splashpos");
+	char *s = env_get("splashpos");
 
 	if (!s)
 		return;
common/splash_source.c +3 -3
index 867a798487..8c0ac581f7 100644
@@ -220,7 +220,7 @@ static int splash_load_fs(struct splash_location *location, u32 bmp_load_addr)
 	loff_t actread;
 	char *splash_file;
 
-	splash_file = getenv("splashfile");
+	splash_file = env_get("splashfile");
 	if (!splash_file)
 		splash_file = SPLASH_SOURCE_DEFAULT_FILE_NAME;
 
@@ -286,7 +286,7 @@ static struct splash_location *select_splash_location(
 	if (!locations || size == 0)
 		return NULL;
 
-	env_splashsource = getenv("splashsource");
+	env_splashsource = env_get("splashsource");
 	if (env_splashsource == NULL)
 		return &locations[0];
 
@@ -383,7 +383,7 @@ int splash_source_load(struct splash_location *locations, uint size)
 	char *env_splashimage_value;
 	u32 bmp_load_addr;
 
-	env_splashimage_value = getenv("splashimage");
+	env_splashimage_value = env_get("splashimage");
 	if (env_splashimage_value == NULL)
 		return -ENOENT;
 
common/update.c +4 -3
index 061a5541b1..974f4655e7 100644
@@ -59,7 +59,7 @@ static int update_load(char *filename, ulong msec_max, int cnt_max, ulong addr)
 	/* save used globals and env variable */
 	saved_timeout_msecs = tftp_timeout_ms;
 	saved_timeout_count = tftp_timeout_count_max;
-	saved_netretry = strdup(getenv("netretry"));
+	saved_netretry = strdup(env_get("netretry"));
 	saved_bootfile = strdup(net_boot_file_name);
 
 	/* set timeouts for auto-update */
@@ -254,7 +254,7 @@ int update_tftp(ulong addr, char *interface, char *devstring)
 	printf("Auto-update from TFTP: ");
 
 	/* get the file name of the update file */
-	filename = getenv(UPDATE_FILE_ENV);
+	filename = env_get(UPDATE_FILE_ENV);
 	if (filename == NULL) {
 		printf("failed, env. variable '%s' not found\n",
 							UPDATE_FILE_ENV);
@@ -264,7 +264,8 @@ int update_tftp(ulong addr, char *interface, char *devstring)
 	printf("trying update file '%s'\n", filename);
 
 	/* get load address of downloaded update file */
-	if ((env_addr = getenv("loadaddr")) != NULL)
+	env_addr = env_get("loadaddr");
+	if (env_addr)
 		addr = simple_strtoul(env_addr, NULL, 16);
 	else
 		addr = CONFIG_UPDATE_LOAD_ADDR;
common/usb_hub.c +1 -1
index 70bc6e2931..86a3477664 100644
@@ -189,7 +189,7 @@ static void usb_hub_power_on(struct usb_hub_device *hub)
 	 * but allow this time to be increased via env variable as some
 	 * devices break the spec and require longer warm-up times
 	 */
-	env = getenv("usb_pgood_delay");
+	env = env_get("usb_pgood_delay");
 	if (env)
 		pgood_delay = max(pgood_delay,
 			          (unsigned)simple_strtol(env, NULL, 0));
common/usb_kbd.c +3 -3
index d2d29cc98f..8cbdba6ac2 100644
@@ -515,7 +515,7 @@ static int probe_usb_keyboard(struct usb_device *dev)
 	if (error)
 		return error;
 
-	stdinname = getenv("stdin");
+	stdinname = env_get("stdin");
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
 	error = iomux_doenv(stdin, stdinname);
 	if (error)
@@ -582,7 +582,7 @@ int usb_kbd_deregister(int force)
 		if (stdio_deregister_dev(dev, force) != 0)
 			return 1;
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
-		if (iomux_doenv(stdin, getenv("stdin")) != 0)
+		if (iomux_doenv(stdin, env_get("stdin")) != 0)
 			return 1;
 #endif
 #ifdef CONFIG_SYS_USB_EVENT_POLL_VIA_INT_QUEUE
@@ -627,7 +627,7 @@ static int usb_kbd_remove(struct udevice *dev)
 		goto err;
 	}
 #if CONFIG_IS_ENABLED(CONSOLE_MUX)
-	if (iomux_doenv(stdin, getenv("stdin"))) {
+	if (iomux_doenv(stdin, env_get("stdin"))) {
 		ret = -ENOLINK;
 		goto err;
 	}
disk/part.c +1 -1
index 491b02dc9c..05d07d850b 100644
@@ -452,7 +452,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,
 	/* If no dev_part_str, use bootdevice environment variable */
 	if (!dev_part_str || !strlen(dev_part_str) ||
 	    !strcmp(dev_part_str, "-"))
-		dev_part_str = getenv("bootdevice");
+		dev_part_str = env_get("bootdevice");
 
 	/* If still no dev_part_str, it's an error */
 	if (!dev_part_str) {
disk/part_amiga.c +2 -2
index 25fe56ce42..f8dae008d7 100644
@@ -132,7 +132,7 @@ struct rigid_disk_block *get_rdisk(struct blk_desc *dev_desc)
     int limit;
     char *s;
 
-    s = getenv("amiga_scanlimit");
+    s = env_get("amiga_scanlimit");
     if (s)
 	limit = simple_strtoul(s, NULL, 10);
     else
@@ -172,7 +172,7 @@ struct bootcode_block *get_bootcode(struct blk_desc *dev_desc)
     int limit;
     char *s;
 
-    s = getenv("amiga_scanlimit");
+    s = env_get("amiga_scanlimit");
     if (s)
 	limit = simple_strtoul(s, NULL, 10);
     else
drivers/ddr/fsl/fsl_ddr_gen4.c +1 -1
index 3349fc5c3b..058c9b9da8 100644
@@ -469,7 +469,7 @@ step2:
 #define CTLR_INTLV_MASK	0x20000000
 	/* Perform build-in test on memory. Three-way interleaving is not yet
 	 * supported by this code. */
-	if (getenv_f("ddr_bist", buffer, CONFIG_SYS_CBSIZE) >= 0) {
+	if (env_get_f("ddr_bist", buffer, CONFIG_SYS_CBSIZE) >= 0) {
 		puts("Running BIST test. This will take a while...");
 		cs0_config = ddr_in32(&ddr->cs0_config);
 		cs0_bnds = ddr_in32(&ddr->cs0_bnds);
drivers/ddr/fsl/interactive.c +4 -4
index 653bbabc95..c99bd2fb6d 100644
@@ -1861,7 +1861,7 @@ int fsl_ddr_interactive_env_var_exists(void)
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 
-	if (getenv_f("ddr_interactive", buffer, CONFIG_SYS_CBSIZE) >= 0)
+	if (env_get_f("ddr_interactive", buffer, CONFIG_SYS_CBSIZE) >= 0)
 		return 1;
 
 	return 0;
@@ -1891,11 +1891,11 @@ unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo, int var_is_set)
 	};
 
 	if (var_is_set) {
-		if (getenv_f("ddr_interactive", buffer2, CONFIG_SYS_CBSIZE) > 0) {
+		if (env_get_f("ddr_interactive", buffer2,
+			      CONFIG_SYS_CBSIZE) > 0)
 			p = buffer2;
-		} else {
+		else
 			var_is_set = 0;
-		}
 	}
 
 	/*
drivers/ddr/fsl/options.c +3 -3
index 20edd2dc28..a7eaed1bd7 100644
@@ -18,7 +18,7 @@
  * Use our own stack based buffer before relocation to allow accessing longer
  * hwconfig strings that might be in the environment before we've relocated.
  * This is pretty fragile on both the use of stack and if the buffer is big
- * enough. However we will get a warning from getenv_f for the later.
+ * enough. However we will get a warning from env_get_f() for the latter.
  */
 
 /* Board-specific functions defined in each board's ddr.c */
@@ -755,7 +755,7 @@ unsigned int populate_memctl_options(const common_timing_params_t *common_dimm,
 	 * Extract hwconfig from environment since we have not properly setup
 	 * the environment but need it for ddr config params
 	 */
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		buf = buffer;
 
 #if defined(CONFIG_SYS_FSL_DDR3) || \
@@ -1399,7 +1399,7 @@ int fsl_use_spd(void)
 	 * Extract hwconfig from environment since we have not properly setup
 	 * the environment but need it for ddr config params
 	 */
-	if (getenv_f("hwconfig", buffer, sizeof(buffer)) > 0)
+	if (env_get_f("hwconfig", buffer, sizeof(buffer)) > 0)
 		buf = buffer;
 
 	/* if hwconfig is not enabled, or "sdram" is not defined, use spd */
drivers/dfu/dfu.c +3 -3
index f6281f4baa..ff732ac309 100644
@@ -62,7 +62,7 @@ int dfu_init_env_entities(char *interface, char *devstr)
 #ifdef CONFIG_SET_DFU_ALT_INFO
 	set_dfu_alt_info(interface, devstr);
 #endif
-	str_env = getenv("dfu_alt_info");
+	str_env = env_get("dfu_alt_info");
 	if (!str_env) {
 		error("\"dfu_alt_info\" env variable not defined!\n");
 		return -EINVAL;
@@ -101,7 +101,7 @@ unsigned char *dfu_get_buf(struct dfu_entity *dfu)
 	if (dfu_buf != NULL)
 		return dfu_buf;
 
-	s = getenv("dfu_bufsiz");
+	s = env_get("dfu_bufsiz");
 	if (s)
 		dfu_buf_size = (unsigned long)simple_strtol(s, NULL, 0);
 
@@ -123,7 +123,7 @@ static char *dfu_get_hash_algo(void)
 {
 	char *s;
 
-	s = getenv("dfu_hash_algo");
+	s = env_get("dfu_hash_algo");
 	if (!s)
 		return NULL;
 
drivers/dfu/dfu_mmc.c +1 -1
index bb23e7fdcb..39e10b1a5a 100644
@@ -161,7 +161,7 @@ static int mmc_file_op(enum dfu_op op, struct dfu_entity *dfu,
 	}
 
 	if (op != DFU_OP_WRITE) {
-		str_env = getenv("filesize");
+		str_env = env_get("filesize");
 		if (str_env == NULL) {
 			puts("dfu: Wrong file size!\n");
 			return -1;
drivers/input/i8042.c +1 -1
index 0fd25b17ec..18476e97d1 100644
@@ -274,7 +274,7 @@ static int i8042_start(struct udevice *dev)
 
 	/* Init keyboard device (default US layout) */
 	keymap = KBD_US;
-	penv = getenv("keymap");
+	penv = env_get("keymap");
 	if (penv != NULL) {
 		if (strncmp(penv, "de", 3) == 0)
 			keymap = KBD_GER;
drivers/input/input.c +1 -1
index 011667fedd..26da3a95ff 100644
@@ -652,7 +652,7 @@ int input_stdio_register(struct stdio_dev *dev)
 	error = stdio_register(dev);
 
 	/* check if this is the standard input device */
-	if (!error && strcmp(getenv("stdin"), dev->name) == 0) {
+	if (!error && strcmp(env_get("stdin"), dev->name) == 0) {
 		/* reassign the console */
 		if (OVERWRITE_CONSOLE ||
 				console_assign(stdin, dev->name))
drivers/mtd/cfi_flash.c +1 -1
index 048a51785e..42bc2efd90 100644
@@ -2353,7 +2353,7 @@ unsigned long flash_init (void)
 #ifdef CONFIG_SYS_FLASH_PROTECTION
 	/* read environment from EEPROM */
 	char s[64];
-	getenv_f("unlock", s, sizeof(s));
+	env_get_f("unlock", s, sizeof(s));
 #endif
 
 #ifdef CONFIG_CFI_FLASH /* for driver model */
drivers/net/fec_mxc.c +1 -1
index 424c347e0e..797e34f7cc 100644
@@ -1096,7 +1096,7 @@ static int fec_probe(bd_t *bd, int dev_id, uint32_t base_addr,
 			sprintf(mac, "eth%daddr", fec->dev_id);
 		else
 			strcpy(mac, "ethaddr");
-		if (!getenv(mac))
+		if (!env_get(mac))
 			eth_env_set_enetaddr(mac, ethaddr);
 	}
 	return ret;
drivers/net/fm/b4860.c +1 -1
index 5aeeb87282..3245bee473 100644
@@ -97,7 +97,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port)
 			 * Extract hwconfig from environment since environment
 			 * is not setup yet
 			 */
-			getenv_f("hwconfig", buffer, sizeof(buffer));
+			env_get_f("hwconfig", buffer, sizeof(buffer));
 			buf = buffer;
 
 			/* check if XFI interface enable in hwconfig for 10g */
drivers/net/fm/fdt.c +1 -1
index 9918d8089a..5920fecea1 100644
@@ -36,7 +36,7 @@ void fdt_fixup_fman_firmware(void *blob)
 		return;
 
 	/* If the environment variable is not set, then exit silently */
-	p = getenv("fman_ucode");
+	p = env_get("fman_ucode");
 	if (!p)
 		return;
 
drivers/net/fsl-mc/mc.c +3 -3
index 8bf25c7040..9c0af2843d 100644
@@ -530,7 +530,7 @@ static unsigned long get_mc_boot_timeout_ms(void)
 {
 	unsigned long timeout_ms = CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS;
 
-	char *timeout_ms_env_var = getenv(MC_BOOT_TIMEOUT_ENV_VAR);
+	char *timeout_ms_env_var = env_get(MC_BOOT_TIMEOUT_ENV_VAR);
 
 	if (timeout_ms_env_var) {
 		timeout_ms = simple_strtoul(timeout_ms_env_var, NULL, 10);
@@ -815,7 +815,7 @@ unsigned long mc_get_dram_block_size(void)
 {
 	unsigned long dram_block_size = CONFIG_SYS_LS_MC_DRAM_BLOCK_MIN_SIZE;
 
-	char *dram_block_size_env_var = getenv(MC_MEM_SIZE_ENV_VAR);
+	char *dram_block_size_env_var = env_get(MC_MEM_SIZE_ENV_VAR);
 
 	if (dram_block_size_env_var) {
 		dram_block_size = simple_strtoul(dram_block_size_env_var, NULL,
@@ -1511,7 +1511,7 @@ void mc_env_boot(void)
 	 * address info properly. Without MAC addresses, the MC code
 	 * can not properly initialize the DPC.
 	 */
-	mc_boot_env_var = getenv(MC_BOOT_ENV_VAR);
+	mc_boot_env_var = env_get(MC_BOOT_ENV_VAR);
 	if (mc_boot_env_var)
 		run_command_list(mc_boot_env_var, -1, 0);
 #endif /* CONFIG_FSL_MC_ENET */
drivers/net/netconsole.c +4 -4
index 3500047577..2210c57a64 100644
@@ -82,11 +82,11 @@ static int refresh_settings_from_env(void)
 
 	/* update only when the environment has changed */
 	if (env_changed_id != env_id) {
-		if (getenv("ncip")) {
+		if (env_get("ncip")) {
 			nc_ip = getenv_ip("ncip");
 			if (!nc_ip.s_addr)
 				return -1;	/* ncip is 0.0.0.0 */
-			p = strchr(getenv("ncip"), ':');
+			p = strchr(env_get("ncip"), ':');
 			if (p != NULL) {
 				nc_out_port = simple_strtoul(p + 1, NULL, 10);
 				nc_in_port = nc_out_port;
@@ -95,10 +95,10 @@ static int refresh_settings_from_env(void)
 			nc_ip.s_addr = ~0; /* ncip is not set, so broadcast */
 		}
 
-		p = getenv("ncoutport");
+		p = env_get("ncoutport");
 		if (p != NULL)
 			nc_out_port = simple_strtoul(p, NULL, 10);
-		p = getenv("ncinport");
+		p = env_get("ncinport");
 		if (p != NULL)
 			nc_in_port = simple_strtoul(p, NULL, 10);
 
drivers/net/phy/micrel.c +1 -1
index 0e4a4ebcc6..15cae957e7 100644
@@ -357,7 +357,7 @@ static int ksz9021_config(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
-	if (getenv("disable_giga"))
+	if (env_get("disable_giga"))
 		features &= ~(SUPPORTED_1000baseT_Half |
 				SUPPORTED_1000baseT_Full);
 	/* force master mode for 1000BaseT due to chip errata */
drivers/pci/fsl_pci_init.c +2 -2
index af20cf0f3e..df76a94144 100644
@@ -390,7 +390,7 @@ void fsl_pci_init(struct pci_controller *hose, struct fsl_pci_info *pci_info)
 
 #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
 	/* boot from PCIE --master */
-	char *s = getenv("bootmaster");
+	char *s = env_get("bootmaster");
 	char pcie[6];
 	sprintf(pcie, "PCIE%d", pci_info->pci_num);
 
@@ -673,7 +673,7 @@ int fsl_pci_init_port(struct fsl_pci_info *pci_info,
 #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
 	} else {
 		/* boot from PCIE --master releases slave's core 0 */
-		char *s = getenv("bootmaster");
+		char *s = env_get("bootmaster");
 		char pcie[6];
 		sprintf(pcie, "PCIE%d", pci_info->pci_num);
 
drivers/pci/pci.c +2 -2
index 6b36c187b5..bbc7dab366 100644
@@ -427,7 +427,7 @@ int pci_hose_scan(struct pci_controller *hose)
 
 	if (!gd->pcidelay_done) {
 		/* wait "pcidelay" ms (if defined)... */
-		s = getenv("pcidelay");
+		s = env_get("pcidelay");
 		if (s) {
 			int val = simple_strtoul(s, NULL, 10);
 			for (i = 0; i < val; i++)
@@ -459,7 +459,7 @@ void pci_init(void)
 	hose_head = NULL;
 
 	/* allow env to disable pci init/enum */
-	if (getenv("pcidisable") != NULL)
+	if (env_get("pcidisable") != NULL)
 		return;
 
 	/* now call board specific pci_init()... */
drivers/pci/pci_common.c +1 -1
index 6526de80db..faf25d96cb 100644
@@ -89,7 +89,7 @@ __weak int pci_skip_dev(struct pci_controller *hose, pci_dev_t dev)
 		/*
 		 * Only skip configuration if "pciconfighost" is not set
 		 */
-		if (getenv("pciconfighost") == NULL)
+		if (env_get("pciconfighost") == NULL)
 			return 1;
 #else
 		return 1;
drivers/rtc/m41t60.c +1 -1
index 95083f0d72..2ddfd4ea5c 100644
@@ -200,7 +200,7 @@ int rtc_set(struct rtc_time *tmp)
 void rtc_reset(void)
 {
 	uchar *const data = rtc_validate();
-	char const *const s = getenv("rtccal");
+	char const *const s = env_get("rtccal");
 
 	if (!data)
 		return;
drivers/serial/usbtty.c +4 -5
index 29799dce93..353109c070 100644
@@ -526,9 +526,9 @@ int drv_usbtty_init (void)
 	int snlen;
 
 	/* Ger seiral number */
-	if (!(sn = getenv("serial#"))) {
+	sn = env_get("serial#");
+	if (!sn)
 		sn = "000000000000";
-	}
 	snlen = strlen(sn);
 	if (snlen > sizeof(serial_number) - 1) {
 		printf ("Warning: serial number %s is too long (%d > %lu)\n",
@@ -540,10 +540,9 @@ int drv_usbtty_init (void)
 
 	/* Decide on which type of UDC device to be.
 	 */
-
-	if(!(tt = getenv("usbtty"))) {
+	tt = env_get("usbtty");
+	if (!tt)
 		tt = "generic";
-	}
 	usbtty_init_terminal_type(strcmp(tt,"cdc_acm"));
 
 	/* prepare buffers... */
drivers/usb/gadget/designware_udc.c +1 -1
index 0db7a3b6c1..a25f5019e8 100644
@@ -601,7 +601,7 @@ void udc_setup_ep(struct usb_device_instance *device,
 	if ((ep != 0) && (udc_device->device_state < STATE_ADDRESSED))
 		return;
 
-	tt = getenv("usbtty");
+	tt = env_get("usbtty");
 	if (!tt)
 		tt = "generic";
 
drivers/usb/gadget/ether.c +6 -6
index d0105372cf..2cf5c8d31e 100644
@@ -2384,12 +2384,12 @@ static int _usb_eth_init(struct ether_priv *priv)
 	strlcpy(host_addr, CONFIG_USBNET_HOST_ADDR, sizeof(host_addr));
 #endif
 	/* Check if the user overruled the MAC addresses */
-	if (getenv("usbnet_devaddr"))
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

drivers/usb/gadget/f_dfu.c +1 -1
index dfa4359577..bc4be712da 100644

Lines of this file are not shown. View the raw message.

drivers/usb/gadget/f_fastboot.c +3 -3
index 7cd6d24bf5..d05b74b2d2 100644

Lines of this file are not shown. View the raw message.

drivers/usb/host/ehci-fsl.c +1 -1
index b57c6cd35a..62c431b99f 100644

Lines of this file are not shown. View the raw message.

drivers/video/ati_radeon_fb.c +2 -1
index 07a29eaba1..5b6c42291c 100644

Lines of this file are not shown. View the raw message.

drivers/video/cfb_console.c +1 -1
index f54802052e..75d4388943 100644

Lines of this file are not shown. View the raw message.

drivers/video/ct69000.c +2 -1
index a74e4e6868..5148413773 100644

Lines of this file are not shown. View the raw message.

drivers/video/mb862xx.c +2 -1
index 1c74e97c5e..e0565e1d2e 100644

Lines of this file are not shown. View the raw message.

drivers/video/mx3fb.c +1 -1
index 51d06d6677..78e595ea4a 100644

Lines of this file are not shown. View the raw message.

drivers/video/mxsfb.c +1 -1
index 0ddce3db58..9d810bab31 100644

Lines of this file are not shown. View the raw message.

drivers/video/videomodes.c +3 -2
index cf71ad120e..6d96b33f20 100644

Lines of this file are not shown. View the raw message.

env/callback.c +1 -1
index 1957cc1996..be70980f04 100644

Lines of this file are not shown. View the raw message.

env/common.c +2 -2
index 0cc8829d0d..110323ecea 100644

Lines of this file are not shown. View the raw message.

env/flags.c +2 -2
index 3c50620cb3..8de532ea02 100644

Lines of this file are not shown. View the raw message.

fs/fs.c +2 -2
index 055dffdafd..13cd3626c6 100644

Lines of this file are not shown. View the raw message.

include/_exports.h +1 -1
index 9deed77378..5416041243 100644

Lines of this file are not shown. View the raw message.

include/asm-generic/global_data.h +1 -1
index 8b32d514c3..944f58195c 100644

Lines of this file are not shown. View the raw message.

include/common.h +25 -7
index fc4b57c139..b4caafc73f 100644

Lines of this file are not shown. View the raw message.

include/exports.h +1 -1
index 6522d78fac..ebe81d914c 100644

Lines of this file are not shown. View the raw message.

include/image.h +1 -1
index c6f1513220..c4fe4cfb8b 100644

Lines of this file are not shown. View the raw message.

lib/smbios.c +1 -1
index 22ca247fec..8f19ad89c1 100644

Lines of this file are not shown. View the raw message.

net/bootp.c +5 -5
index 579515687b..6c869ef856 100644

Lines of this file are not shown. View the raw message.

net/eth-uclass.c +3 -3
index d356576210..6051a6ab6f 100644

Lines of this file are not shown. View the raw message.

net/eth_common.c +7 -7
index 7b36532ee1..bde3b88322 100644

Lines of this file are not shown. View the raw message.

net/eth_legacy.c +1 -1
index 2608302648..5d29d3483b 100644

Lines of this file are not shown. View the raw message.

net/net.c +3 -3
index 2fed28092d..3fe18d7717 100644

Lines of this file are not shown. View the raw message.

net/tftp.c +5 -5
index ced45ec1f1..f498263376 100644

Lines of this file are not shown. View the raw message.

post/post.c +1 -1
index 8c2c822acb..8fef0c3412 100644

Lines of this file are not shown. View the raw message.

test/command_ut.c +8 -8
index 21283eb357..f76d52569d 100644

Lines of this file are not shown. View the raw message.

test/dm/eth.c +18 -18
index f824d704c6..122fab924d 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.14.0.rc0.400.g1c36432dff-goog

Part of the diff is not shown here. View the raw message.