030-mtd-nand-Use-standard-large-page-OOB-layout-when-usi.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From 882fd1577cbe7812ae3a48988180c5f0fda475ca Mon Sep 17 00:00:00 2001
  2. From: Miquel Raynal <[email protected]>
  3. Date: Sat, 26 Aug 2017 17:19:15 +0200
  4. Subject: [PATCH] mtd: nand: Use standard large page OOB layout when using
  5. NAND_ECC_NONE
  6. Use the core's large page OOB layout functions when not reserving any
  7. space for ECC bytes in the OOB layout. Fix ->nand_ooblayout_ecc_lp()
  8. to return -ERANGE instead of a zero length in this case.
  9. Signed-off-by: Miquel Raynal <[email protected]>
  10. Signed-off-by: Boris Brezillon <[email protected]>
  11. ---
  12. drivers/mtd/nand/nand_base.c | 15 ++++++++++++++-
  13. 1 file changed, 14 insertions(+), 1 deletion(-)
  14. --- a/drivers/mtd/nand/nand_base.c
  15. +++ b/drivers/mtd/nand/nand_base.c
  16. @@ -115,7 +115,7 @@ static int nand_ooblayout_ecc_lp(struct
  17. struct nand_chip *chip = mtd_to_nand(mtd);
  18. struct nand_ecc_ctrl *ecc = &chip->ecc;
  19. - if (section)
  20. + if (section || !ecc->total)
  21. return -ERANGE;
  22. oobregion->length = ecc->total;
  23. @@ -4712,6 +4712,19 @@ int nand_scan_tail(struct mtd_info *mtd)
  24. mtd_set_ooblayout(mtd, &nand_ooblayout_lp_hamming_ops);
  25. break;
  26. default:
  27. + /*
  28. + * Expose the whole OOB area to users if ECC_NONE
  29. + * is passed. We could do that for all kind of
  30. + * ->oobsize, but we must keep the old large/small
  31. + * page with ECC layout when ->oobsize <= 128 for
  32. + * compatibility reasons.
  33. + */
  34. + if (ecc->mode == NAND_ECC_NONE) {
  35. + mtd_set_ooblayout(mtd,
  36. + &nand_ooblayout_lp_ops);
  37. + break;
  38. + }
  39. +
  40. WARN(1, "No oob scheme defined for oobsize %d\n",
  41. mtd->oobsize);
  42. ret = -EINVAL;