From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Peter Pan <peterpandong@micron.com>
Cc: <richard@nod.at>, <computersforpeace@gmail.com>,
<arnaud.mouiche@gmail.com>, <thomas.petazzoni@free-electrons.com>,
<marex@denx.de>, <cyrille.pitchen@atmel.com>,
<linux-mtd@lists.infradead.org>, <peterpansjtu@gmail.com>,
<linshunquan1@hisilicon.com>
Subject: Re: [PATCH v4 1/9] mtd: nand: add oob iterator in nand_for_each_page
Date: Wed, 29 Mar 2017 21:34:27 +0200 [thread overview]
Message-ID: <20170329213427.280c26bb@bbrezillon> (raw)
In-Reply-To: <1490262226-29092-2-git-send-email-peterpandong@micron.com>
On Thu, 23 Mar 2017 17:43:38 +0800
Peter Pan <peterpandong@micron.com> wrote:
> Iterate nand pages by both page and oob operation.
For the next version, can you merge my initial commit [1] into this one
(you can keep the authorship)?
>
> Signed-off-by: Peter Pan <peterpandong@micron.com>
> ---
> include/linux/mtd/nand.h | 38 +++++++++++++++++++++++++++++++-------
> 1 file changed, 31 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
> index c2197b4..54ded4c 100644
> --- a/include/linux/mtd/nand.h
> +++ b/include/linux/mtd/nand.h
> @@ -84,9 +84,12 @@ struct nand_device {
> * @pageoffset: the offset within a page
Update the documentation.
> */
> struct nand_page_iter {
> - loff_t offs;
> int page;
> int pageoffs;
> + size_t dataleft;
> + int ooboffs;
> + int oobsize;
oobsize can be extracted from nand_device, and since a nand_device
object it passed to all nand_page_iter_xxx() functions you don't need it
here.
> + size_t oobleft;
> };
>
> /**
> @@ -193,14 +196,19 @@ static inline int nand_per_page_oobsize(struct nand_device *nand)
> * @offs: absolute offset
> * @iter: page iterator
Update the documentation.
> */
> -static inline void nand_page_iter_init(struct nand_device *nand, loff_t offs,
> +static inline void nand_page_iter_init(struct nand_device *nand,
> + loff_t offs, size_t len, u32 ooboffs,
> + size_t ooblen, u32 oobsize,
> struct nand_page_iter *iter)
> {
> u64 page = offs;
>
> iter->pageoffs = do_div(page, nand->memorg.pagesize);
> iter->page = page;
> - iter->offs = offs;
> + iter->dataleft = len;
> + iter->ooboffs = ooboffs;
> + iter->oobsize = oobsize;
> + iter->oobleft = ooblen;
> }
>
> /**
> @@ -212,13 +220,29 @@ static inline void nand_page_iter_next(struct nand_device *nand,
> struct nand_page_iter *iter)
> {
> iter->page++;
> - iter->offs += nand_page_size(nand) - iter->pageoffs;
> iter->pageoffs = 0;
> + if (iter->dataleft)
> + iter->dataleft -= min_t (int,
> + nand_page_size(nand) - iter->pageoffs,
> + iter->dataleft);
> + if (iter->oobleft)
> + iter->oobleft -= min_t(int, iter->oobsize - iter->ooboffs,
> + iter->oobleft);
> +}
> +
Document the function.
> +static inline bool nand_page_iter_end(struct nand_device *nand,
> + struct nand_page_iter *iter)
> +{
> + if (iter->dataleft || iter->oobleft)
> + return false;
> + return true;
> }
>
> -#define nand_for_each_page(nand, start, len, iter) \
> - for (nand_page_iter_init(nand, start, iter); \
> - (iter)->offs < (start) + (len); \
> +#define nand_for_each_page(nand, start, len, ooboffs, ooblen, \
> + oobsize, iter) \
> + for (nand_page_iter_init(nand, start, len, ooboffs, \
> + ooblen, oobsize, iter); \
> + !nand_page_iter_end(nand, iter); \
> nand_page_iter_next(nand, iter))
>
> /**
[1]https://github.com/bbrezillon/linux-0day/commit/f02767a662ec02a0206a0b6c5a410a38d7b7b313
next prev parent reply other threads:[~2017-03-29 19:35 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-23 9:43 [PATCH v4 0/9] Introduction to SPI NAND framework Peter Pan
2017-03-23 9:43 ` [PATCH v4 1/9] mtd: nand: add oob iterator in nand_for_each_page Peter Pan
2017-03-23 11:13 ` Marek Vasut
2017-03-28 1:35 ` Peter Pan
2017-03-29 19:34 ` Boris Brezillon [this message]
2017-03-30 8:01 ` Peter Pan
2017-03-30 8:34 ` Boris Brezillon
2017-03-23 9:43 ` [PATCH v4 2/9] mtd: nand: make sure mtd_oob_ops consistent in bbt Peter Pan
2017-03-29 19:48 ` Boris Brezillon
2017-03-23 9:43 ` [PATCH v4 3/9] mtd: nand: add more helpers in nand.h Peter Pan
2017-03-23 11:19 ` Marek Vasut
2017-03-29 19:57 ` Boris Brezillon
2017-03-30 8:04 ` Peter Pan
2017-03-30 8:40 ` Boris Brezillon
2017-03-23 9:43 ` [PATCH v4 4/9] nand: spi: add basic blocks for infrastructure Peter Pan
2017-03-23 11:29 ` Marek Vasut
2017-03-23 15:40 ` Boris Brezillon
2017-03-23 16:33 ` Marek Vasut
2017-03-30 12:25 ` Arnaud Mouiche
2017-03-30 12:52 ` Boris Brezillon
2017-03-29 22:28 ` Cyrille Pitchen
2017-03-30 12:38 ` Arnaud Mouiche
2017-03-30 12:51 ` Boris Brezillon
2017-03-23 9:43 ` [PATCH v4 5/9] nand: spi: add basic operations support Peter Pan
2017-03-23 9:43 ` [PATCH v4 6/9] nand: spi: Add bad block support Peter Pan
2017-03-23 9:43 ` [PATCH v4 7/9] nand: spi: add Micron spi nand support Peter Pan
2017-03-30 12:31 ` Arnaud Mouiche
2017-03-30 12:57 ` Boris Brezillon
2017-03-23 9:43 ` [PATCH v4 8/9] nand: spi: Add generic SPI controller support Peter Pan
2017-03-23 11:33 ` Marek Vasut
2017-03-28 1:38 ` Peter Pan
2017-03-29 21:37 ` Cyrille Pitchen
2017-03-30 8:28 ` Peter Pan
2017-03-23 9:43 ` [PATCH v4 9/9] MAINTAINERS: Add SPI NAND entry Peter Pan
2017-03-30 12:17 ` [PATCH v4 0/9] Introduction to SPI NAND framework Arnaud Mouiche
2017-04-10 7:33 ` Peter Pan
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=20170329213427.280c26bb@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=arnaud.mouiche@gmail.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@atmel.com \
--cc=linshunquan1@hisilicon.com \
--cc=linux-mtd@lists.infradead.org \
--cc=marex@denx.de \
--cc=peterpandong@micron.com \
--cc=peterpansjtu@gmail.com \
--cc=richard@nod.at \
--cc=thomas.petazzoni@free-electrons.com \
/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