Skip to contentSkip to conversation

mtd: spinand: Fix Macronix ECC Status Read

PATCH In review Emil Lenngren 2 participants 3 messages Dec 20, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: spinand: Fix Macronix ECC Status Read

The datasheet specifies the upper four bits are reserved. Testing on real hardware shows that these bits can indeed be nonzero.

---
 drivers/mtd/nand/spi/macronix.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mtd/nand/spi/macronix.c +7 -1
index 98f6b9c4b6..d16b57081c 100644
@@ -10,6 +10,7 @@
 #include <linux/mtd/spinand.h>
 
 #define SPINAND_MFR_MACRONIX		0xC2
+#define MACRONIX_ECCSR_MASK		0x0F
 
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
@@ -55,7 +56,12 @@ static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
 					  SPI_MEM_OP_DUMMY(1, 1),
 					  SPI_MEM_OP_DATA_IN(1, eccsr, 1));
 
-	return spi_mem_exec_op(spinand->spimem, &op);
+	int ret = spi_mem_exec_op(spinand->spimem, &op);
+	if (ret)
+		return ret;
+
+	*eccsr &= MACRONIX_ECCSR_MASK;
+	return 0;
 }
 
 static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw

+Miquel

Hi Emil,

Can you please Cc the NAND and MTD maintainers next time?

Quoted 4 lines · On Thu, 20 Dec 2018 13:46:58 +0100 Emil Lenngren <[email protected]>…

The datasheet specifies the upper four bits are reserved. Testing on real hardware shows that these bits can indeed be nonzero.

Quoted 30 lines
---
 drivers/mtd/nand/spi/macronix.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mtd/nand/spi/macronix.c +7 -1
index 98f6b9c4b6..d16b57081c 100644
@@ -10,6 +10,7 @@
 #include <linux/mtd/spinand.h>
 
 #define SPINAND_MFR_MACRONIX		0xC2
+#define MACRONIX_ECCSR_MASK		0x0F
 
 static SPINAND_OP_VARIANTS(read_cache_variants,
 		SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
@@ -55,7 +56,12 @@ static int mx35lf1ge4ab_get_eccsr(struct spinand_device *spinand, u8 *eccsr)
 					  SPI_MEM_OP_DUMMY(1, 1),
 					  SPI_MEM_OP_DATA_IN(1, eccsr, 1));
 
-	return spi_mem_exec_op(spinand->spimem, &op);
+	int ret = spi_mem_exec_op(spinand->spimem, &op);
+	if (ret)
+		return ret;
+
+	*eccsr &= MACRONIX_ECCSR_MASK;
+	return 0;
 }
 
 static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,
#2 lore raw

Den tors 20 dec. 2018 kl 14:03 skrev Boris Brezillon <[email protected]>:

Quoted 6 lines

+Miquel

Hi Emil,

Can you please Cc the NAND and MTD maintainers next time?

Sure!