summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2012-11-26 13:51:41 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2012-11-26 11:14:40 +0100
commit019d2474e892ad9e6be3ceccbb61798a423565a2 (patch)
tree5d469cb76fcbb35165560e94f4d1c8397e362e11 /commands
parent6552d2991ff5fb0d6632ab5dd91ac44be39d6992 (diff)
downloadbarebox-019d2474e892ad9e6be3ceccbb61798a423565a2.tar.gz
barebox-019d2474e892ad9e6be3ceccbb61798a423565a2.tar.xz
commands: mw: add the '-x' option (swap bytes)
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/mem.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/commands/mem.c b/commands/mem.c
index 9873e52832..51aa04daa2 100644
--- a/commands/mem.c
+++ b/commands/mem.c
@@ -255,9 +255,10 @@ static int do_mem_mw(int argc, char *argv[])
char *filename = DEVMEM;
int mode = O_RWSIZE_4;
loff_t adr;
+ int swab = 0;
- if (mem_parse_options(argc, argv, "bwld:", &mode, NULL, &filename,
- NULL) < 0)
+ if (mem_parse_options(argc, argv, "bwld:x", &mode, NULL, &filename,
+ &swab) < 0)
return 1;
if (optind + 1 >= argc)
@@ -280,10 +281,14 @@ static int do_mem_mw(int argc, char *argv[])
break;
case O_RWSIZE_2:
val16 = simple_strtoul(argv[optind], NULL, 0);
+ if (swab)
+ val16 = __swab16(val16);
ret = write(fd, &val16, 2);
break;
case O_RWSIZE_4:
val32 = simple_strtoul(argv[optind], NULL, 0);
+ if (swab)
+ val32 = __swab32(val32);
ret = write(fd, &val32, 4);
break;
}