mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@kernel.org>
To: barebox@lists.infradead.org
Cc: Wolfram Sang <wsa@kernel.org>
Subject: [PATCH 2/3] mtd: nand: atmel: legacy: use proper ecc_shift
Date: Sun, 19 Mar 2023 16:49:08 +0100	[thread overview]
Message-ID: <20230319154909.24047-3-wsa@kernel.org> (raw)
In-Reply-To: <20230319154909.24047-1-wsa@kernel.org>

The logic of the ternary operator is broken because '1 << x' is always
true even if 'x' is 0. Convert the logic to really use either the pdata
value or a sane default. Fixes "WARNING: Total number of ECC bytes
exceeded oobsize" on my USB-A9G20.

Fixes: babffbb193 ("mtd: atmel_nand: Add per board ECC setup")
Signed-off-by: Wolfram Sang <wsa@kernel.org>
---

The other option is to revert babffbb193. I don't see any user. The code
was obviously not enough tested as well.

 drivers/mtd/nand/atmel/legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/atmel/legacy.c b/drivers/mtd/nand/atmel/legacy.c
index ea1fd64ad8..184cf465e3 100644
--- a/drivers/mtd/nand/atmel/legacy.c
+++ b/drivers/mtd/nand/atmel/legacy.c
@@ -1240,7 +1240,7 @@ static int __init atmel_nand_probe(struct device *dev)
 
 	nand_chip->ecc.mode = pdata->ecc_mode;
 	nand_chip->ecc.strength = pdata->ecc_strength ? : 1;
-	nand_chip->ecc.size = 1 << pdata->ecc_size_shift ? : 512;
+	nand_chip->ecc.size = 1 << (pdata->ecc_size_shift ? : 9);
 
 	if (pdata->ecc_mode == NAND_ECC_HW) {
 		nand_chip->ecc.mode = NAND_ECC_HW;
-- 
2.35.1




  parent reply	other threads:[~2023-03-19 15:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-19 15:49 [PATCH 0/3] mtd: nand: atmel: legacy: fix boot on USB-A9G20 Wolfram Sang
2023-03-19 15:49 ` [PATCH 1/3] mtd: nand: atmel: legacy: add 'algo' to use Wolfram Sang
2023-03-19 15:49 ` Wolfram Sang [this message]
2023-03-19 15:49 ` [PATCH 3/3] mtd: nand: atmel: legacy: remove superfluous code Wolfram Sang
2023-03-19 18:51 ` [PATCH 0/3] mtd: nand: atmel: legacy: fix boot on USB-A9G20 Sam Ravnborg
2023-03-19 21:28   ` Wolfram Sang
2023-03-21  8:58     ` Sascha Hauer
2023-03-21  9:44       ` Alexander Dahl
2023-03-21 16:48         ` Sam Ravnborg
2023-03-21 17:20       ` Wolfram Sang
2023-03-21 19:02         ` Sam Ravnborg
2023-03-21 20:53           ` Sam Ravnborg
2023-03-21 21:42             ` Wolfram Sang
2023-03-22  7:37               ` Sascha Hauer
2023-04-27 17:25           ` Wolfram Sang
2023-04-27 17:26       ` Wolfram Sang
2023-03-22  7:41 ` Sascha Hauer

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=20230319154909.24047-3-wsa@kernel.org \
    --to=wsa@kernel.org \
    --cc=barebox@lists.infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox