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

Boris Brezillon boris.brezillon at free-electrons.com
Wed Jan 6 05:36:01 PST 2016


On Tue, 15 Dec 2015 05:59:31 +0000
Peter Pan <peterpansjtu at gmail.com> wrote:

> From: Brian Norris <computersforpeace at gmail.com>
> 
> Use new BBT APIs (nand_bbt_*()) in NAND. Keep old APIs (nand_*_bbt())
> exist temporarily.
> 
> Signed-off-by: Brian Norris <computersforpeace at gmail.com>
> [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 at micron.com>
> ---
>  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



More information about the linux-mtd mailing list