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 08/10] nandwrite: cleanup "oobinfochanged" leftovers
Date: Fri, 19 Aug 2011 10:07:54 -0700 [thread overview]
Message-ID: <1313773676-12879-9-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1313773676-12879-1-git-send-email-computersforpeace@gmail.com>
We don't really use oobinfochanged anymore, since all the calls to the
MEMSETOOBSEL ioctls are gone. The remaining usage of it is superfluous
now, as the only case where it is changed is under the "noecc" condition
and the only case where it is tested is under the "!noecc" condition.
We also no longer need the "restoreoob" label and can instead simply
close everything done with the single remaining label, "closeall". Note
that `close(-1)' is legal, although useless.
Finally, we move `old_oobinfo' into the only block of code in which it's
used now.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
nandwrite.c | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/nandwrite.c b/nandwrite.c
index a0f2596..078e2ff 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -225,8 +225,6 @@ int main(int argc, char * const argv[])
struct mtd_dev_info mtd;
long long offs;
int ret;
- int oobinfochanged = 0;
- struct nand_oobinfo old_oobinfo;
bool failed = true;
/* contains all the data read from the file so far for the current eraseblock */
unsigned char *filebuf = NULL;
@@ -277,9 +275,7 @@ int main(int argc, char * const argv[])
if (noecc) {
ret = ioctl(fd, MTDFILEMODE, MTD_MODE_RAW);
- if (ret == 0) {
- oobinfochanged = 2;
- } else {
+ if (ret) {
switch (errno) {
case ENOTTY:
errmsg_die("ioctl MTDFILEMODE is missing");
@@ -300,7 +296,7 @@ int main(int argc, char * const argv[])
if (ifd == -1) {
perror(img);
- goto restoreoob;
+ goto closeall;
}
pagelen = mtd.min_io_size + ((writeoob) ? mtd.oob_size : 0);
@@ -502,6 +498,7 @@ int main(int argc, char * const argv[])
if (!noecc) {
int i, start, len;
int tags_pos = 0;
+ struct nand_oobinfo old_oobinfo;
/* Read the current oob info */
if (ioctl(fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
@@ -517,7 +514,7 @@ int main(int argc, char * const argv[])
* Modified to support out of order oobfree segments,
* such as the layout used by diskonchip.c
*/
- if (!oobinfochanged && (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE)) {
+ if (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
for (i = 0; old_oobinfo.oobfree[i][1]; i++) {
/* Set the reserved bytes to 0xff */
start = old_oobinfo.oobfree[i][0];
@@ -592,8 +589,6 @@ int main(int argc, char * const argv[])
closeall:
close(ifd);
-
-restoreoob:
libmtd_close(mtd_desc);
free(filebuf);
free(oobbuf);
--
1.7.6
next prev 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 ` Brian Norris [this message]
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-9-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