diff options
author | Michal Simek <michal.simek@xilinx.com> | 2015-12-04 16:56:57 +0100 |
---|---|---|
committer | Michal Simek <michal.simek@xilinx.com> | 2015-12-07 10:14:30 +0100 |
commit | e4099c8b8053e7534cc50cdc8403792304eea973 (patch) | |
tree | 02d305ddf52c8af03ef99a9cc2c02624c8f9ac8b /common | |
parent | c643f3ef9b68a2444c9672bc7b72735a5b7855b0 (diff) | |
download | u-boot-imx-e4099c8b8053e7534cc50cdc8403792304eea973.zip u-boot-imx-e4099c8b8053e7534cc50cdc8403792304eea973.tar.gz u-boot-imx-e4099c8b8053e7534cc50cdc8403792304eea973.tar.bz2 |
i2c: cmd: Relocate subcommands when MANUAL_RELOC
Subcommands contain pointers to functions which are not updated when
MANUAL_RELOC is enabled. This patch fix it.
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Acked-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_i2c.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 3d0de81..552c875 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1944,11 +1944,15 @@ static cmd_tbl_t cmd_i2c_sub[] = { U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""), }; -#ifdef CONFIG_NEEDS_MANUAL_RELOC -void i2c_reloc(void) { - fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub)); +static __maybe_unused void i2c_reloc(void) +{ + static int relocated; + + if (!relocated) { + fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub)); + relocated = 1; + }; } -#endif /** * do_i2c() - Handle the "i2c" command-line command @@ -1964,6 +1968,10 @@ static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *c; +#ifdef CONFIG_NEEDS_MANUAL_RELOC + i2c_reloc(); +#endif + if (argc < 2) return CMD_RET_USAGE; |