]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: handle non-power-of-2 erase size
authorPeter Korsgaard <jacmet@sunsite.dk>
Tue, 17 Feb 2009 14:03:40 +0000 (15:03 +0100)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 17 Feb 2009 17:16:01 +0000 (19:16 +0200)
E.g., this is needed for DataFlash.

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

index 7f7764a6d9f72f58f1d96667f09f6d5a1479f897..877502218429ab0b1fbf11cd9e8fdc51f6d1c06b 100644 (file)
--- a/flashcp.c
+++ b/flashcp.c
@@ -255,8 +255,9 @@ int main (int argc,char *argv[])
 #warning "Check for smaller erase regions"
 
        erase.start = 0;
-       erase.length = filestat.st_size & ~(mtd.erasesize - 1);
-       if (filestat.st_size % mtd.erasesize) erase.length += mtd.erasesize;
+       erase.length = (filestat.st_size + mtd.erasesize - 1) / mtd.erasesize;
+       erase.length *= mtd.erasesize;
+
        if (flags & FLAG_VERBOSE)
        {
                /* if the user wants verbose output, erase 1 block at a time and show him/her what's going on */