All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: Kevin Cernekee <cernekee@gmail.com>,
	Brian Norris <computersforpeace@gmail.com>,
	linux-mtd@lists.infradead.org,
	Mike Frysinger <vapier.adi@gmail.com>
Subject: [PATCH 05/10] nandwrite: remove `autoplace' features
Date: Fri, 19 Aug 2011 10:07:51 -0700	[thread overview]
Message-ID: <1313773676-12879-6-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1313773676-12879-1-git-send-email-computersforpeace@gmail.com>

The `autoplace' option was meant to force an MTD_OOB_AUTO layout while
writing to flash. This option has not been properly supported for a very
long time, as the necessary ioctl, MEMSETOOBSEL, has been removed.
Apparently nobody uses this option. Kill it.

Other code depends on the availability of the `old_oobinfo' data, so we
move some code within a block that handles autoplacement if it's
*already* enabled. This, however, is inconsistent and should be cleaned
up shortly.

Note: this option may be re-implemented in the near future with the
addition of a new ioctl that allows on-the-fly chaning of MTD OOB modes.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 nandwrite.c |   43 +++++++++----------------------------------
 1 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/nandwrite.c b/nandwrite.c
index f58bbfa..2700975 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -60,17 +60,12 @@ static struct nand_oobinfo yaffs_oobinfo = {
 	.eccpos = { 8, 9, 10, 13, 14, 15}
 };
 
-static struct nand_oobinfo autoplace_oobinfo = {
-	.useecc = MTD_NANDECC_AUTOPLACE
-};
-
 static void display_help(void)
 {
 	printf(
 "Usage: nandwrite [OPTION] MTD_DEVICE [INPUTFILE|-]\n"
 "Writes to the specified MTD device.\n"
 "\n"
-"  -a, --autoplace         Use auto oob layout\n"
 "  -j, --jffs2             Force jffs2 oob layout (legacy support)\n"
 "  -y, --yaffs             Force yaffs oob layout (legacy support)\n"
 "  -f, --forcelegacy       Force legacy support on autoplacement-enabled mtd\n"
@@ -114,7 +109,6 @@ static bool		quiet = false;
 static bool		writeoob = false;
 static bool		rawoob = false;
 static bool		onlyoob = false;
-static bool		autoplace = false;
 static bool		markbad = false;
 static bool		forcejffs2 = false;
 static bool		forceyaffs = false;
@@ -130,11 +124,10 @@ static void process_options(int argc, char * const argv[])
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "ab:fjmnNoOpqrs:y";
+		static const char *short_options = "b:fjmnNoOpqrs:y";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
-			{"autoplace", no_argument, 0, 'a'},
 			{"blockalign", required_argument, 0, 'b'},
 			{"forcelegacy", no_argument, 0, 'f'},
 			{"jffs2", no_argument, 0, 'j'},
@@ -171,9 +164,6 @@ static void process_options(int argc, char * const argv[])
 			case 'q':
 				quiet = true;
 				break;
-			case 'a':
-				autoplace = true;
-				break;
 			case 'j':
 				forcejffs2 = true;
 				break;
@@ -321,25 +311,6 @@ int main(int argc, char * const argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (autoplace) {
-		/* Read the current oob info */
-		if (ioctl(fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
-			perror("MEMGETOOBSEL");
-			close(fd);
-			exit(EXIT_FAILURE);
-		}
-
-		// autoplace ECC ?
-		if (old_oobinfo.useecc != MTD_NANDECC_AUTOPLACE) {
-			if (ioctl(fd, MEMSETOOBSEL, &autoplace_oobinfo) != 0) {
-				perror("MEMSETOOBSEL");
-				close(fd);
-				exit(EXIT_FAILURE);
-			}
-			oobinfochanged = 1;
-		}
-	}
-
 	if (noecc)  {
 		ret = ioctl(fd, MTDFILEMODE, MTD_MODE_RAW);
 		if (ret == 0) {
@@ -374,10 +345,6 @@ int main(int argc, char * const argv[])
 	if (forcejffs2 || forceyaffs) {
 		struct nand_oobinfo *oobsel = forcejffs2 ? &jffs2_oobinfo : &yaffs_oobinfo;
 
-		if (autoplace) {
-			fprintf(stderr, "Autoplacement is not possible for legacy -j/-y options\n");
-			goto restoreoob;
-		}
 		if ((old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE) && !forcelegacy) {
 			fprintf(stderr, "Use -f option to enforce legacy placement on autoplacement enabled mtd device\n");
 			goto restoreoob;
@@ -608,6 +575,14 @@ int main(int argc, char * const argv[])
 			if (!noecc) {
 				int i, start, len;
 				int tags_pos = 0;
+
+				/* Read the current oob info */
+				if (ioctl(fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
+					perror("MEMGETOOBSEL");
+					close(fd);
+					exit(EXIT_FAILURE);
+				}
+
 				/*
 				 * We use autoplacement and have the oobinfo with the autoplacement
 				 * information from the kernel available
-- 
1.7.6

  parent reply	other threads:[~2011-08-19 17:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-19 17:07 [PATCH 00/10] nandwrite: clean out old ioctls Brian Norris
2011-08-19 17:07 ` [PATCH 01/10] mtd_debug: fixup style Brian Norris
2011-08-19 17:07 ` [PATCH 02/10] mtd_debug: replace #defines with enum Brian Norris
2011-08-19 17:07 ` [PATCH 03/10] mtd-utils: use __func__ instead of __FUNCTION__ Brian Norris
2011-08-19 17:07 ` [PATCH 04/10] nandwrite: remove C99 comment style Brian Norris
2011-08-19 17:07 ` Brian Norris [this message]
2011-08-19 17:07 ` [PATCH 06/10] nandwrite: kill more MEMSETOOBSEL Brian Norris
2011-08-19 17:07 ` [PATCH 07/10] nandwrite: kill -j, -y, and -f options Brian Norris
2011-08-19 17:07 ` [PATCH 08/10] nandwrite: cleanup "oobinfochanged" leftovers Brian Norris
2011-08-19 17:07 ` [PATCH 09/10] nandwrite: refactor "old_oobinfo" code Brian Norris
2011-08-19 17:07 ` [PATCH 10/10] nanddump: kill usages of MEMSETOOBSEL ioctl Brian Norris
2011-08-23  6:31   ` Artem Bityutskiy
2011-08-23 16:19     ` Brian Norris
2011-08-23  6:29 ` [PATCH 00/10] nandwrite: clean out old ioctls Artem Bityutskiy

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=1313773676-12879-6-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=cernekee@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=vapier.adi@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.