flashcp
Tobias Simon
tobias.simon at sp-ss.de
Thu Jul 19 19:23:46 EDT 2007
Hello Jörn,
I just saw the following line, which is part of the original source:
"if (filestat.st_size % mtd.erasesize) erase.length += mtd.erasesize;"
So either this line could be deleted (when using my last patch):
--- flashcp_old.c 2007-07-20 01:15:28.000000000 +0200
+++ flashcp_a.c 2007-07-20 01:16:48.000000000 +0200
@@ -257,9 +257,15 @@
#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;
- if (flags & FLAG_VERBOSE)
+
+ if (filestat.st_size % mtd.erasesize) {
+ erase.length = filestat.st_size + mtd.erasesize - (filestat.st_size %
mtd.erasesize);
+ }
+ else {
+ erase.length = filestat.st_size;
+ }
+
+ if (flags & FLAG_VERBOSE)
{
/* if the user wants verbose output, erase 1 block at a time
and show him/her what's going on */
int blocks = erase.length / mtd.erasesize;
... or left there in conjunction with your "rounding down" code:
--- flashcp_old.c 2007-07-20 01:15:28.000000000 +0200
+++ flashcp_b.c 2007-07-20 01:14:02.000000000 +0200
@@ -257,9 +257,12 @@
#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;
- if (flags & FLAG_VERBOSE)
+
+ erase.length = (filestat.st_size / mtd.erasesize) * mtd.erasesize;
+ if (filestat.st_size % 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 */
int blocks = erase.length / mtd.erasesize;
I prefer the second patch, because it's easier to understand.
Best Regards,
Tobias
More information about the linux-mtd
mailing list