* [PATCH v5] mtd: nand: Use standard large page OOB layout when using NAND_ECC_NONE
@ 2017-08-26 15:19 Miquel Raynal
2017-09-22 10:06 ` Boris Brezillon
0 siblings, 1 reply; 2+ messages in thread
From: Miquel Raynal @ 2017-08-26 15:19 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, linux-mtd
Cc: David Woodhouse, Brian Norris, Marek Vasut, Cyrille Pitchen,
linux-kernel, Miquel Raynal
Use the core's large page OOB layout functions when not reserving any
space for ECC bytes in the OOB layout. Fix ->nand_ooblayout_ecc_lp()
to return -ERANGE instead of a zero length in this case.
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
---
drivers/mtd/nand/nand_base.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index c5221795a1e8..39894c3f0fd5 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -115,7 +115,7 @@ static int nand_ooblayout_ecc_lp(struct mtd_info *mtd, int section,
struct nand_chip *chip = mtd_to_nand(mtd);
struct nand_ecc_ctrl *ecc = &chip->ecc;
- if (section)
+ if (section || !ecc->total)
return -ERANGE;
oobregion->length = ecc->total;
@@ -4649,6 +4649,19 @@ int nand_scan_tail(struct mtd_info *mtd)
mtd_set_ooblayout(mtd, &nand_ooblayout_lp_hamming_ops);
break;
default:
+ /*
+ * Expose the whole OOB area to users if ECC_NONE
+ * is passed. We could do that for all kind of
+ * ->oobsize, but we must keep the old large/small
+ * page with ECC layout when ->oobsize <= 128 for
+ * compatibility reasons.
+ */
+ if (ecc->mode == NAND_ECC_NONE) {
+ mtd_set_ooblayout(mtd,
+ &nand_ooblayout_lp_ops);
+ break;
+ }
+
WARN(1, "No oob scheme defined for oobsize %d\n",
mtd->oobsize);
ret = -EINVAL;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v5] mtd: nand: Use standard large page OOB layout when using NAND_ECC_NONE
2017-08-26 15:19 [PATCH v5] mtd: nand: Use standard large page OOB layout when using NAND_ECC_NONE Miquel Raynal
@ 2017-09-22 10:06 ` Boris Brezillon
0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2017-09-22 10:06 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, linux-mtd, Cyrille Pitchen, linux-kernel,
Marek Vasut, Brian Norris, David Woodhouse
On Sat, 26 Aug 2017 17:19:15 +0200
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> Use the core's large page OOB layout functions when not reserving any
> space for ECC bytes in the OOB layout. Fix ->nand_ooblayout_ecc_lp()
> to return -ERANGE instead of a zero length in this case.
>
Applied.
Thanks,
Boris
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
> ---
> drivers/mtd/nand/nand_base.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index c5221795a1e8..39894c3f0fd5 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -115,7 +115,7 @@ static int nand_ooblayout_ecc_lp(struct mtd_info *mtd, int section,
> struct nand_chip *chip = mtd_to_nand(mtd);
> struct nand_ecc_ctrl *ecc = &chip->ecc;
>
> - if (section)
> + if (section || !ecc->total)
> return -ERANGE;
>
> oobregion->length = ecc->total;
> @@ -4649,6 +4649,19 @@ int nand_scan_tail(struct mtd_info *mtd)
> mtd_set_ooblayout(mtd, &nand_ooblayout_lp_hamming_ops);
> break;
> default:
> + /*
> + * Expose the whole OOB area to users if ECC_NONE
> + * is passed. We could do that for all kind of
> + * ->oobsize, but we must keep the old large/small
> + * page with ECC layout when ->oobsize <= 128 for
> + * compatibility reasons.
> + */
> + if (ecc->mode == NAND_ECC_NONE) {
> + mtd_set_ooblayout(mtd,
> + &nand_ooblayout_lp_ops);
> + break;
> + }
> +
> WARN(1, "No oob scheme defined for oobsize %d\n",
> mtd->oobsize);
> ret = -EINVAL;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-09-22 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-26 15:19 [PATCH v5] mtd: nand: Use standard large page OOB layout when using NAND_ECC_NONE Miquel Raynal
2017-09-22 10:06 ` Boris Brezillon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox