public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] UBI: Change size of UBI commands to default to hex instead of decimal
@ 2008-11-21 18:08 Stefan Roese
  2008-11-21 19:28 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Roese @ 2008-11-21 18:08 UTC (permalink / raw)
  To: u-boot

Currently the size parameters of the UBI commands (e.g. "ubi write") are decoded as
decimal instead of hex as default. This patch now interprets all these values
consistantly as hex, as all other standard U-Boot commands do.

Signed-off-by: Stefan Roese <sr@denx.de>
---
This depends on the UBI patches v4 I sent a few days ago. Its available in the testing
branch of the u-boot-ubi repository.

 common/cmd_ubi.c |   36 ++++--------------------------------
 1 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/common/cmd_ubi.c b/common/cmd_ubi.c
index 18091b0..6b4a1fa 100644
--- a/common/cmd_ubi.c
+++ b/common/cmd_ubi.c
@@ -30,6 +30,7 @@
 
 /* Private own data */
 static struct ubi_device *ubi;
+static char buffer[80];
 
 struct selected_dev {
 	char dev_name[32];	/* NAND/OneNAND etc */
@@ -114,19 +115,6 @@ static int ubi_info(int layout)
 	return 0;
 }
 
-static int parse_num(size_t *num, const char *token)
-{
-        char *endp;
-        size_t n;
-
-        n = (size_t) ustrtoul(token, &endp, 0);
-        if (*endp)
-                return -EINVAL;
-
-        *num = n;
-        return 0;
-}
-
 static int verify_mkvol_req(const struct ubi_device *ubi,
 			    const struct ubi_mkvol_req *req)
 {
@@ -379,7 +367,6 @@ static int ubi_volume_read(char *volume, char *buf, size_t size)
 	tmp = offp;
 	off = do_div(tmp, vol->usable_leb_size);
 	lnum = tmp;
-	printf("off=%d lnum=%d\n", off, lnum);
 	do {
 		if (off + len >= vol->usable_leb_size)
 			len = vol->usable_leb_size - off;
@@ -398,9 +385,7 @@ static int ubi_volume_read(char *volume, char *buf, size_t size)
 		size -= len;
 		offp += len;
 
-		printf("buf = %x\n", (unsigned)buf);
 		memcpy(buf, tbuf, len);
-		printf("buf[0] = %x\n", buf[0]);
 
 		buf += len;
 		len = size > tbuf_size ? tbuf_size : size;
@@ -415,7 +400,6 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev)
 	struct mtd_device *dev;
 	struct part_info *part;
 	struct mtd_partition mtd_part;
-	char buffer[32];
 	u8 pnum;
 	int err;
 
@@ -549,11 +533,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		}
 		/* E.g., create volume size */
 		if (argc == 4) {
-			err = parse_num(&size, argv[3]);
-			if (err) {
-				printf("Incorrect type\n");
-				return err;
-			}
+			addr = simple_strtoul(argv[3], NULL, 16);
 			argc--;
 		}
 		/* Use maximum available size */
@@ -577,11 +557,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 		}
 
 		addr = simple_strtoul(argv[2], NULL, 16);
-		err = parse_num(&size, argv[4]);
-		if (err) {
-			printf("Please see usage\n");
-			return err;
-		}
+		size = simple_strtoul(argv[4], NULL, 16);
 
 		return ubi_volume_write(argv[3], (void *)addr, size);
 	}
@@ -591,11 +567,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 
 		/* E.g., read volume size */
 		if (argc == 5) {
-			err = parse_num(&size, argv[4]);
-			if (err) {
-				printf("Please see usage\n");
-				return err;
-			}
+			size = simple_strtoul(argv[4], NULL, 16);
 			argc--;
 		}
 
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] UBI: Change size of UBI commands to default to hex instead of decimal
  2008-11-21 18:08 [U-Boot] [PATCH] UBI: Change size of UBI commands to default to hex instead of decimal Stefan Roese
@ 2008-11-21 19:28 ` Wolfgang Denk
  2008-11-24  7:31   ` Stefan Roese
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2008-11-21 19:28 UTC (permalink / raw)
  To: u-boot


In message <1227290884-7993-1-git-send-email-sr@denx.de> you wrote:
> Currently the size parameters of the UBI commands (e.g. "ubi write") are decoded as
> decimal instead of hex as default. This patch now interprets all these values
> consistantly as hex, as all other standard U-Boot commands do.

You may want to rephrase the Subject a bit. For me "Change size of UBI
commands" is not what you actually mean (changing the parsing of the
size parameter).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The use of anthropomorphic terminology when  dealing  with  computing
systems is a symptom of professional immaturity.   -- Edsger Dijkstra

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] UBI: Change size of UBI commands to default to hex instead of decimal
  2008-11-21 19:28 ` Wolfgang Denk
@ 2008-11-24  7:31   ` Stefan Roese
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2008-11-24  7:31 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang,

On Friday 21 November 2008, Wolfgang Denk wrote:
> In message <1227290884-7993-1-git-send-email-sr@denx.de> you wrote:
> > Currently the size parameters of the UBI commands (e.g. "ubi write") are
> > decoded as decimal instead of hex as default. This patch now interprets
> > all these values consistantly as hex, as all other standard U-Boot
> > commands do.
>
> You may want to rephrase the Subject a bit. For me "Change size of UBI
> commands" is not what you actually mean (changing the parsing of the
> size parameter).

OK, I'll resend a patch with a modified subject directly.

Best regards,
Stefan

=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-24  7:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-21 18:08 [U-Boot] [PATCH] UBI: Change size of UBI commands to default to hex instead of decimal Stefan Roese
2008-11-21 19:28 ` Wolfgang Denk
2008-11-24  7:31   ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox