Skip to contentSkip to conversation

mtd: spi-nor: core: Add an error message when failing to exit the 4-byte address mode

PATCH Applied Tudor Ambarus 3 participants 5 messages Jul 28, 2022 – Oct 25, 2022

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

PATCH 1/1 mtd: spi-nor: core: Add an error message when failing to exit the 4-byte address mode

Add an error message when failing to exit the 4-byte address mode. Do not stop the execution and go through the spi_nor_soft_reset() method if used, in the hope that the flash will default to 3-byte address mode after the reset.

---
 drivers/mtd/spi-nor/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +2 -1
index f2c64006f8d7..1cdbdad97136 100644
@@ -2841,7 +2841,8 @@ void spi_nor_restore(struct spi_nor *nor)
 	/* restore the addressing mode */
 	if (nor->addr_nbytes == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
 	    nor->flags & SNOR_F_BROKEN_RESET)
-		nor->params->set_4byte_addr_mode(nor, false);
+		if (nor->params->set_4byte_addr_mode(nor, false))
+			dev_err(nor->dev, "Failed to exit 4-byte address mode\n");
 
 	if (nor->flags & SNOR_F_SOFT_RESET)
 		spi_nor_soft_reset(nor);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Tudor Ambarus

Add an error message when failing to exit the 4-byte address mode. Do not stop the execution and go through the spi_nor_soft_reset() method if used, in the hope that the flash will default to 3-byte address mode after the reset.

Quoted 21 lines
---
 drivers/mtd/spi-nor/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +2 -1
index f2c64006f8d7..1cdbdad97136 100644
@@ -2841,7 +2841,8 @@ void spi_nor_restore(struct spi_nor *nor)
 	/* restore the addressing mode */
 	if (nor->addr_nbytes == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
 	    nor->flags & SNOR_F_BROKEN_RESET)
-		nor->params->set_4byte_addr_mode(nor, false);
+		if (nor->params->set_4byte_addr_mode(nor, false))
+			dev_err(nor->dev, "Failed to exit 4-byte address mode\n");
 
 	if (nor->flags & SNOR_F_SOFT_RESET)
 		spi_nor_soft_reset(nor);
Signature · 1 line
2.25.1
Signature · 3 lines
Regards,
Pratyush Yadav
Texas Instruments Inc.
#2 lore raw
In reply to Tudor Ambarus

Hi,

Am 2022-07-28 05:01, schrieb Tudor Ambarus:

Quoted 16 lines

Add an error message when failing to exit the 4-byte address mode. Do not stop the execution and go through the spi_nor_soft_reset() method if used, in the hope that the flash will default to 3-byte address mode after the reset.

---
 drivers/mtd/spi-nor/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index f2c64006f8d7..1cdbdad97136 100644

drivers/mtd/spi-nor/core.c void spi_nor_restore(struct spi_nor *nor) · line 2845

Quoted 6 lines
drivers/mtd/spi-nor/core.c +2 -1
@@ -2841,7 +2841,8 @@ void spi_nor_restore(struct spi_nor *nor)
 	/* restore the addressing mode */
 	if (nor->addr_nbytes == 4 && !(nor->flags & SNOR_F_4B_OPCODES) &&
 	    nor->flags & SNOR_F_BROKEN_RESET)
-		nor->params->set_4byte_addr_mode(nor, false);
+		if (nor->params->set_4byte_addr_mode(nor, false))
+			dev_err(nor->dev, "Failed to exit 4-byte address mode\n");

Could we stick to the ususal pattern:

ret = func()
if (ret)
err("blubb (%d)", ret);

I know it is more lines but imho it makes the code much more readable. And that way you could also print the error code. You could also use dev_err("bla (%pe)\n", ERR_PTR(ret));

-michael

#3 lore raw
Quoted 33 lines · Michael Walle

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Hi,

Am 2022-07-28 05:01, schrieb Tudor Ambarus:

Quoted 20 lines

Add an error message when failing to exit the 4-byte address mode. Do not
stop the execution and go through the spi_nor_soft_reset() method if used,
in the hope that the flash will default to 3-byte address mode after the
reset.

---
 drivers/mtd/spi-nor/core.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +0 -0
index f2c64006f8d7..1cdbdad97136 100644
@@ -2841,7 +2841,8 @@ void spi_nor_restore(struct spi_nor *nor)
       /* restore the addressing mode */
Quoted 5 lines

      if (nor->addr_nbytes == 4 && !(nor->flags & SNOR_F_4B_OPCODES) && nor->flags & SNOR_F_BROKEN_RESET)
-             nor->params->set_4byte_addr_mode(nor, false);
+             if (nor->params->set_4byte_addr_mode(nor, false))
+                     dev_err(nor->dev, "Failed to exit 4-byte address mode\n");

Could we stick to the ususal pattern:

Quoted 8 lines

ret = func()
if (ret)
   err("blubb (%d)", ret);

I know it is more lines but imho it makes the code much more readable. And that way you could also print the error code. You could also use dev_err("bla (%pe)\n", ERR_PTR(ret));

sure, will do. Thanks.

author Applied
#4 lore raw
In reply to Tudor Ambarus
Quoted 6 lines · Tudor Ambarus

Add an error message when failing to exit the 4-byte address mode. Do not stop the execution and go through the spi_nor_soft_reset() method if used, in the hope that the flash will default to 3-byte address mode after the reset.

Applied to spi-nor/next, thanks!

[1/1] mtd: spi-nor: core: Add an error message when failing to exit the 4-byte address mode

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

Best regards,

Signature · 1 line
Tudor Ambarus <[email protected]>