mtd: spi-nor: core: Check written SR value in spi_nor_write_16bit_sr_and_check()
authorChen-Tsung Hsieh <chentsung@chromium.org>
Wed, 26 Jan 2022 07:32:26 +0000 (15:32 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:51 +0000 (10:22 +0200)
commitfad41a8f88567f693b0fb79e66a56a5b28fb0803
tree68e6fab6981bc70465165988760e58afd8daf1bb
parent32c7cbb75b368a3e2c2560b078c9778406823f2d
mtd: spi-nor: core: Check written SR value in spi_nor_write_16bit_sr_and_check()

[ Upstream commit 70dd83d737d8900b2d98db6dc6b928c596334d37 ]

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: 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit on lock()/unlock()")
Signed-off-by: Chen-Tsung Hsieh <chentsung@chromium.org>
Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Reviewed-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Pratyush Yadav <p.yadav@ti.com>
Link: https://lore.kernel.org/r/20220126073227.3401275-1-chentsung@chromium.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/spi-nor/core.c