Commit e4099c8b8053e7534cc50cdc8403792304eea973
1 parent
c643f3ef9b
Exists in
v2017.01-smarct4x
and in
30 other branches
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>
Showing 1 changed file with 12 additions and 4 deletions Side-by-side Diff
common/cmd_i2c.c
... | ... | @@ -1944,11 +1944,15 @@ |
1944 | 1944 | U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""), |
1945 | 1945 | }; |
1946 | 1946 | |
1947 | -#ifdef CONFIG_NEEDS_MANUAL_RELOC | |
1948 | -void i2c_reloc(void) { | |
1949 | - fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub)); | |
1947 | +static __maybe_unused void i2c_reloc(void) | |
1948 | +{ | |
1949 | + static int relocated; | |
1950 | + | |
1951 | + if (!relocated) { | |
1952 | + fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub)); | |
1953 | + relocated = 1; | |
1954 | + }; | |
1950 | 1955 | } |
1951 | -#endif | |
1952 | 1956 | |
1953 | 1957 | /** |
1954 | 1958 | * do_i2c() - Handle the "i2c" command-line command |
... | ... | @@ -1963,6 +1967,10 @@ |
1963 | 1967 | static int do_i2c(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) |
1964 | 1968 | { |
1965 | 1969 | cmd_tbl_t *c; |
1970 | + | |
1971 | +#ifdef CONFIG_NEEDS_MANUAL_RELOC | |
1972 | + i2c_reloc(); | |
1973 | +#endif | |
1966 | 1974 | |
1967 | 1975 | if (argc < 2) |
1968 | 1976 | return CMD_RET_USAGE; |