Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: spinand: gigadevice: Fix the get ecc status issue

Some GigaDevice ecc_get_status functions use on-stack buffer for
spi_mem_op causes spi_mem_check_op failing, fix the issue by using
spinand scratchbuf.

Fixes: c40c7a990a46 ("mtd: spinand: Add support for GigaDevice GD5F1GQ4UExxG")
Signed-off-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20231108150701.593912-1-han.xu@nxp.com

authored by

Han Xu and committed by
Miquel Raynal
59950610 6613476e

+4 -2
+4 -2
drivers/mtd/nand/spi/gigadevice.c
··· 186 186 { 187 187 u8 status2; 188 188 struct spi_mem_op op = SPINAND_GET_FEATURE_OP(GD5FXGQXXEXXG_REG_STATUS2, 189 - &status2); 189 + spinand->scratchbuf); 190 190 int ret; 191 191 192 192 switch (status & STATUS_ECC_MASK) { ··· 207 207 * report the maximum of 4 in this case 208 208 */ 209 209 /* bits sorted this way (3...0): ECCS1,ECCS0,ECCSE1,ECCSE0 */ 210 + status2 = *(spinand->scratchbuf); 210 211 return ((status & STATUS_ECC_MASK) >> 2) | 211 212 ((status2 & STATUS_ECC_MASK) >> 4); 212 213 ··· 229 228 { 230 229 u8 status2; 231 230 struct spi_mem_op op = SPINAND_GET_FEATURE_OP(GD5FXGQXXEXXG_REG_STATUS2, 232 - &status2); 231 + spinand->scratchbuf); 233 232 int ret; 234 233 235 234 switch (status & STATUS_ECC_MASK) { ··· 249 248 * 1 ... 4 bits are flipped (and corrected) 250 249 */ 251 250 /* bits sorted this way (1...0): ECCSE1, ECCSE0 */ 251 + status2 = *(spinand->scratchbuf); 252 252 return ((status2 & STATUS_ECC_MASK) >> 4) + 1; 253 253 254 254 case STATUS_ECC_UNCOR_ERROR: