Skip to content

Commit f4cb4d7

Browse files
Emillmiquelraynal
authored andcommitted
mtd: spinand: macronix: Fix ECC Status Read
The datasheet specifies the upper four bits are reserved. Testing on real hardware shows that these bits can indeed be nonzero. Signed-off-by: Emil Lenngren <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Signed-off-by: Miquel Raynal <[email protected]>
1 parent 67c8800 commit f4cb4d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/mtd/nand/spi/macronix.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/mtd/spinand.h>
1111

1212
#define SPINAND_MFR_MACRONIX 0xC2
13+
#define MACRONIX_ECCSR_MASK 0x0F
1314

1415
static SPINAND_OP_VARIANTS(read_cache_variants,
1516
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)
5556
SPI_MEM_OP_DUMMY(1, 1),
5657
SPI_MEM_OP_DATA_IN(1, eccsr, 1));
5758

58-
return spi_mem_exec_op(spinand->spimem, &op);
59+
int ret = spi_mem_exec_op(spinand->spimem, &op);
60+
if (ret)
61+
return ret;
62+
63+
*eccsr &= MACRONIX_ECCSR_MASK;
64+
return 0;
5965
}
6066

6167
static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand,

0 commit comments

Comments
 (0)