From: stefani@seibold.net
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
Artem Bityutskiy <Artem.Bityutskiy@nokia.com>,
linux-mtd@lists.infradead.org,
David Woodhouse <David.Woodhouse@intel.com>,
Artem Bityutskiy <dedekind1@gmail.com>
Cc: stefani@seibold.net
Subject: [PATCH] Add quick erase format option
Date: Mon, 9 Aug 2010 10:25:53 +0200 [thread overview]
Message-ID: <1281342353-18180-1-git-send-email-stefani@seibold.net> (raw)
From: Stefani Seibold <stefani@seibold.net>
This patch add a quick format option which skips erasing of already erased
flash blocks. This is useful for first time production environments where
the flash arrived erased.
Signed-off-by: Stefani Seibold <stefani@seibold.net>
---
ubi-utils/src/ubiformat.c | 29 ++++++++++++++++++++++++++---
1 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/ubi-utils/src/ubiformat.c b/ubi-utils/src/ubiformat.c
index 4e27e4f..8e33334 100644
--- a/ubi-utils/src/ubiformat.c
+++ b/ubi-utils/src/ubiformat.c
@@ -45,7 +45,7 @@
#include "common.h"
#include "ubiutils-common.h"
-#define PROGRAM_VERSION "1.5"
+#define PROGRAM_VERSION "1.6"
#define PROGRAM_NAME "ubiformat"
/* The variables below are set by command line arguments */
@@ -55,6 +55,7 @@ struct args {
unsigned int verbose:1;
unsigned int override_ec:1;
unsigned int novtbl:1;
+ unsigned int quick:1;
unsigned int manual_subpage;
int subpage_size;
int vid_hdr_offs;
@@ -94,6 +95,7 @@ static const char *optionsstr =
" (default is 1)\n"
"-Q, --image-seq=<num> 32-bit UBI image sequence number to use\n"
" (by default a random number is picked)\n"
+"-E, --erase-quick erase only used blocks\n"
"-y, --yes assume the answer is \"yes\" for all question\n"
" this program would otherwise ask\n"
"-q, --quiet suppress progress percentage information\n"
@@ -125,6 +127,7 @@ static const struct option long_options[] = {
{ .name = "ubi-ver", .has_arg = 1, .flag = NULL, .val = 'x' },
{ .name = "help", .has_arg = 0, .flag = NULL, .val = 'h' },
{ .name = "version", .has_arg = 0, .flag = NULL, .val = 'V' },
+ { .name = "erase-quick", .has_arg = 0, .flag = NULL, .val = 'E' },
{ NULL, 0, NULL, 0},
};
@@ -138,7 +141,7 @@ static int parse_opt(int argc, char * const argv[])
char *endp;
unsigned long int image_seq;
- key = getopt_long(argc, argv, "nh?Vyqve:x:s:O:f:S:", long_options, NULL);
+ key = getopt_long(argc, argv, "nh?Vyqve:x:s:O:f:S:E", long_options, NULL);
if (key == -1)
break;
@@ -202,6 +205,10 @@ static int parse_opt(int argc, char * const argv[])
break;
+ case 'E':
+ args.quick = 1;
+ break;
+
case 'v':
args.verbose = 1;
break;
@@ -600,7 +607,20 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
ec = si->ec[eb] + 1;
else
ec = si->mean_ec;
- ubigen_init_ec_hdr(ui, hdr, ec);
+
+ if (args.quick) {
+ err = mtd_read(mtd, args.node_fd, eb, 0, hdr, write_size);
+ if (!err) {
+ int i;
+
+ for(i = 0; i != write_size; i++) {
+ if (((unsigned char *)hdr)[i] != 0xff)
+ break;
+ }
+ if (i == write_size)
+ goto skip_erase;
+ }
+ }
if (args.verbose) {
normsg_cont("eraseblock %d: erase", eb);
@@ -621,6 +641,9 @@ static int format(libmtd_t libmtd, const struct mtd_dev_info *mtd,
continue;
}
+skip_erase:
+ ubigen_init_ec_hdr(ui, hdr, ec);
+
if ((eb1 == -1 || eb2 == -1) && !novtbl) {
if (eb1 == -1) {
eb1 = eb;
--
1.7.2
next reply other threads:[~2010-08-09 8:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-09 8:25 stefani [this message]
2010-08-09 8:37 ` David Woodhouse
2010-08-09 8:52 ` Stefani Seibold
2010-08-09 11:29 ` Artem Bityutskiy
2010-08-09 13:37 ` Stefani Seibold
2010-08-09 13:54 ` Stefani Seibold
2010-08-29 11:30 ` Artem Bityutskiy
2010-08-29 12:20 ` Artem Bityutskiy
2010-08-31 6:42 ` Stefani Seibold
2010-09-01 0:47 ` Artem Bityutskiy
2010-09-02 6:53 ` Stefani Seibold
2010-09-02 10:58 ` Artem Bityutskiy
2010-09-02 11:42 ` Stefani Seibold
2018-06-20 5:38 ` Richard Weinberger
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=1281342353-18180-1-git-send-email-stefani@seibold.net \
--to=stefani@seibold.net \
--cc=Artem.Bityutskiy@nokia.com \
--cc=David.Woodhouse@intel.com \
--cc=akpm@linux-foundation.org \
--cc=dedekind1@gmail.com \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®