
Hi Jagan,
On Wed, 27 Jun 2018 16:38:26 +0530, Jagan Teki jagan@amarulasolutions.com wrote:
On Wed, Jun 6, 2018 at 9:00 PM, Miquel Raynal miquel.raynal@bootlin.com wrote:
From: Boris Brezillon boris.brezillon@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@bootlin.com Signed-off-by: Miquel Raynal miquel.raynal@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@free-electrons.com>
Peter Pan <peterpandong@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.
Thanks for reviewing! Miquèl