pastebin

Paste #91960: Untitled ASCII paste by 208.66.31.210

From 7fbe0aaedcebf500d495b1bd7dff43a632f9d465 Mon Sep 17 00:00:00 2001
From: Boris Brezillon <boris.brezillon@free-electrons.com>
Date: Fri, 26 Feb 2016 19:29:48 +0100
Subject: [PATCH] fixup! mtd: add mtd_ooblayout_xxx() helper functions

---
 drivers/mtd/mtdcore.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index ab3a7b6..8085262 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -1127,12 +1127,16 @@ static int mtd_ooblayout_find_region(struct mtd_info *mtd, int byte,
 
 	memset(oobregion, 0, sizeof(*oobregion));
 
-	while (pos + oobregion->length <= byte) {
-		ret = iter(mtd, section++, oobregion);
+	while (1) {
+		ret = iter(mtd, section, oobregion);
 		if (ret)
 			return ret;
 
+		if (pos + oobregion->length > byte)
+			break;
+
 		pos += oobregion->length;
+		section++;
 	}
 
 	/*
@@ -1209,7 +1213,7 @@ static int mtd_ooblayout_get_bytes(struct mtd_info *mtd, u8 *buf,
 		nbytes -= cnt;
 	}
 
-	return !nbytes ? 0 : -ERANGE;
+	return 0;
 }
 
 /**
@@ -1253,7 +1257,7 @@ static int mtd_ooblayout_set_bytes(struct mtd_info *mtd, const u8 *buf,
 		nbytes -= cnt;
 	}
 
-	return !nbytes ? 0 : -ERANGE;
+	return 0;
 }
 
 /**
-- 
2.1.4

Private
Wrap long lines

4 + 5 =