All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] mtd: core: Handle unsupported OTP operations
@ 2024-03-13 17:34 ` Aapo Vienamo
  0 siblings, 0 replies; 12+ messages in thread
From: Aapo Vienamo @ 2024-03-13 17:34 UTC (permalink / raw)
  To: mwalle, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg, Aapo Vienamo

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(-)

-- 
2.41.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 0/2] mtd: core: Handle unsupported OTP operations
@ 2024-03-13 17:34 ` Aapo Vienamo
  0 siblings, 0 replies; 12+ messages in thread
From: Aapo Vienamo @ 2024-03-13 17:34 UTC (permalink / raw)
  To: mwalle, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg, Aapo Vienamo

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(-)

-- 
2.41.0


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
  2024-03-13 17:34 ` Aapo Vienamo
@ 2024-03-13 17:34   ` Aapo Vienamo
  -1 siblings, 0 replies; 12+ messages in thread
From: Aapo Vienamo @ 2024-03-13 17:34 UTC (permalink / raw)
  To: mwalle, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg, Aapo Vienamo

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.

Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Michael Walle <mwalle@kernel.org>
Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
---
 drivers/mtd/mtdcore.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 5887feb347a4..c365c97e7232 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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,
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 1/2] mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
@ 2024-03-13 17:34   ` Aapo Vienamo
  0 siblings, 0 replies; 12+ messages in thread
From: Aapo Vienamo @ 2024-03-13 17:34 UTC (permalink / raw)
  To: mwalle, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg, Aapo Vienamo

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.

Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Michael Walle <mwalle@kernel.org>
Fixes: 4b361cfa8624 ("mtd: core: add OTP nvmem provider support")
---
 drivers/mtd/mtdcore.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 5887feb347a4..c365c97e7232 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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,
-- 
2.41.0


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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
  2024-03-13 17:34 ` Aapo Vienamo
@ 2024-03-13 17:34   ` Aapo Vienamo
  -1 siblings, 0 replies; 12+ messages in thread
From: Aapo Vienamo @ 2024-03-13 17:34 UTC (permalink / raw)
  To: mwalle, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg, Aapo Vienamo

Handle 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.

Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/mtd/mtdcore.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c365c97e7232..9e18422fdc77 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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;
 }
 
 /**
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
@ 2024-03-13 17:34   ` Aapo Vienamo
  0 siblings, 0 replies; 12+ messages in thread
From: Aapo Vienamo @ 2024-03-13 17:34 UTC (permalink / raw)
  To: mwalle, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg, Aapo Vienamo

Handle 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.

Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/mtd/mtdcore.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index c365c97e7232..9e18422fdc77 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -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;
 }
 
 /**
-- 
2.41.0


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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
  2024-03-13 17:34   ` Aapo Vienamo
@ 2024-03-18 14:07     ` Michael Walle
  -1 siblings, 0 replies; 12+ messages in thread
From: Michael Walle @ 2024-03-18 14:07 UTC (permalink / raw)
  To: Aapo Vienamo, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg

[-- Attachment #1: Type: text/plain, Size: 757 bytes --]

On Wed Mar 13, 2024 at 6:34 PM CET, Aapo Vienamo wrote:
> Handle 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.
>
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
@ 2024-03-18 14:07     ` Michael Walle
  0 siblings, 0 replies; 12+ messages in thread
From: Michael Walle @ 2024-03-18 14:07 UTC (permalink / raw)
  To: Aapo Vienamo, miquel.raynal, richard, vigneshr, linux-mtd, linux-kernel
  Cc: mika.westerberg


[-- Attachment #1.1: Type: text/plain, Size: 757 bytes --]

On Wed Mar 13, 2024 at 6:34 PM CET, Aapo Vienamo wrote:
> Handle 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.
>
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

Reviewed-by: Michael Walle <mwalle@kernel.org>

-michael

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

[-- Attachment #2: Type: text/plain, Size: 144 bytes --]

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
  2024-03-13 17:34   ` Aapo Vienamo
@ 2024-03-25 10:18     ` Miquel Raynal
  -1 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2024-03-25 10:18 UTC (permalink / raw)
  To: Aapo Vienamo, mwalle, miquel.raynal, richard, vigneshr,
	linux-mtd, linux-kernel
  Cc: mika.westerberg

On Wed, 2024-03-13 at 17:34:25 UTC, Aapo Vienamo wrote:
> Handle 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.
> 
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Michael Walle <mwalle@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported
@ 2024-03-25 10:18     ` Miquel Raynal
  0 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2024-03-25 10:18 UTC (permalink / raw)
  To: Aapo Vienamo, mwalle, miquel.raynal, richard, vigneshr,
	linux-mtd, linux-kernel
  Cc: mika.westerberg

On Wed, 2024-03-13 at 17:34:25 UTC, Aapo Vienamo wrote:
> Handle 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.
> 
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Michael Walle <mwalle@kernel.org>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
  2024-03-13 17:34   ` Aapo Vienamo
@ 2024-03-25 10:18     ` Miquel Raynal
  -1 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2024-03-25 10:18 UTC (permalink / raw)
  To: Aapo Vienamo, mwalle, miquel.raynal, richard, vigneshr,
	linux-mtd, linux-kernel
  Cc: mika.westerberg

On Wed, 2024-03-13 at 17:34:24 UTC, Aapo Vienamo wrote:
> 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.
> 
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Michael Walle <mwalle@kernel.org>
> 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

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/2] mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add()
@ 2024-03-25 10:18     ` Miquel Raynal
  0 siblings, 0 replies; 12+ messages in thread
From: Miquel Raynal @ 2024-03-25 10:18 UTC (permalink / raw)
  To: Aapo Vienamo, mwalle, miquel.raynal, richard, vigneshr,
	linux-mtd, linux-kernel
  Cc: mika.westerberg

On Wed, 2024-03-13 at 17:34:24 UTC, Aapo Vienamo wrote:
> 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.
> 
> Signed-off-by: Aapo Vienamo <aapo.vienamo@linux.intel.com>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Michael Walle <mwalle@kernel.org>
> 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-03-25 10:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-13 17:34 [PATCH v2 0/2] mtd: core: Handle unsupported OTP operations Aapo Vienamo
2024-03-13 17:34 ` Aapo Vienamo
2024-03-13 17:34 ` [PATCH v2 1/2] mtd: core: Report error if first mtd_otp_size() call fails in mtd_otp_nvmem_add() Aapo Vienamo
2024-03-13 17:34   ` Aapo Vienamo
2024-03-25 10:18   ` Miquel Raynal
2024-03-25 10:18     ` Miquel Raynal
2024-03-13 17:34 ` [PATCH v2 2/2] mtd: core: Don't fail mtd_otp_nvmem_add() if OTP is unsupported Aapo Vienamo
2024-03-13 17:34   ` Aapo Vienamo
2024-03-18 14:07   ` Michael Walle
2024-03-18 14:07     ` Michael Walle
2024-03-25 10:18   ` Miquel Raynal
2024-03-25 10:18     ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.