[U-Boot] [PATCH 11/39] env: Move env_set_hex() to env.h

Simon Glass sjg at chromium.org
Sun Jul 28 14:03:28 UTC 2019


Move env_set_hex() over to the new header file along with env_set_addr()
which uses it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 api/api.c                                   |  1 +
 arch/arm/mach-tegra/cboot.c                 |  1 +
 arch/arm/mach-uniphier/board_late_init.c    |  1 +
 board/BuR/common/common.c                   |  1 +
 board/boundary/nitrogen6x/nitrogen6x.c      |  1 +
 board/broadcom/bcmstb/bcmstb.c              |  1 +
 board/emulation/qemu-riscv/qemu-riscv.c     |  1 +
 board/freescale/qemu-ppce500/qemu-ppce500.c |  1 +
 board/raspberrypi/rpi/rpi.c                 |  1 +
 board/sunxi/board.c                         |  1 +
 board/xilinx/zynqmp/cmds.c                  |  1 +
 cmd/cbfs.c                                  |  1 +
 cmd/cramfs.c                                |  1 +
 cmd/fdt.c                                   |  1 +
 cmd/jffs2.c                                 |  1 +
 cmd/load.c                                  |  1 +
 cmd/lzmadec.c                               |  1 +
 cmd/nand.c                                  |  1 +
 cmd/reiser.c                                |  1 +
 cmd/setexpr.c                               |  1 +
 cmd/spl.c                                   |  1 +
 cmd/tpm-v1.c                                |  1 +
 cmd/trace.c                                 |  1 +
 cmd/ubi.c                                   |  1 +
 cmd/unzip.c                                 |  1 +
 cmd/ximg.c                                  |  1 +
 cmd/zfs.c                                   |  1 +
 cmd/zip.c                                   |  1 +
 common/autoboot.c                           |  1 +
 common/bootm.c                              |  1 +
 common/bootm_os.c                           |  1 +
 drivers/fastboot/fb_command.c               |  1 +
 drivers/net/fm/fm.c                         |  1 +
 drivers/usb/gadget/f_sdp.c                  |  1 +
 fs/fs.c                                     |  1 +
 fs/ubifs/ubifs.c                            |  1 +
 include/common.h                            | 21 --------------------
 include/env.h                               | 22 +++++++++++++++++++++
 net/net.c                                   |  1 +
 39 files changed, 59 insertions(+), 21 deletions(-)

diff --git a/api/api.c b/api/api.c
index 9f03f1a35b..8a41b7cce7 100644
--- a/api/api.c
+++ b/api/api.c
@@ -8,6 +8,7 @@
 #include <config.h>
 #include <command.h>
 #include <common.h>
+#include <env.h>
 #include <malloc.h>
 #include <environment.h>
 #include <linux/types.h>
diff --git a/arch/arm/mach-tegra/cboot.c b/arch/arm/mach-tegra/cboot.c
index a829ef794f..bd4f33686d 100644
--- a/arch/arm/mach-tegra/cboot.c
+++ b/arch/arm/mach-tegra/cboot.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <environment.h>
 #include <fdt_support.h>
 #include <fdtdec.h>
diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c
index 3180b24330..14b61fc7df 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -6,6 +6,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <spl.h>
 #include <linux/libfdt.h>
 #include <nand.h>
diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c
index 89087d7dba..148fc9075e 100644
--- a/board/BuR/common/common.c
+++ b/board/BuR/common/common.c
@@ -10,6 +10,7 @@
  */
 #include <version.h>
 #include <common.h>
+#include <env.h>
 #include <fdtdec.h>
 #include <i2c.h>
 #include <lcd.h>
diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c
index 867eade4bd..26af3f7102 100644
--- a/board/boundary/nitrogen6x/nitrogen6x.c
+++ b/board/boundary/nitrogen6x/nitrogen6x.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
diff --git a/board/broadcom/bcmstb/bcmstb.c b/board/broadcom/bcmstb/bcmstb.c
index 7f8e0f951d..5fc2c0591b 100644
--- a/board/broadcom/bcmstb/bcmstb.c
+++ b/board/broadcom/bcmstb/bcmstb.c
@@ -8,6 +8,7 @@
 
 #include <linux/types.h>
 #include <common.h>
+#include <env.h>
 #include <asm/io.h>
 #include <asm/bootm.h>
 #include <mach/timer.h>
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
index d6167aaef1..49e304f7eb 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <env.h>
 #include <fdtdec.h>
 #include <virtio_types.h>
 #include <virtio.h>
diff --git a/board/freescale/qemu-ppce500/qemu-ppce500.c b/board/freescale/qemu-ppce500/qemu-ppce500.c
index 42a6b5427a..fb36d8366c 100644
--- a/board/freescale/qemu-ppce500/qemu-ppce500.c
+++ b/board/freescale/qemu-ppce500/qemu-ppce500.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <pci.h>
 #include <asm/processor.h>
 #include <asm/mmu.h>
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 617c892dde..104589bff1 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -6,6 +6,7 @@
 #include <common.h>
 #include <config.h>
 #include <dm.h>
+#include <env.h>
 #include <environment.h>
 #include <efi_loader.h>
 #include <fdt_support.h>
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 98bc3cd0c1..bb425cbf66 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -12,6 +12,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <env.h>
 #include <mmc.h>
 #include <axp_pmic.h>
 #include <generic-phy.h>
diff --git a/board/xilinx/zynqmp/cmds.c b/board/xilinx/zynqmp/cmds.c
index 321670d4e3..ed7ba58c64 100644
--- a/board/xilinx/zynqmp/cmds.c
+++ b/board/xilinx/zynqmp/cmds.c
@@ -5,6 +5,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <malloc.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index c118a952ac..3d1fc95972 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -8,6 +8,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <cbfs.h>
 
 static int do_cbfs_init(cmd_tbl_t *cmdtp, int flag, int argc,
diff --git a/cmd/cramfs.c b/cmd/cramfs.c
index 598028cfad..2188910b2a 100644
--- a/cmd/cramfs.c
+++ b/cmd/cramfs.c
@@ -12,6 +12,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <linux/list.h>
diff --git a/cmd/fdt.c b/cmd/fdt.c
index 10d8f3230b..25a6ed40d2 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -9,6 +9,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <linux/ctype.h>
 #include <linux/types.h>
 #include <asm/global_data.h>
diff --git a/cmd/jffs2.c b/cmd/jffs2.c
index 64621f2546..b47cd3d989 100644
--- a/cmd/jffs2.c
+++ b/cmd/jffs2.c
@@ -72,6 +72,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <malloc.h>
 #include <jffs2/jffs2.h>
 #include <linux/list.h>
diff --git a/cmd/load.c b/cmd/load.c
index dd1e8dac13..713fe56b55 100644
--- a/cmd/load.c
+++ b/cmd/load.c
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <command.h>
 #include <console.h>
+#include <env.h>
 #include <s_record.h>
 #include <net.h>
 #include <exports.h>
diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c
index 6860b5f758..e3b9cc75ac 100644
--- a/cmd/lzmadec.c
+++ b/cmd/lzmadec.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <mapmem.h>
 #include <asm/io.h>
 
diff --git a/cmd/nand.c b/cmd/nand.c
index 899d504533..27efef20bc 100644
--- a/cmd/nand.c
+++ b/cmd/nand.c
@@ -23,6 +23,7 @@
 #include <linux/mtd/mtd.h>
 #include <command.h>
 #include <console.h>
+#include <env.h>
 #include <watchdog.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
diff --git a/cmd/reiser.c b/cmd/reiser.c
index 2c0bca1c54..7f51b927a4 100644
--- a/cmd/reiser.c
+++ b/cmd/reiser.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <config.h>
 #include <command.h>
+#include <env.h>
 #include <image.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index 1a6cecdeda..0182f19938 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -11,6 +11,7 @@
 #include <common.h>
 #include <config.h>
 #include <command.h>
+#include <env.h>
 #include <mapmem.h>
 
 static ulong get_arg(char *s, int w)
diff --git a/cmd/spl.c b/cmd/spl.c
index 038f48818d..56051b8a4b 100644
--- a/cmd/spl.c
+++ b/cmd/spl.c
@@ -7,6 +7,7 @@
 #include <common.h>
 #include <command.h>
 #include <cmd_spl.h>
+#include <env.h>
 #include <linux/libfdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
diff --git a/cmd/tpm-v1.c b/cmd/tpm-v1.c
index b75e0933a1..2807331524 100644
--- a/cmd/tpm-v1.c
+++ b/cmd/tpm-v1.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <malloc.h>
 #include <asm/unaligned.h>
 #include <tpm-common.h>
diff --git a/cmd/trace.c b/cmd/trace.c
index 7d328f88be..392b129536 100644
--- a/cmd/trace.c
+++ b/cmd/trace.c
@@ -5,6 +5,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <mapmem.h>
 #include <trace.h>
 #include <asm/io.h>
diff --git a/cmd/ubi.c b/cmd/ubi.c
index c511a2fb76..ca5dc9021b 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -13,6 +13,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <exports.h>
 #include <memalign.h>
 #include <mtd.h>
diff --git a/cmd/unzip.c b/cmd/unzip.c
index 8474d9becf..afd58e7cdb 100644
--- a/cmd/unzip.c
+++ b/cmd/unzip.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <gzip.h>
 
 static int do_unzip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
diff --git a/cmd/ximg.c b/cmd/ximg.c
index 920a80edc8..a9481004f0 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -13,6 +13,7 @@
  */
 #include <common.h>
 #include <command.h>
+#include <env.h>
 #include <gzip.h>
 #include <image.h>
 #include <mapmem.h>
diff --git a/cmd/zfs.c b/cmd/zfs.c
index 384ac4c939..ed5402bb13 100644
--- a/cmd/zfs.c
+++ b/cmd/zfs.c
@@ -12,6 +12,7 @@
 #include <part.h>
 #include <config.h>
 #include <command.h>
+#include <env.h>
 #include <image.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
diff --git a/cmd/zip.c b/cmd/zip.c
index 9cd400a7e8..8ef46e9815 100644
--- a/cmd/zip.c
+++ b/cmd/zip.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <command.h>
+#include <env.h>
 
 static int do_zip(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/common/autoboot.c b/common/autoboot.c
index 94133eaeda..6201f0f17b 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -9,6 +9,7 @@
 #include <bootretry.h>
 #include <cli.h>
 #include <console.h>
+#include <env.h>
 #include <fdtdec.h>
 #include <menu.h>
 #include <post.h>
diff --git a/common/bootm.c b/common/bootm.c
index 2cd47f96c8..da554f4cb1 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <bootstage.h>
 #include <bzlib.h>
+#include <env.h>
 #include <errno.h>
 #include <fdt_support.h>
 #include <gzip.h>
diff --git a/common/bootm_os.c b/common/bootm_os.c
index 855c471c28..6fb7d658da 100644
--- a/common/bootm_os.c
+++ b/common/bootm_os.c
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <bootm.h>
+#include <env.h>
 #include <fdt_support.h>
 #include <linux/libfdt.h>
 #include <malloc.h>
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 200f9910c5..4864344853 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <fastboot.h>
 #include <fastboot-internal.h>
 #include <fb_mmc.h>
diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index 0a43dfe74e..ce0f1678fd 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -4,6 +4,7 @@
  *	Dave Liu <daveliu at freescale.com>
  */
 #include <common.h>
+#include <env.h>
 #include <malloc.h>
 #include <asm/io.h>
 #include <linux/errno.h>
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index fab7ce6f97..bcd1c5d47c 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -19,6 +19,7 @@
 #include <errno.h>
 #include <common.h>
 #include <console.h>
+#include <env.h>
 #include <malloc.h>
 
 #include <linux/usb/ch9.h>
diff --git a/fs/fs.c b/fs/fs.c
index 48d8f1f6da..d8a4ced469 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -6,6 +6,7 @@
 #include <config.h>
 #include <errno.h>
 #include <common.h>
+#include <env.h>
 #include <mapmem.h>
 #include <part.h>
 #include <ext4fs.h>
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index 72e8a24d3b..67a0e8caae 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -12,6 +12,7 @@
  */
 
 #include <common.h>
+#include <env.h>
 #include <gzip.h>
 #include <memalign.h>
 #include "ubifs.h"
diff --git a/include/common.h b/include/common.h
index 26ec18ded4..100eac6e5e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -209,27 +209,6 @@ int env_set(const char *varname, const char *value);
  */
 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 env_set_addr(const char *varname, const void *addr)
-{
-	return env_set_hex(varname, (ulong)addr);
-}
-
 void	pci_init_board(void);
 
 /* common/exports.c */
diff --git a/include/env.h b/include/env.h
index bf34ac3f86..5c780f30d6 100644
--- a/include/env.h
+++ b/include/env.h
@@ -10,6 +10,7 @@
 #define __ENV_H
 
 #include <stdbool.h>
+#include <linux/types.h>
 
 /**
  * env_get_id() - Gets a sequence number for the environment
@@ -62,6 +63,27 @@ int env_match(unsigned char *name, int index);
  */
 int env_get_f(const char *name, char *buf, unsigned int len);
 
+/**
+ * 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 env_set_addr(const char *varname, const void *addr)
+{
+	return env_set_hex(varname, (ulong)addr);
+}
+
 /**
  * env_complete() - return an auto-complete for environment variables
  *
diff --git a/net/net.c b/net/net.c
index 58b0417cbe..1a175c4597 100644
--- a/net/net.c
+++ b/net/net.c
@@ -90,6 +90,7 @@
 #include <common.h>
 #include <command.h>
 #include <console.h>
+#include <env.h>
 #include <environment.h>
 #include <errno.h>
 #include <net.h>
-- 
2.22.0.709.g102302147b-goog



More information about the U-Boot mailing list