Patch "mtd: spi-nor: core: Check written SR value in spi_nor_write_16bit_sr_and_check()" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

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

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mtd-spi-nor-core-check-written-sr-value-in-spi_nor_w.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d2c2536ce8e562f0ef446cf03032186982900c87
Author: Chen-Tsung Hsieh <chentsung@xxxxxxxxxxxx>
Date:   Wed Jan 26 15:32:26 2022 +0800

    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@xxxxxxxxxxxx>
    Signed-off-by: Pratyush Yadav <p.yadav@xxxxxx>
    Reviewed-by: Michael Walle <michael@xxxxxxxx>
    Reviewed-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx>
    Acked-by: Pratyush Yadav <p.yadav@xxxxxx>
    Link: https://lore.kernel.org/r/20220126073227.3401275-1-chentsung@xxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index cc08bd707378..90f39aabc1ff 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -1007,6 +1007,15 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1)
 	if (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)
 		return 0;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux