Skip to content

Commit f5a0506

Browse files
maignialoliviermiquelraynal
authored andcommitted
mtd: spinand: winbond: Fix ecc_get_status
Reading ECC status is failing. w25n02kv_ecc_get_status() is using on-stack buffer for SPINAND_GET_FEATURE_OP() output. It is not suitable for DMA needs of spi-mem. Fix this by using the spi-mem operations dedicated buffer spinand->scratchbuf. See spinand->scratchbuf: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/mtd/spinand.h?h=v6.3#n418 spi_mem_check_op(): https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi-mem.c?h=v6.3#n199 Fixes: 6154c7a ("mtd: spinand: winbond: add Winbond W25N02KV flash support") Cc: stable@vger.kernel.org Signed-off-by: Olivier Maignial <olivier.maignial@hotmail.fr> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/DB4P250MB1032EDB9E36B764A33769039FE23A@DB4P250MB1032.EURP250.PROD.OUTLOOK.COM
1 parent 8544cda commit f5a0506

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/mtd/nand/spi/winbond.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
108108
{
109109
struct nand_device *nand = spinand_to_nand(spinand);
110110
u8 mbf = 0;
111-
struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, &mbf);
111+
struct spi_mem_op op = SPINAND_GET_FEATURE_OP(0x30, spinand->scratchbuf);
112112

113113
switch (status & STATUS_ECC_MASK) {
114114
case STATUS_ECC_NO_BITFLIPS:
@@ -126,7 +126,7 @@ static int w25n02kv_ecc_get_status(struct spinand_device *spinand,
126126
if (spi_mem_exec_op(spinand->spimem, &op))
127127
return nanddev_get_ecc_conf(nand)->strength;
128128

129-
mbf >>= 4;
129+
mbf = *(spinand->scratchbuf) >> 4;
130130

131131
if (WARN_ON(mbf > nanddev_get_ecc_conf(nand)->strength || !mbf))
132132
return nanddev_get_ecc_conf(nand)->strength;

0 commit comments

Comments
 (0)