[PATCH 3/7] mtd: rawnand: Expose _notsupp() helpers for raw page accessors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 18 Jul 2018 10:42:17 +0200
Boris Brezillon <boris.brezillon at bootlin.com> wrote:

> Some implementations simply can't disable their ECC engine. Expose
> helpers returning -ENOTSUPP so that the caller knows that raw accesses
> are not supported instead of silently falling back to non-raw
> accessors.
> 
> Signed-off-by: Boris Brezillon <boris.brezillon at bootlin.com>
> ---
>  drivers/mtd/nand/raw/nand_base.c | 33 +++++++++++++++++++++++++++++++++
>  include/linux/mtd/rawnand.h      |  4 ++++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index 4fa5e20d9690..323a900f3697 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -2966,6 +2966,23 @@ int nand_check_erased_ecc_chunk(void *data, int datalen,
>  }
>  EXPORT_SYMBOL(nand_check_erased_ecc_chunk);
>  
> +/**
> + * nand_read_page_raw_notsupp - dummy read raw page function
> + * @mtd: mtd info structure
> + * @chip: nand chip info structure
> + * @buf: buffer to store read data
> + * @oob_required: caller requires OOB data read to chip->oob_poi
> + * @page: page number to read
> + *
> + * Returns -ENOTSUPP unconditionally.
> + */
> +int nand_read_page_raw_notsupp(struct mtd_info *mtd, struct nand_chip *chip,
> +			       u8 *buf, int oob_required, int page)
> +{
> +	return -ENOTSUPP;
> +}
> +EXPORT_SYMBOL(nand_read_page_raw_notsupp);
> +
>  /**
>   * nand_read_page_raw - [INTERN] read raw page data without ecc
>   * @mtd: mtd info structure
> @@ -3960,6 +3977,22 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from,
>  	return ret;
>  }
>  
> +/**
> + * nand_write_page_raw - dummy raw page write function

Crap, I forgot to add the _notsupp suffix in the doc.

> + * @mtd: mtd info structure
> + * @chip: nand chip info structure
> + * @buf: data buffer
> + * @oob_required: must write chip->oob_poi to OOB
> + * @page: page number to write
> + *
> + * Returns -ENOTSUPP unconditionally.
> + */
> +int nand_write_page_raw_notsupp(struct mtd_info *mtd, struct nand_chip *chip,
> +				const u8 *buf, int oob_required, int page)
> +{
> +	return -ENOTSUPP;
> +}
> +EXPORT_SYMBOL(nand_write_page_raw_notsupp);
>  
>  /**
>   * nand_write_page_raw - [INTERN] raw page write function
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index 11c2426fc363..f60fad29eae6 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -1681,10 +1681,14 @@ int nand_get_set_features_notsupp(struct mtd_info *mtd, struct nand_chip *chip,
>  /* Default read_page_raw implementation */
>  int nand_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
>  		       uint8_t *buf, int oob_required, int page);
> +int nand_read_page_raw_notsupp(struct mtd_info *mtd, struct nand_chip *chip,
> +			       u8 *buf, int oob_required, int page);
>  
>  /* Default write_page_raw implementation */
>  int nand_write_page_raw(struct mtd_info *mtd, struct nand_chip *chip,
>  			const uint8_t *buf, int oob_required, int page);
> +int nand_write_page_raw_notsupp(struct mtd_info *mtd, struct nand_chip *chip,
> +				const u8 *buf, int oob_required, int page);
>  
>  /* Reset and initialize a NAND device */
>  int nand_reset(struct nand_chip *chip, int chipnr);




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux