summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-03-05 12:25:18 -0700
committerSimon Glass <sjg@chromium.org>2015-04-16 19:27:41 -0600
commitcc5e196e0350055e3e438d5dc2341316027c8d93 (patch)
tree0da94e5896c41e059640886b8ad659759750e265
parent161d2e4e5b98310c4910a353e432dbabcb1bd630 (diff)
downloadu-boot-imx-cc5e196e0350055e3e438d5dc2341316027c8d93.zip
u-boot-imx-cc5e196e0350055e3e438d5dc2341316027c8d93.tar.gz
u-boot-imx-cc5e196e0350055e3e438d5dc2341316027c8d93.tar.bz2
Correct map_sysmem() logic in do_mem_mw()
This function does not unmap what it maps. Correct it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
-rw-r--r--common/cmd_mem.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 3f85c1a..1cbf84f 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -165,7 +165,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif
ulong addr, count;
int size;
- void *buf;
+ void *buf, *start;
ulong bytes;
if ((argc < 3) || (argc > 4))
@@ -197,7 +197,8 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
bytes = size * count;
- buf = map_sysmem(addr, bytes);
+ start = map_sysmem(addr, bytes);
+ buf = start;
while (count-- > 0) {
if (size == 4)
*((u32 *)buf) = (u32)writeval;
@@ -211,7 +212,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*((u8 *)buf) = (u8)writeval;
buf += size;
}
- unmap_sysmem(buf);
+ unmap_sysmem(start);
return 0;
}