mtd: core: Handle unsupported OTP operations
v2 cover mtd: core: Handle unsupported OTP operations
Make MTD core tolerate SPI controllers without OTP support.
These changes address the issue that occurs when an OTP capable SPI NOR device is initialized with the Intel SPI controller. The limited supported opcode set of the SPI controller leads to failure in the OTP initialization, which in turn fails the probe for the MTD device. By allowing the MTD core to tolerate unsupported OTP, the rest of the MTD functionality remains intact even if OTP initialization is unsupported.
v2 changes:
- Move handling of -EOPNOTSUPP to mtd_otp_nvmem_add()
- Omit error message if -EOPNOTSUPP is returned
Aapo Vienamo (2):
mtd: core: Report error if first mtd_otp_size() call fails in
mtd_otp_nvmem_add()
mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
drivers/mtd/mtdcore.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.41.0
PATCH v2 1/2 mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
Jump to the error reporting code in mtd_otp_nvmem_add() if the mtd_otp_size() call fails. Without this fix, the error is not logged.
--- drivers/mtd/mtdcore.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/mtdcore.c +4 -2
@@ -956,8 +956,10 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd)if (mtd->_get_user_prot_info && mtd->_read_user_prot_reg) { size =mtd_otp_size (mtd, true); -if (size <0 ) -return size; +if (size <0 ) { + err = size; + goto err; + }if (size >0 ) { nvmem = mtd_otp_nvmem_register(mtd, "user-otp", size,
Signature · 1 line
2.41.0
Re: [PATCH v2 1/2] mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
Quoted 7 lines · Aapo Vienamo
Jump to the error reporting code in
mtd_otp_nvmem_add()if themtd_otp_size()call fails. Without this fix, the error is not logged.Signed-off-by Aapo Vienamo <[email protected]>Reviewed-by Mika Westerberg <[email protected]>Reviewed-by Michael Walle <[email protected]>Fixes 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
PATCH v2 2/2 mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
In reply to Aapo VienamoHandle the case where -EOPNOTSUPP is returned from OTP driver.
This addresses an issue that occurs with the Intel SPI flash controller, which has a limited supported opcode set. Whilst the OTP functionality is not available due to this restriction, other parts of the MTD functionality of the device are intact. This change allows the driver to gracefully handle the restriction by allowing the supported functionality to remain available instead of failing the probe altogether.
--- drivers/mtd/mtdcore.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mtd/mtdcore.c +5 -1
@@ -1014,7 +1014,11 @@ static int mtd_otp_nvmem_add(struct mtd_info *mtd) err:nvmem_unregister (mtd->otp_user_nvmem); -return dev_err_probe (dev, err,"Failed to register OTP NVMEM device\n" ); +/* Don't report error if OTP is not supported. */ +if (err != -EOPNOTSUPP ) +return dev_err_probe (dev, err, +"Failed to register OTP NVMEM device\n" ); +return 0 ; }/**
Signature · 1 line
2.41.0
Re: [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
Quoted 10 lines · Aapo Vienamo
Handle the case where
-EOPNOTSUPPis returned from OTP driver.This addresses an issue that occurs with the Intel SPI flash controller, which has a limited supported opcode set. Whilst the OTP functionality is not available due to this restriction, other parts of the MTD functionality of the device are intact. This change allows the driver to gracefully handle the restriction by allowing the supported functionality to remain available instead of failing the probe altogether.
Quoted 2 lines
Signed-off-by Aapo Vienamo <[email protected]>Reviewed-by Mika Westerberg <[email protected]>
-michael
Re: [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
In reply to Aapo VienamoQuoted 10 lines · Aapo Vienamo
Handle the case where
-EOPNOTSUPPis returned from OTP driver.This addresses an issue that occurs with the Intel SPI flash controller, which has a limited supported opcode set. Whilst the OTP functionality is not available due to this restriction, other parts of the MTD functionality of the device are intact. This change allows the driver to gracefully handle the restriction by allowing the supported functionality to remain available instead of failing the probe altogether.
Quoted 3 lines
Signed-off-by Aapo Vienamo <[email protected]>Reviewed-by Mika Westerberg <[email protected]>Reviewed-by Michael Walle <[email protected]>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel