Skip to content

Commit cca2c08

Browse files
DragonBluepgregkh
authored andcommitted
mtd: spi-nor: swp: check SR_TB flag when getting tb_mask
[ Upstream commit 94645aa ] When the chip does not support top/bottom block protect, the tb_mask must be set to 0, otherwise SR1 bit5 will be unexpectedly modified. Signed-off-by: Shiji Yang <yangshiji66@outlook.com> Fixes: 3dd8012 ("mtd: spi-nor: add TB (Top/Bottom) protect support") Reviewed-by: Michael Walle <mwalle@kernel.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b194ae6 commit cca2c08

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/mtd/spi-nor/swp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ static u8 spi_nor_get_sr_tb_mask(struct spi_nor *nor)
2727
{
2828
if (nor->flags & SNOR_F_HAS_SR_TB_BIT6)
2929
return SR_TB_BIT6;
30-
else
30+
else if (nor->flags & SNOR_F_HAS_SR_TB)
3131
return SR_TB_BIT5;
32+
else
33+
return 0;
3234
}
3335

3436
static u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor)

0 commit comments

Comments
 (0)