Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1684156

Re: [PATCH] mtd: nand: fix lack of oob layout when using no ecc

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mtd: nand: fix lack of oob layout when using no ecc
Date 2017-07-10 13:40 +0200
Message-ID <u1FcK-4qZ-19@gated-at.bofh.it> (permalink)
References <u1EgF-3Sw-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, 10 Jul 2017 12:37:26 +0200
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:

> Fix nand core lack of OOB layout when:
> - the NFC driver does not provide any OOB layout,
> - ECC operations are disabled (using NAND_ECC_NONE).
> Using this configuration leads to a crash during the probe.
> 
> Add layout functions for small and large pages with mainly free bytes
> plus reserved space for bad block markers.
> 
> Check the configuration and eventually assign this OOB layout in
> nand_scan_tail().
> 
> Bad block markers position was extracted from the existing OOB layouts
> by assigning as free all the bytes marked as ECC.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
> ---
>  drivers/mtd/nand/nand_base.c | 75 +++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 74 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index c5221795a1e8..28ff58e4385f 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -53,7 +53,45 @@ static int nand_get_device(struct mtd_info *mtd, int new_state);
>  static int nand_do_write_oob(struct mtd_info *mtd, loff_t to,
>  			     struct mtd_oob_ops *ops);
>  
> -/* Define default oob placement schemes for large and small page devices */
> +/*
> + * Define default OOB placement schemes for:
> + *   - no ECC or software ECC
> + *   - small or large page devices
> + */
> +static int nand_ooblayout_ecc_sp_bbm_only(struct mtd_info *mtd, int section,
> +					  struct mtd_oob_region *oobregion)
> +{
> +	return -ERANGE;
> +}
> +
> +static int nand_ooblayout_free_sp_bbm_only(struct mtd_info *mtd, int section,
> +					   struct mtd_oob_region *oobregion)
> +{
> +	if (section > 1)
> +		return -ERANGE;
> +
> +	if (!section) {
> +		if (mtd->oobsize == 16) {
> +			oobregion->offset = 0;
> +			oobregion->length = 4;
> +		} else {
> +			oobregion->offset = 0;
> +			oobregion->length = 5;
> +		}
> +	} else {
> +		oobregion->offset = 6;
> +		oobregion->length = mtd->oobsize - oobregion->offset;
> +	}
> +
> +	return 0;
> +}
> +
> +const struct mtd_ooblayout_ops nand_ooblayout_sp_bbm_only_ops = {
> +	.ecc = nand_ooblayout_ecc_sp_bbm_only,

Actually, you don't have to implement ->ecc() in this case, just leave
it to NULL, the core takes care of returning -ENOTSUPP in this case [1].

[1]http://elixir.free-electrons.com/linux/latest/source/drivers/mtd/mtdcore.c#L1143

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mtd: nand: fix lack of oob layout when using no ecc Miquel Raynal <miquel.raynal@free-electrons.com> - 2017-07-10 12:40 +0200
  Re: [PATCH] mtd: nand: fix lack of oob layout when using no ecc Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-07-10 13:30 +0200
    Re: [PATCH] mtd: nand: fix lack of oob layout when using no ecc Miquel RAYNAL <miquel.raynal@free-electrons.com> - 2017-07-10 13:40 +0200
  Re: [PATCH] mtd: nand: fix lack of oob layout when using no ecc Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-07-10 13:40 +0200
  [PATCH v2] mtd: nand: fix lack of oob layout when using no ecc Miquel RAYNAL <miquel.raynal@free-electrons.com> - 2017-07-10 14:10 +0200
    Re: [PATCH v2] mtd: nand: fix lack of oob layout when using no ecc Boris Brezillon <boris.brezillon@free-electrons.com> - 2017-07-18 10:00 +0200

csiph-web