aboutsummaryrefslogtreecommitdiff
path: root/common/cmd_onenand.c
diff options
context:
space:
mode:
authorHeiko Schocher2015-04-27 07:42:05 +0200
committerJagan Teki2015-06-30 00:40:11 +0530
commit09c3280754f8f68a4d7fc0ee397a92b38c4f59e4 (patch)
tree689e7996e2475d0199f9b16dc66009457dd66b6a /common/cmd_onenand.c
parent9fe6d8716e090f3b2dd3f4604acfced124b8a2fc (diff)
mtd, nand: Move common functions from cmd_nand.c to common place
Move common functions from cmd_nand.c (for calculating offset and size from cmdline paramter) to common place, so they could used from other commands which use mtd partitions. For onenand the arg_off_size() is left in common/cmd_onenand.c. It should use now the common arg_off() function, but as I could not test onenand I let it there ... Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Scott Wood <scottwood@freescale.com> Reviewed-by: Jagannadh Teki <jteki@openedev.com>
Diffstat (limited to 'common/cmd_onenand.c')
-rw-r--r--common/cmd_onenand.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c
index 06cc1405675..feab01a71e3 100644
--- a/common/cmd_onenand.c
+++ b/common/cmd_onenand.c
@@ -24,15 +24,8 @@ static struct mtd_info *mtd;
static loff_t next_ofs;
static loff_t skip_ofs;
-static inline int str2long(char *p, ulong *num)
-{
- char *endptr;
-
- *num = simple_strtoul(p, &endptr, 16);
- return (*p != '\0' && *endptr == '\0') ? 1 : 0;
-}
-
-static int arg_off_size(int argc, char * const argv[], ulong *off, size_t *size)
+static int arg_off_size_onenand(int argc, char * const argv[], ulong *off,
+ size_t *size)
{
if (argc >= 1) {
if (!(str2long(argv[0], off))) {
@@ -399,7 +392,7 @@ static int do_onenand_read(cmd_tbl_t * cmdtp, int flag, int argc, char * const a
addr = (ulong)simple_strtoul(argv[1], NULL, 16);
printf("\nOneNAND read: ");
- if (arg_off_size(argc - 2, argv + 2, &ofs, &len) != 0)
+ if (arg_off_size_onenand(argc - 2, argv + 2, &ofs, &len) != 0)
return 1;
ret = onenand_block_read(ofs, len, &retlen, (u8 *)addr, oob);
@@ -425,7 +418,7 @@ static int do_onenand_write(cmd_tbl_t * cmdtp, int flag, int argc, char * const
addr = (ulong)simple_strtoul(argv[1], NULL, 16);
printf("\nOneNAND write: ");
- if (arg_off_size(argc - 2, argv + 2, &ofs, &len) != 0)
+ if (arg_off_size_onenand(argc - 2, argv + 2, &ofs, &len) != 0)
return 1;
ret = onenand_block_write(ofs, len, &retlen, (u8 *)addr, withoob);
@@ -461,7 +454,7 @@ static int do_onenand_erase(cmd_tbl_t * cmdtp, int flag, int argc, char * const
printf("\nOneNAND erase: ");
/* skip first two or three arguments, look for offset and size */
- if (arg_off_size(argc, argv, &ofs, &len) != 0)
+ if (arg_off_size_onenand(argc, argv, &ofs, &len) != 0)
return 1;
ret = onenand_block_erase(ofs, len, force);
@@ -486,7 +479,7 @@ static int do_onenand_test(cmd_tbl_t * cmdtp, int flag, int argc, char * const a
printf("\nOneNAND test: ");
/* skip first two or three arguments, look for offset and size */
- if (arg_off_size(argc - 1, argv + 1, &ofs, &len) != 0)
+ if (arg_off_size_onenand(argc - 1, argv + 1, &ofs, &len) != 0)
return 1;
ret = onenand_block_test(ofs, len);