Am 01.06.2016 um 11:05 schrieb Boris Brezillon:
Add error messages explaining what is wrong or missing in the arguments
passed by to the sunxi-nand-image-builder tool.
Signed-off-by: Boris Brezillon <boris.brezil...@free-electrons.com>
---
nand-image-builder.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/nand-image-builder.c b/nand-image-builder.c
index 34eee4f..d3d3f64 100644
--- a/nand-image-builder.c
+++ b/nand-image-builder.c
@@ -938,20 +938,37 @@ static int check_image_info(struct image_info *info)
int eccbytes, eccsteps;
unsigned i;
- if (!info->page_size || !info->oob_size || !info->eraseblock_size ||
- !info->usable_page_size)
+ if (!info->page_size) {
+ fprintf(stderr, "--page-size is missing\n");
return -EINVAL;
+ }
+
+ if (!info->page_size) {
+ fprintf(stderr, "--oob-size is missing\n");
+ return -EINVAL;
+ }
+
+ if (!info->eraseblock_size) {
+ fprintf(stderr, "--eraseblock-size is missing\n");
+ return -EINVAL;
+ }
- if (info->ecc_step_size != 512 && info->ecc_step_size != 1024)
+ if (info->ecc_step_size != 512 && info->ecc_step_size != 1024) {
+ fprintf(stderr, "Invalid ECC step argument: %d\n",
+ info->ecc_step_size);
return -EINVAL;
+ }
for (i = 0; i < ARRAY_SIZE(valid_ecc_strengths); i++) {
if (valid_ecc_strengths[i] == info->ecc_strength)
break;
}
- if (i == ARRAY_SIZE(valid_ecc_strengths))
+ if (i == ARRAY_SIZE(valid_ecc_strengths)) {
+ fprintf(stderr, "Invalid ECC strength argument: %d\n",
+ info->ecc_strength);
return -EINVAL;
+ }
eccbytes = DIV_ROUND_UP(info->ecc_strength * 14, 8);
if (eccbytes % 2)
@@ -961,8 +978,11 @@ static int check_image_info(struct image_info *info)
eccsteps = info->usable_page_size / info->ecc_step_size;
if (info->page_size + info->oob_size <
- info->usable_page_size + (eccsteps * (eccbytes)))
+ info->usable_page_size + (eccsteps * (eccbytes))) {
When changing that line, please strip the surplus braces around `eccbytes`.
+ fprintf(stderr,
+ "ECC bytes do not fit in the NAND page, choose a weaker
ECC\n");
return -EINVAL;
+ }
return 0;
}
Apart from the nitpick above
Acked-by: Bernhard Nortmann <bernhard.nortm...@web.de>
--
You received this message because you are subscribed to the Google Groups
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to linux-sunxi+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.