linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: gpmi: fall back to legacy mode if no ECC information present
@ 2018-01-29 14:44 Stefan Agner
  2018-01-30 13:23 ` Boris Brezillon
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Agner @ 2018-01-29 14:44 UTC (permalink / raw)
  To: han.xu, boris.brezillon
  Cc: marek.vasut, richard, dwmw2, cyrille.pitchen, max.oss.09,
	linux-mtd, linux-kernel, Stefan Agner

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-02-06 15:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-29 14:44 [PATCH] mtd: nand: gpmi: fall back to legacy mode if no ECC information present Stefan Agner
2018-01-30 13:23 ` 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

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).