Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbdIVKGO (ORCPT ); Fri, 22 Sep 2017 06:06:14 -0400 Received: from mail.free-electrons.com ([62.4.15.54]:56744 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbdIVKGM (ORCPT ); Fri, 22 Sep 2017 06:06:12 -0400 Date: Fri, 22 Sep 2017 12:06:10 +0200 From: Boris Brezillon To: Miquel Raynal Cc: Richard Weinberger , linux-mtd@lists.infradead.org, Cyrille Pitchen , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse Subject: Re: [PATCH v5] mtd: nand: Use standard large page OOB layout when using NAND_ECC_NONE Message-ID: <20170922120610.0700434a@bbrezillon> In-Reply-To: <20170826151915.28400-1-miquel.raynal@free-electrons.com> References: <20170826151915.28400-1-miquel.raynal@free-electrons.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1646 Lines: 52 On Sat, 26 Aug 2017 17:19:15 +0200 Miquel Raynal 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 > --- > 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;