[PATCH] mtd: spi-nor: micron-st: fix FSR read fallback for controllers returning -ENOTSUPP
From: Bean Huo
Date: Wed Mar 18 2026 - 09:55:19 EST
From: Bean Huo <beanhuo@xxxxxxxxxx>
micron_st_nor_ready() falls back to SR-only polling when the SPI
controller does not support low-level FSR reads, but only checks for
-EOPNOTSUPP (95). Some SPI master drivers return the kernel-internal
-ENOTSUPP (524) for the same condition. The two codes carry identical
semantics but have different numeric values, so the fallback is never
reached when the master returns -ENOTSUPP; the function propagates the
error instead, causing all subsequent erase/program operations on the
Micron flash to fail.
Fix this by treating -ENOTSUPP equivalently to -EOPNOTSUPP in the FSR
error path. Note that spi-mem.c already treats both error codes as
equivalent in its own fallback logic, so this aligns micron_st_nor_ready()
with that existing convention.
Fixes: 90c517f435a9 ("mtd: spi-nor: micron-st: Skip FSR reading if SPI controller does not support it")
Reported-by: Zailiang Zhang <zaizhang@xxxxxxxxx>
Signed-off-by: Bean Huo <beanhuo@xxxxxxxxxx>
---
drivers/mtd/spi-nor/micron-st.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/micron-st.c b/drivers/mtd/spi-nor/micron-st.c
index 88033384a71e..4be6a76fc3e5 100644
--- a/drivers/mtd/spi-nor/micron-st.c
+++ b/drivers/mtd/spi-nor/micron-st.c
@@ -598,7 +598,7 @@ static int micron_st_nor_ready(struct spi_nor *nor)
* operations to the software. If this is the case we use
* only the status register value.
*/
- return ret == -EOPNOTSUPP ? sr_ready : ret;
+ return (ret == -EOPNOTSUPP || ret == -ENOTSUPP) ? sr_ready : ret;
}
if (nor->bouncebuf[0] & (FSR_E_ERR | FSR_P_ERR)) {
--
2.34.1