summaryrefslogtreecommitdiff
path: root/flashcp.c
diff options
context:
space:
mode:
authorPeter Korsgaard <jacmet@sunsite.dk>2009-02-17 15:03:40 +0100
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-02-17 19:16:01 +0200
commit5eceb74f70c535e2c22d3d5be1625a0c8a8e38ea (patch)
tree3dc83919439e69236d3a150b6724482a6a053b1d /flashcp.c
parent6bd4de4228044315d4271af58761792aef762ac9 (diff)
mtd-utils: handle non-power-of-2 erase size
E.g., this is needed for DataFlash. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'flashcp.c')
-rw-r--r--flashcp.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/flashcp.c b/flashcp.c
index 7f7764a..8775022 100644
--- 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 */