提交 51fd8532 编写于 作者: C Chen-Tsung Hsieh 提交者: Zheng Zengkai

mtd: spi-nor: core: Check written SR value in spi_nor_write_16bit_sr_and_check()

stable inclusion
from stable-v5.10.121
commit 0e1cd4edefc8baeaea51aa39f85645516263eca9
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0e1cd4edefc8baeaea51aa39f85645516263eca9

--------------------------------

[ Upstream commit 70dd83d7 ]

Read back Status Register 1 to ensure that the written byte match the
received value and return -EIO if read back test failed.

Without this patch, spi_nor_write_16bit_sr_and_check() only check the
second half of the 16bit. It causes errors like spi_nor_sr_unlock()
return success incorrectly when spi_nor_write_16bit_sr_and_check()
doesn't write SR successfully.

Fixes: 39d1e334 ("mtd: spi-nor: Fix clearing of QE bit on lock()/unlock()")
Signed-off-by: NChen-Tsung Hsieh <chentsung@chromium.org>
Signed-off-by: NPratyush Yadav <p.yadav@ti.com>
Reviewed-by: NMichael Walle <michael@walle.cc>
Reviewed-by: NTudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: NPratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20220126073227.3401275-1-chentsung@chromium.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 e96c6693
...@@ -827,6 +827,15 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1) ...@@ -827,6 +827,15 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1)
if (ret) if (ret)
return ret; return ret;
ret = spi_nor_read_sr(nor, sr_cr);
if (ret)
return ret;
if (sr1 != sr_cr[0]) {
dev_dbg(nor->dev, "SR: Read back test failed\n");
return -EIO;
}
if (nor->flags & SNOR_F_NO_READ_CR) if (nor->flags & SNOR_F_NO_READ_CR)
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册