From: Stefan Agner <stefan@agner.ch>
To: han.xu@nxp.com, boris.brezillon@free-electrons.com
Cc: marek.vasut@gmail.com, richard@nod.at, dwmw2@infradead.org,
cyrille.pitchen@wedev4u.fr, max.oss.09@gmail.com,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Stefan Agner <stefan@agner.ch>
Subject: [PATCH] mtd: nand: gpmi: fall back to legacy mode if no ECC information present
Date: Mon, 29 Jan 2018 15:44:40 +0100 [thread overview]
Message-ID: <20180129144440.13648-1-stefan@agner.ch> (raw)
In case fsl,use-minimum-ecc is set, the driver tries to determine
ECC layout by using the ECC information provided by the MTD stack.
However, in case the NAND chip does not provide any information,
the driver currently fails with:
nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1
nand: Macronix NAND 128MiB 3,3V 8-bit
nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
gpmi-nand 1806000.gpmi-nand: Error setting BCH geometry : 1
gpmi-nand: probe of 1806000.gpmi-nand failed with error 1
Fall back to implementation specific default mode if no ECC
information are provided by the NAND chip and fsl,use-minimum-ecc
is specified.
This is more in line with what the device tree binding documentation
promises:
"However, note that if this strength is not
discoverable or this property is not enabled,
the software may chooses an implementation-defined
ECC scheme."
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
drivers/mtd/nand/gpmi-nand/gpmi-nand.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 50f8d4a1b983..7b8e8c629081 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -206,7 +206,7 @@ static int set_geometry_by_ecc_info(struct gpmi_nand_data *this)
unsigned int block_mark_bit_offset;
if (!(chip->ecc_strength_ds > 0 && chip->ecc_step_ds > 0))
- return -EINVAL;
+ return -ENOTSUPP;
switch (chip->ecc_step_ds) {
case SZ_512:
@@ -423,11 +423,15 @@ static int legacy_set_geometry(struct gpmi_nand_data *this)
int common_nfc_set_geometry(struct gpmi_nand_data *this)
{
- if ((of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
- || legacy_set_geometry(this))
- return set_geometry_by_ecc_info(this);
+ int ret = -ENOTSUPP;
- return 0;
+ if (of_property_read_bool(this->dev->of_node, "fsl,use-minimum-ecc"))
+ ret = set_geometry_by_ecc_info(this);
+
+ if (ret == -ENOTSUPP)
+ return legacy_set_geometry(this);
+
+ return ret;
}
struct dma_chan *get_dma_chan(struct gpmi_nand_data *this)
--
2.16.1
next reply other threads:[~2018-01-29 14:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-29 14:44 Stefan Agner [this message]
2018-01-30 13:23 ` [PATCH] mtd: nand: gpmi: fall back to legacy mode if no ECC information present Boris Brezillon
[not found] ` <d7a812de1b96be3460230efde4914ec1@agner.ch>
[not found] ` <20180131105705.17bbe858@bbrezillon>
2018-01-31 21:18 ` stefan
2018-02-05 22:16 ` stefan
2018-02-06 15:40 ` Boris Brezillon
2018-02-06 15:55 ` stefan
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=20180129144440.13648-1-stefan@agner.ch \
--to=stefan@agner.ch \
--cc=boris.brezillon@free-electrons.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=han.xu@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=max.oss.09@gmail.com \
--cc=richard@nod.at \
/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;
as well as URLs for NNTP newsgroup(s).