[U-Boot] [RFC PATCH 08/20] mtd: nand: Add core infrastructure to deal with NAND devices
Tom Rini
trini at konsulko.com
Wed Jun 27 21:35:36 UTC 2018
On Wed, Jun 27, 2018 at 02:48:23PM +0200, Miquel Raynal wrote:
> Hi Jagan,
>
> On Wed, 27 Jun 2018 16:38:26 +0530, Jagan Teki
> <jagan at amarulasolutions.com> wrote:
>
> > On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal <miquel.raynal at bootlin.com> wrote:
> > > From: Boris Brezillon <boris.brezillon at bootlin.com>
> > >
> > > Add an intermediate layer to abstract NAND device interface so that
> > > some logic can be shared between SPI NANDs, parallel/raw NANDs,
> > > OneNANDs, ...
> > >
> > > Signed-off-by: Boris Brezillon <boris.brezillon at bootlin.com>
> > > Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
> > > ---
> > > drivers/mtd/nand/Kconfig | 3 +
> > > drivers/mtd/nand/Makefile | 3 +
> > > drivers/mtd/nand/bbt.c | 132 +++++++++
> > > drivers/mtd/nand/core.c | 243 +++++++++++++++
> > > include/linux/mtd/nand.h | 731 ++++++++++++++++++++++++++++++++++++++++++++++
> > > 5 files changed, 1112 insertions(+)
> > > create mode 100644 drivers/mtd/nand/bbt.c
> > > create mode 100644 drivers/mtd/nand/core.c
> > > create mode 100644 include/linux/mtd/nand.h
> > >
> > > diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
> > > index 6d53734718..1c1a1f487e 100644
> > > --- a/drivers/mtd/nand/Kconfig
> > > +++ b/drivers/mtd/nand/Kconfig
> > > @@ -1 +1,4 @@
> > > +config MTD_NAND_CORE
> > > + tristate
> > > +
> > > source "drivers/mtd/nand/raw/Kconfig"
> > > diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
> > > index d1c3f93047..69c80ea252 100644
> > > --- a/drivers/mtd/nand/Makefile
> > > +++ b/drivers/mtd/nand/Makefile
> > > @@ -1,3 +1,6 @@
> > > # SPDX-License-Identifier: GPL-2.0
> > >
> > > +nandcore-objs := core.o bbt.o
> > > +obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
> > > +
> > > obj-$(CONFIG_MTD_NAND) += raw/
> > > diff --git a/drivers/mtd/nand/bbt.c b/drivers/mtd/nand/bbt.c
> > > new file mode 100644
> > > index 0000000000..7e0ad3190c
> > > --- /dev/null
> > > +++ b/drivers/mtd/nand/bbt.c
> > > @@ -0,0 +1,132 @@
> > > +// SPDX-License-Identifier: GPL-2.0
> > > +/*
> > > + * Copyright (c) 2017 Free Electrons
> > > + *
> > > + * Authors:
> > > + * Boris Brezillon <boris.brezillon at free-electrons.com>
> > > + * Peter Pan <peterpandong at micron.com>
> > > + */
> > > +
> > > +#define pr_fmt(fmt) "nand-bbt: " fmt
> > > +
> > > +#include <linux/mtd/nand.h>
> > > +#ifndef __UBOOT__
> > > +#include <linux/slab.h>
> > > +#endif
> > > +
> > > +/**
> > > + * nanddev_bbt_init() - Initialize the BBT (Bad Block Table)
> > > + * @nand: NAND device
> > > + *
> > > + * Initialize the in-memory BBT.
> > > + *
> > > + * Return: 0 in case of success, a negative error code otherwise.
> > > + */
> > > +int nanddev_bbt_init(struct nand_device *nand)
> > > +{
> > > + unsigned int bits_per_block = fls(NAND_BBT_BLOCK_NUM_STATUS);
> > > + unsigned int nblocks = nanddev_neraseblocks(nand);
> > > + unsigned int nwords = DIV_ROUND_UP(nblocks * bits_per_block,
> > > + BITS_PER_LONG);
> > > +
> > > + nand->bbt.cache = kzalloc(nwords, GFP_KERNEL);
> > > + if (!nand->bbt.cache)
> > > + return -ENOMEM;
> > > +
> > > + return 0;
> > > +}
> > > +EXPORT_SYMBOL_GPL(nanddev_bbt_init);
> >
> > Can't we skip __UBOOT__ and EXPORT_SYMBOL_GPL ?
>
> Do you mean that you want me to delete all the #ifndef __UBOOT__/#endif
> sections?
>
> They are present only to ease the patch backporting process from
> Linux. It was very useful during the development, I don't have a
> strong opinion on whether we should keep them or not, yet.
The general rule here is we do whatever makes life easiest on the people
that are doing the periodic re-syncs. Thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180627/06c706c8/attachment.sig>
More information about the U-Boot
mailing list