[PATCH 02/10] mtd: add a helper to check the SLC/MLC nand chip

Brian Norris computersforpeace at gmail.com
Mon Aug 12 20:52:34 EDT 2013


On Mon, Aug 12, 2013 at 01:42:45PM +0800, Huang Shijie wrote:
> Add a helper to check if a nand chip is SLC or MLC.
> This helper makes the code more readable.
> 
> Signed-off-by: Huang Shijie <b32955 at freescale.com>
> ---
>  drivers/mtd/nand/denali.c    |    2 +-
>  drivers/mtd/nand/nand_base.c |   14 ++++++--------
>  include/linux/mtd/nand.h     |    9 +++++++++
>  3 files changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
> index 2ed2bb3..645721e 100644
> --- a/drivers/mtd/nand/denali.c
> +++ b/drivers/mtd/nand/denali.c
> @@ -1520,7 +1520,7 @@ int denali_init(struct denali_nand_info *denali)
>  	 * so just let controller do 15bit ECC for MLC and 8bit ECC for
>  	 * SLC if possible.
>  	 * */
> -	if (denali->nand.cellinfo & NAND_CI_CELLTYPE_MSK &&
> +	if (!nand_is_slc(&denali->nand) &&

According to my recommendations in patch 1, this would only need to be:

  if (denali->nand.bits_per_cell > 1 && ...)

IMO, that is plenty readable, then we don't need the helper.

>  			(denali->mtd.oobsize > (denali->bbtskipbytes +
>  			ECC_15BITS * (denali->mtd.writesize /
>  			ECC_SECTOR_SIZE)))) {
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index ee1aa52..fd5117d 100644

(ditto elsewhere)

Thanks,
Brian



More information about the linux-mtd mailing list