Skip to content

Commit 834de5c

Browse files
ambarusrichardweinberger
authored andcommitted
mtd: spi-nor: Fix the disabling of write protection at init
spi_nor_spansion_clear_sr_bp() depends on spansion_quad_enable(). While spansion_quad_enable() is selected as default when initializing the flash parameters, the nor->quad_enable() method can be overwritten later on when parsing BFPT. Select the write protection disable mechanism at spi_nor_init() time, when the nor->quad_enable() method is already known. Fixes: 191f5c2 ("mtd: spi-nor: use 16-bit WRR command when QE is set on spansion flashes") Signed-off-by: Tudor Ambarus <[email protected]> Reviewed-by: Vignesh Raghavendra <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent d45331b commit 834de5c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3780,8 +3780,6 @@ static int spi_nor_init_params(struct spi_nor *nor,
37803780
default:
37813781
/* Kept only for backward compatibility purpose. */
37823782
params->quad_enable = spansion_quad_enable;
3783-
if (nor->clear_sr_bp)
3784-
nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
37853783
break;
37863784
}
37873785

@@ -4035,6 +4033,9 @@ static int spi_nor_init(struct spi_nor *nor)
40354033
int err;
40364034

40374035
if (nor->clear_sr_bp) {
4036+
if (nor->quad_enable == spansion_quad_enable)
4037+
nor->clear_sr_bp = spi_nor_spansion_clear_sr_bp;
4038+
40384039
err = nor->clear_sr_bp(nor);
40394040
if (err) {
40404041
dev_err(nor->dev,

0 commit comments

Comments
 (0)