public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC PATCH 08/20] mtd: nand: Add core infrastructure to deal with NAND devices
Date: Wed, 27 Jun 2018 14:48:23 +0200	[thread overview]
Message-ID: <20180627144823.148fc41d@xps13> (raw)
In-Reply-To: <CAMty3ZDBcVDErT3yUT6PrUNN3q3AnJvBEv+iue=0fX=d5y8g5Q@mail.gmail.com>

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

  reply	other threads:[~2018-06-27 12:48 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 15:30 [U-Boot] [RFC PATCH 00/20] SPI-NAND support Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 01/20] mtd: Fallback to ->_read/write_oob() when ->_read/write() is missing Miquel Raynal
2018-06-27 10:52   ` Jagan Teki
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 02/20] mtd: add get/set of_node/flash_node helpers Miquel Raynal
2018-06-27 10:53   ` Jagan Teki
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 03/20] mtd: fix build issue with includes Miquel Raynal
2018-06-27 10:53   ` Jagan Teki
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 04/20] mtd: move definitions to enlarge their range Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 05/20] mtd: move all flash categories inside MTD submenu Miquel Raynal
2018-06-27 10:56   ` Jagan Teki
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 06/20] mtd: move NAND fiels into a raw/ subdirectory Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 07/20] mtd: rename nand into rawnand in Kconfig prompt Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 08/20] mtd: nand: Add core infrastructure to deal with NAND devices Miquel Raynal
2018-06-27 11:08   ` Jagan Teki
2018-06-27 12:48     ` Miquel Raynal [this message]
2018-06-27 21:35       ` Tom Rini
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 09/20] mtd: nand: Pass mode information to nand_page_io_req Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 10/20] spi: Extend the core to ease integration of SPI memory controllers Miquel Raynal
2018-07-06 11:32   ` Jagan Teki
2018-07-11 13:55     ` Miquel Raynal
2018-07-11 14:37       ` Jagan Teki
2018-07-11 15:10         ` Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 11/20] mtd: nand: Add core infrastructure to support SPI NANDs Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 12/20] mtd: spinand: Add initial support for Micron MT29F2G01ABAGD Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 13/20] mtd: spinand: Add initial support for Winbond W25M02GV Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 14/20] mtd: spinand: Add initial support for the MX35LF1GE4AB chip Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 15/20] mtd: spinand: Add initial support for the MX35LF2GE4AB chip Miquel Raynal
2018-06-22 12:03   ` Boris Brezillon
2018-06-26  7:54     ` Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 16/20] mtd: uclass: add probe function Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 17/20] cmd: mtd: add 'mtd' command Miquel Raynal
2018-06-06 19:45   ` Boris Brezillon
2018-07-11 13:51     ` Miquel Raynal
2018-07-11 14:01       ` Boris Brezillon
2018-07-11 14:17         ` Miquel Raynal
2018-07-06 11:38   ` Jagan Teki
2018-07-06 12:26     ` Miquel Raynal
2018-07-06 13:21       ` Stefan Roese
2018-07-06 13:42         ` Miquel Raynal
2018-07-06 13:51           ` Stefan Roese
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 18/20] dt-bindings: Add bindings for SPI NAND devices Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 19/20] mips: dts: ocelot: describe SPI CS pins Miquel Raynal
2018-06-06 15:30 ` [U-Boot] [RFC PATCH 20/20] mips: dts: ocelot: add the SPI NAND node Miquel Raynal
2018-06-07  5:51 ` [U-Boot] [RFC PATCH 00/20] SPI-NAND support Jagan Teki
2018-06-07  8:41   ` Miquel Raynal
2018-06-18  8:07     ` Boris Brezillon
2018-06-25  8:29     ` Jagan Teki
2018-06-25  9:09       ` Boris Brezillon
2018-06-25 12:38         ` Richard Weinberger
2018-06-25 14:27         ` Jagan Teki
2018-06-25 14:28           ` Jagan Teki
2018-06-25 14:46             ` Boris Brezillon
2018-06-25 14:55               ` Tom Rini
2018-06-25 14:59                 ` Stefan Roese
2018-06-25 18:37                 ` Jagan Teki
2018-06-25 19:58                   ` Boris Brezillon
2018-06-25 20:01                     ` Tom Rini
2018-06-27 11:43                     ` Jagan Teki
2018-06-25 14:36           ` Richard Weinberger
2018-06-12 14:14 ` Stefan Roese
2018-06-18  8:13   ` Miquel Raynal
2018-07-06 11:43 ` Jagan Teki
2018-07-06 12:06   ` Miquel Raynal
2018-07-06 12:15     ` Jagan Teki
2018-07-06 17:48       ` Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180627144823.148fc41d@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox