public inbox for linux-mtd@lists.infradead.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 10/10] nanddump: kill usages of MEMSETOOBSEL ioctl
Date: Fri, 19 Aug 2011 10:07:56 -0700	[thread overview]
Message-ID: <1313773676-12879-11-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1313773676-12879-1-git-send-email-computersforpeace@gmail.com>

The ioctl MEMSETOOBSEL hasn't existed for a long time. Using it as a
backup to MTDFILEMODE is pointless, so just remove every time it is
used.

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

diff --git a/nanddump.c b/nanddump.c
index 0b931db..7a24c0d 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -34,10 +34,6 @@
 #include "common.h"
 #include <libmtd.h>
 
-static struct nand_oobinfo none_oobinfo = {
-	.useecc = MTD_NANDECC_OFF,
-};
-
 static void display_help(void)
 {
 	printf(
@@ -309,11 +305,10 @@ int main(int argc, char * const argv[])
 {
 	long long ofs, end_addr = 0;
 	long long blockstart = 1;
-	int ret, i, fd, ofd = 0, bs, badblock = 0;
+	int i, fd, ofd = 0, bs, badblock = 0;
 	struct mtd_dev_info mtd;
 	char pretty_buf[PRETTY_BUF_LEN];
-	int oobinfochanged = 0, firstblock = 1;
-	struct nand_oobinfo old_oobinfo;
+	int firstblock = 1;
 	struct mtd_ecc_stats stat1, stat2;
 	bool eccstats = false;
 	unsigned char *readbuf = NULL, *oobbuf = NULL;
@@ -341,26 +336,9 @@ int main(int argc, char * const argv[])
 	readbuf = xmalloc(sizeof(readbuf) * mtd.min_io_size);
 
 	if (noecc)  {
-		ret = ioctl(fd, MTDFILEMODE, MTD_MODE_RAW);
-		if (ret == 0) {
-			oobinfochanged = 2;
-		} else {
-			switch (errno) {
-			case ENOTTY:
-				if (ioctl(fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
-					perror("MEMGETOOBSEL");
-					goto closeall;
-				}
-				if (ioctl(fd, MEMSETOOBSEL, &none_oobinfo) != 0) {
-					perror("MEMSETOOBSEL");
-					goto closeall;
-				}
-				oobinfochanged = 1;
-				break;
-			default:
+		if (ioctl(fd, MTDFILEMODE, MTD_MODE_RAW) != 0) {
 				perror("MTDFILEMODE");
 				goto closeall;
-			}
 		}
 	} else {
 		/* check if we can read ecc stats */
@@ -498,15 +476,6 @@ int main(int argc, char * const argv[])
 			write(ofd, oobbuf, mtd.oob_size);
 	}
 
-	/* reset oobinfo */
-	if (oobinfochanged == 1) {
-		if (ioctl(fd, MEMSETOOBSEL, &old_oobinfo) != 0) {
-			perror("MEMSETOOBSEL");
-			close(fd);
-			close(ofd);
-			return EXIT_FAILURE;
-		}
-	}
 	/* Close the output file and MTD device, free memory */
 	close(fd);
 	close(ofd);
@@ -517,12 +486,6 @@ int main(int argc, char * const argv[])
 	return EXIT_SUCCESS;
 
 closeall:
-	/* The new mode change is per file descriptor ! */
-	if (oobinfochanged == 1) {
-		if (ioctl(fd, MEMSETOOBSEL, &old_oobinfo) != 0)  {
-			perror("MEMSETOOBSEL");
-		}
-	}
 	close(fd);
 	close(ofd);
 	free(oobbuf);
-- 
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 ` [PATCH 05/10] nandwrite: remove `autoplace' features Brian Norris
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 ` Brian Norris [this message]
2011-08-23  6:31   ` [PATCH 10/10] nanddump: kill usages of MEMSETOOBSEL ioctl 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-11-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox