]> www.infradead.org Git - mtd-utils.git/commitdiff
flash_erase: start position should be in bytes
authorPeter Korsgaard <jacmet@sunsite.dk>
Fri, 18 Mar 2011 10:21:57 +0000 (11:21 +0100)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 18 Mar 2011 10:52:44 +0000 (12:52 +0200)
Commit a8801d8 (unify flash_erase and flash_eraseall) changed the
flash_erase interface in a backwards incompatible way. Before that
commit start position was given in bytes, and now it must be provided
in blocks.

While I agree the new interface is nicer, we shouldn't break the
interface. I have scripts that expect the old behaviour, and I'm
most likely not alone, so change the interface back to the old
way.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
flash_erase.c

index 1a7b52ef15e260a15eb5a7c5492babfb1ad3666c..3ce701b4c84cf762e4f66629b7fdfe4c82b4f7d2 100644 (file)
@@ -60,7 +60,7 @@ static void show_progress(struct mtd_dev_info *mtd, uint64_t start, int eb,
 
 static void display_help (void)
 {
-       printf("Usage: %s [options] MTD_DEVICE <start block> <block count>\n"
+       printf("Usage: %s [options] MTD_DEVICE <start offset> <block count>\n"
                        "Erase blocks of the specified MTD device.\n"
                        "Specify a count of 0 to erase to end of device.\n"
                        "\n"
@@ -94,6 +94,7 @@ int main(int argc, char *argv[])
        libmtd_t mtd_desc;
        struct mtd_dev_info mtd;
        int fd, clmpos = 0, clmlen = 8;
+       unsigned long long start;
        unsigned int eb, eb_start, eb_cnt;
        int isNAND;
        int error = 0;
@@ -153,7 +154,7 @@ int main(int argc, char *argv[])
        switch (argc - optind) {
        case 3:
                mtd_device = argv[optind];
-               eb_start = simple_strtoul(argv[optind + 1], &error);
+               start = simple_strtoull(argv[optind + 1], &error);
                eb_cnt = simple_strtoul(argv[optind + 2], &error);
                break;
        default:
@@ -182,6 +183,8 @@ int main(int argc, char *argv[])
        if (mtd_get_dev_info(mtd_desc, mtd_device, &mtd) < 0)
                return errmsg("mtd_get_dev_info failed");
 
+       eb_start = start / mtd.eb_size;
+
        isNAND = mtd.type == MTD_NANDFLASH ? 1 : 0;
 
        if (jffs2) {