Skip to content

Commit f110ecd

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 855ddfd commit f110ecd

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
@@ -28,8 +28,10 @@ static u8 spi_nor_get_sr_tb_mask(struct spi_nor *nor)
2828
{
2929
if (nor->flags & SNOR_F_HAS_SR_TB_BIT6)
3030
return SR_TB_BIT6;
31-
else
31+
else if (nor->flags & SNOR_F_HAS_SR_TB)
3232
return SR_TB_BIT5;
33+
else
34+
return 0;
3335
}
3436

3537
static u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor)

0 commit comments

Comments
 (0)