From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miquel Raynal Date: Wed, 27 Jun 2018 14:48:23 +0200 Subject: [U-Boot] [RFC PATCH 08/20] mtd: nand: Add core infrastructure to deal with NAND devices In-Reply-To: References: <20180606153040.21397-1-miquel.raynal@bootlin.com> <20180606153040.21397-9-miquel.raynal@bootlin.com> Message-ID: <20180627144823.148fc41d@xps13> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi Jagan, On Wed, 27 Jun 2018 16:38:26 +0530, Jagan Teki wrote: > On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal = wrote: > > From: Boris Brezillon > > > > 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 > > Signed-off-by: Miquel Raynal > > --- > > 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 :=3D core.o bbt.o > > +obj-$(CONFIG_MTD_NAND_CORE) +=3D nandcore.o > > + > > obj-$(CONFIG_MTD_NAND) +=3D 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 > > + * Peter Pan > > + */ > > + > > +#define pr_fmt(fmt) "nand-bbt: " fmt > > + > > +#include > > +#ifndef __UBOOT__ > > +#include > > +#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 =3D fls(NAND_BBT_BLOCK_NUM_STATUS); > > + unsigned int nblocks =3D nanddev_neraseblocks(nand); > > + unsigned int nwords =3D DIV_ROUND_UP(nblocks * bits_per_block, > > + BITS_PER_LONG); > > + > > + nand->bbt.cache =3D kzalloc(nwords, GFP_KERNEL); > > + if (!nand->bbt.cache) > > + return -ENOMEM; > > + > > + return 0; > > +} > > +EXPORT_SYMBOL_GPL(nanddev_bbt_init); =20 >=20 > 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.=20 Thanks for reviewing! Miqu=C3=A8l