From: Tobias Simon <tobias.simon@sp-ss.de>
To: linux-mtd@lists.infradead.org
Cc: joern@logfs.org
Subject: Re: flashcp
Date: Fri, 20 Jul 2007 01:23:46 +0200 [thread overview]
Message-ID: <200707200123.46618.tobias.simon@sp-ss.de> (raw)
In-Reply-To: <200707200055.29457.tobias.simon@sp-ss.de>
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
next prev parent reply other threads:[~2007-07-19 23:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-19 18:46 flashcp Tobias Simon
2007-07-19 19:56 ` flashcp Jörn Engel
2007-07-19 21:08 ` flashcp Tobias Simon
2007-07-19 22:13 ` flashcp Jörn Engel
2007-07-19 22:55 ` flashcp Tobias Simon
2007-07-19 23:23 ` Tobias Simon [this message]
2007-07-20 0:28 ` flashcp Jörn Engel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200707200123.46618.tobias.simon@sp-ss.de \
--to=tobias.simon@sp-ss.de \
--cc=joern@logfs.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox