Re: [PATCH v2 05/12] mtd: nand: use new BBT API instead of old ones

From: Boris Brezillon
Date: Wed Jan 06 2016 - 08:36:11 EST


On Tue, 15 Dec 2015 05:59:31 +0000
Peter Pan <peterpansjtu@xxxxxxxxx> wrote:

> From: Brian Norris <computersforpeace@xxxxxxxxx>
>
> Use new BBT APIs (nand_bbt_*()) in NAND. Keep old APIs (nand_*_bbt())
> exist temporarily.
>
> Signed-off-by: Brian Norris <computersforpeace@xxxxxxxxx>
> [Peter: 1. use nand_bbt_markbad_factory() in docg4.c and implement
> 2. nand_create_factory_badblock_pattern(), nand_is_bad_bbm() and
> nand_default_bbt() in nand_base.c
> 3. add NAND_BADBLOCK_PATTERN_ALLOC macro]
> Signed-off-by: Peter Pan <peterpandong@xxxxxxxxxx>
> ---
> drivers/mtd/nand/docg4.c | 6 +-
> drivers/mtd/nand/nand_base.c | 140 ++++++++++++++++++++++++++++++++++++++++---
> include/linux/mtd/nand.h | 9 ++-
> 3 files changed, 143 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
> index da93d7f..1be7fa2 100644
> --- a/drivers/mtd/nand/docg4.c
> +++ b/drivers/mtd/nand/docg4.c
> @@ -1037,7 +1037,7 @@ static int __init read_factory_bbt(struct mtd_info *mtd)
> * operation after device power-up. The above read ensures it never is.
> * Ugly, I know.
> */
> - if (nand->bbt == NULL) /* no memory-based bbt */
> + if (nand->nand_bbt == NULL) /* no memory-based bbt */

Hm, can we avoid direct references to the ->nand_bbt field by either
providing an accessor (nand_get_bbt()), or providing wrappers around
the nand_chip device (nand_has_bbt(nand), nand_markbad_factory(nand,
ofs), ...)?
In my rather limited experience, doing that is more future-proof.

--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/