Skip to contentSkip to conversation

mtd: spi-nor: Check bus width while setting QE bit

PATCH In review Hsin-Yi Wang 3 participants 3 messages Aug 18, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 mtd: spi-nor: Check bus width while setting QE bit

spi_nor_write_16bit_sr_and_check() should also check if bus width is 4 before setting QE bit.

Fixes 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit on lock()/unlock()")

---
v2: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/mtd/spi-nor/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +3 -1
index 614960c7d22cc..1328128dfe65c 100644
@@ -870,7 +870,9 @@ static int spi_nor_write_16bit_sr_and_check(struct spi_nor *nor, u8 sr1)
 		ret = spi_nor_read_cr(nor, &sr_cr[1]);
 		if (ret)
 			return ret;
-	} else if (nor->params->quad_enable) {
+	} else if (spi_nor_get_protocol_width(nor->read_proto) == 4 &&
+		   spi_nor_get_protocol_width(nor->write_proto) == 4 &&
+		   nor->params->quad_enable) {
 		/*
 		 * If the Status Register 2 Read command (35h) is not
 		 * supported, we should at least be sure we don't
Signature · 6 lines
2.42.0.rc1.204.g551eb34607-goog


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Reviewed-by on v3 1/1
#1 lore raw
Quoted 7 lines

spi_nor_write_16bit_sr_and_check() should also check if bus width is 4 before setting QE bit.

Fixes 39d1e3340c73 ("mtd: spi-nor: Fix clearing of QE bit on lock()/unlock()")

I'm not sure if the comment beneath needs an update, too.

In any case:

Quoted 21 lines

---
v2: https://lore.kernel.org/lkml/[email protected]/

---
 drivers/mtd/spi-nor/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +3 -1
index 614960c7d22cc..1328128dfe65c 100644
@@ -870,7 +870,9 @@ static int spi_nor_write_16bit_sr_and_check(struct 
 spi_nor *nor, u8 sr1)
 		ret = spi_nor_read_cr(nor, &sr_cr[1]);
 		if (ret)
 			return ret;
-	} else if (nor->params->quad_enable) {
+	} else if (spi_nor_get_protocol_width(nor->read_proto) == 4 &&
+		   spi_nor_get_protocol_width(nor->write_proto) == 4 &&
+		   nor->params->quad_enable) {
 		/*
 		 * If the Status Register 2 Read command (35h) is not
Quoted 1 line

* supported, we should at least be sure we don't

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw
In reply to Hsin-Yi Wang
Quoted 4 lines · Hsin-Yi Wang

spi_nor_write_16bit_sr_and_check() should also check if bus width is 4 before setting QE bit.

Updated comment in the code and
applied to git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git,
spi-nor/next branch. Thanks!

[1/1] mtd: spi-nor: Check bus width while setting QE bit

      https://git.kernel.org/mtd/c/f01d8155a92e

Cheers,

Signature · 5 lines
Tudor Ambarus <[email protected]>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/