Commit 86516203 authored by Boris Brezillon's avatar Boris Brezillon Committed by Greg Kroah-Hartman

mtd: nand: mxc: Fix mxc_v1 ooblayout

commit 3bff08df upstream.

Commit a894cf6c ("mtd: nand: mxc: switch to mtd_ooblayout_ops")
introduced a bug in the OOB layout description. Even if the driver claims
that 3 ECC bytes are reserved to protect 512 bytes of data, it's actually
5 ECC bytes to protect 512+6 bytes of data (some OOB bytes are also
protected using extra ECC bytes).

Fix the mxc_v1_ooblayout_{free,ecc}() functions to reflect this behavior.
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Fixes: a894cf6c ("mtd: nand: mxc: switch to mtd_ooblayout_ops")
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f07cb348
...@@ -877,6 +877,8 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr) ...@@ -877,6 +877,8 @@ static void mxc_do_addr_cycle(struct mtd_info *mtd, int column, int page_addr)
} }
} }
#define MXC_V1_ECCBYTES 5
static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section, static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section,
struct mtd_oob_region *oobregion) struct mtd_oob_region *oobregion)
{ {
...@@ -886,7 +888,7 @@ static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section, ...@@ -886,7 +888,7 @@ static int mxc_v1_ooblayout_ecc(struct mtd_info *mtd, int section,
return -ERANGE; return -ERANGE;
oobregion->offset = (section * 16) + 6; oobregion->offset = (section * 16) + 6;
oobregion->length = nand_chip->ecc.bytes; oobregion->length = MXC_V1_ECCBYTES;
return 0; return 0;
} }
...@@ -908,8 +910,7 @@ static int mxc_v1_ooblayout_free(struct mtd_info *mtd, int section, ...@@ -908,8 +910,7 @@ static int mxc_v1_ooblayout_free(struct mtd_info *mtd, int section,
oobregion->length = 4; oobregion->length = 4;
} }
} else { } else {
oobregion->offset = ((section - 1) * 16) + oobregion->offset = ((section - 1) * 16) + MXC_V1_ECCBYTES + 6;
nand_chip->ecc.bytes + 6;
if (section < nand_chip->ecc.steps) if (section < nand_chip->ecc.steps)
oobregion->length = (section * 16) + 6 - oobregion->length = (section * 16) + 6 -
oobregion->offset; oobregion->offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment