All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	linux-mtd@lists.infradead.org,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Chen-Yu Tsai <wens@csie.org>,
	linux-sunxi@googlegroups.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support
Date: Fri, 22 Jan 2016 18:57:13 -0800	[thread overview]
Message-ID: <20160123025713.GA90611@google.com> (raw)
In-Reply-To: <1449054067-16751-4-git-send-email-boris.brezillon@free-electrons.com>

All three look good, so pushed to l2-mtd.git/next. One comment below:

On Wed, Dec 02, 2015 at 12:01:07PM +0100, Boris Brezillon wrote:

...

> +static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc)
> +{
> +	const u16 *seeds = sunxi_nfc_randomizer_page_seeds;
> +	int mod = mtd->erasesize / mtd->writesize;

Richard suggested you use the mtd.h helper here. Patch below.

> +
> +	if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds))
> +		mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds);
> +
> +	if (ecc) {
> +		if (mtd->ecc_step_size == 512)
> +			seeds = sunxi_nfc_randomizer_ecc512_seeds;
> +		else
> +			seeds = sunxi_nfc_randomizer_ecc1024_seeds;
> +	}
> +
> +	return seeds[page % mod];
> +}

From: Brian Norris <computersforpeace@gmail.com>
Date: Fri, 22 Jan 2016 18:54:02 -0800
Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper

Suggested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 5f700719d5c2..b5ea6b312df0 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -624,7 +624,7 @@ static u16 sunxi_nfc_randomizer_step(u16 state, int count)
 static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc)
 {
 	const u16 *seeds = sunxi_nfc_randomizer_page_seeds;
-	int mod = mtd->erasesize / mtd->writesize;
+	int mod = mtd_div_by_ws(mtd->erasesize, mtd);
 
 	if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds))
 		mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds);
-- 
2.7.0.rc3.207.g0ac5344

WARNING: multiple messages have this Message-ID (diff)
From: computersforpeace@gmail.com (Brian Norris)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support
Date: Fri, 22 Jan 2016 18:57:13 -0800	[thread overview]
Message-ID: <20160123025713.GA90611@google.com> (raw)
In-Reply-To: <1449054067-16751-4-git-send-email-boris.brezillon@free-electrons.com>

All three look good, so pushed to l2-mtd.git/next. One comment below:

On Wed, Dec 02, 2015 at 12:01:07PM +0100, Boris Brezillon wrote:

...

> +static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc)
> +{
> +	const u16 *seeds = sunxi_nfc_randomizer_page_seeds;
> +	int mod = mtd->erasesize / mtd->writesize;

Richard suggested you use the mtd.h helper here. Patch below.

> +
> +	if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds))
> +		mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds);
> +
> +	if (ecc) {
> +		if (mtd->ecc_step_size == 512)
> +			seeds = sunxi_nfc_randomizer_ecc512_seeds;
> +		else
> +			seeds = sunxi_nfc_randomizer_ecc1024_seeds;
> +	}
> +
> +	return seeds[page % mod];
> +}

From: Brian Norris <computersforpeace@gmail.com>
Date: Fri, 22 Jan 2016 18:54:02 -0800
Subject: [PATCH] mtd: nand: sunxi: use mtd_div_by_ws() helper

Suggested-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 drivers/mtd/nand/sunxi_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 5f700719d5c2..b5ea6b312df0 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -624,7 +624,7 @@ static u16 sunxi_nfc_randomizer_step(u16 state, int count)
 static u16 sunxi_nfc_randomizer_state(struct mtd_info *mtd, int page, bool ecc)
 {
 	const u16 *seeds = sunxi_nfc_randomizer_page_seeds;
-	int mod = mtd->erasesize / mtd->writesize;
+	int mod = mtd_div_by_ws(mtd->erasesize, mtd);
 
 	if (mod > ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds))
 		mod = ARRAY_SIZE(sunxi_nfc_randomizer_page_seeds);
-- 
2.7.0.rc3.207.g0ac5344

  reply	other threads:[~2016-01-23  2:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-02 11:01 [PATCH v2 0/3] mtd: nand: add randomizer support Boris Brezillon
2015-12-02 11:01 ` Boris Brezillon
2015-12-02 11:01 ` [PATCH v2 1/3] mtd: nand: add NAND_NEED_SCRAMBLING option flag Boris Brezillon
2015-12-02 11:01   ` Boris Brezillon
2015-12-02 11:01 ` [PATCH v2 2/3] mtd: nand: add NAND_NEED_SCRAMBLING flag to the H27UCG8T2ATR-BC definition Boris Brezillon
2015-12-02 11:01   ` Boris Brezillon
2015-12-02 11:01 ` [PATCH v2 3/3] mtd: nand: sunxi: add randomizer support Boris Brezillon
2015-12-02 11:01   ` Boris Brezillon
2016-01-23  2:57   ` Brian Norris [this message]
2016-01-23  2:57     ` Brian Norris
2016-01-23  8:18     ` Boris Brezillon
2016-01-23  8:18       ` Boris Brezillon
2016-01-23 20:55       ` Brian Norris
2016-01-23 20:55         ` Brian Norris
2016-01-11  9:13 ` [PATCH v2 0/3] mtd: nand: " Boris Brezillon
2016-01-11  9:13   ` Boris Brezillon

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=20160123025713.GA90611@google.com \
    --to=computersforpeace@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=richard@nod.at \
    --cc=wens@csie.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.