[PATCH] mtd: spi-nor: Report missing SR2 support as -EOPNOTSUPP
From: Miquel Raynal
Date: Fri Dec 04 2026 - 06:08:59 EST
Commit 63489002d397 ("mtd: spi-nor: Refactor Read Status/Write Status
support") made spi_nor_read_sr2() return -EINVAL when opcodes.read_sr2
is unset. This does not only happen with flashes lacking SR2, but also
when the controller cannot issue the read opcode.
The OTP NVMEM registration path treats -EOPNOTSUPP as "OTP unsupported"
and ignores it, but not -EINVAL. Probe may therefore fail on Intel SPI
platforms with chips featuring an OTP region.
Return -EOPNOTSUPP instead, restoring the v7.3 behaviour for
spi_nor_otp_is_locked_sr2().
Fixes: 63489002d397 ("mtd: spi-nor: Refactor Read Status/Write Status support")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Alan Borzeszkowski <alan.borzeszkowski@xxxxxxxxxxxxxxx>
Closes: https://lore.kernel.org/linux-mtd/111cfeb5ffc603883b6573c62e49675bc3924b0a.camel@xxxxxxxxxxxxxxx/
Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>
---
Build tested only.
---
drivers/mtd/spi-nor/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index a04d22d2e2e1..2374e1f5fadb 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -842,7 +842,7 @@ int spi_nor_read_sr2(struct spi_nor *nor, u8 *sr2)
struct spi_nor_flash_parameter *params = nor->params;
if (!params->opcodes.read_sr2)
- return -EINVAL;
+ return -EOPNOTSUPP;
return spi_nor_read_sr_ll(nor, params->opcodes.read_sr2, sr2, 1);
}
---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261204-winbond-upstreaming-fix-sr2-einval-972091bb0c1f
Best regards,
--
Miquel Raynal <miquel.raynal@xxxxxxxxxxx>