Skip to contentSkip to conversation

mtd: core: print error code if registering NVMEM fails

PATCH In review Rafał Miłecki 2 participants 3 messages Mar 17, 2023 – Mar 20, 2023 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: core: print error code if registering NVMEM fails

From: Rafał Miłecki <[email protected]>

It's a common practice that helps debugging problems.

---
 drivers/mtd/mtdcore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/mtdcore.c +2 -1
index 83a22566a8ce..8303ce62c751 100644
@@ -539,7 +539,8 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 		if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) {
 			mtd->nvmem = NULL;
 		} else {
-			dev_err(&mtd->dev, "Failed to register NVMEM device\n");
+			dev_err(&mtd->dev, "Failed to register NVMEM device: %ld\n",
+				PTR_ERR(mtd->nvmem));
 			return PTR_ERR(mtd->nvmem);
 		}
 	}
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer
#1 lore raw

Hi Rafał,

[email protected] wrote on Fri, 17 Mar 2023 08:47:36 +0100:

Quoted 3 lines

From: Rafał Miłecki <[email protected]>

It's a common practice that helps debugging problems.

Totally agree. I actually sent a patch to avoid the error message upon EPROBE_DEFER which has the side effect of printing the error (thanks to the use of dev_err_probe()):

https://lore.kernel.org/linux-mtd/[email protected]/

Quoted 10 lines
---
 drivers/mtd/mtdcore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/mtdcore.c +0 -0
index 83a22566a8ce..8303ce62c751 100644

drivers/mtd/mtdcore.c static int mtd_nvmem_add(struct mtd_info *mtd) · line 546

Quoted 9 lines
drivers/mtd/mtdcore.c +2 -1
@@ -539,7 +539,8 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
 		if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) {
 			mtd->nvmem = NULL;
 		} else {
-			dev_err(&mtd->dev, "Failed to register NVMEM device\n");
+			dev_err(&mtd->dev, "Failed to register NVMEM device: %ld\n",
+				PTR_ERR(mtd->nvmem));
 			return PTR_ERR(mtd->nvmem);
 		}
 	}

Thanks,
Miquèl

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

#2 lore raw
Quoted 11 lines · Miquel Raynal

[email protected] wrote on Fri, 17 Mar 2023 08:47:36 +0100:

Quoted 3 lines

From: Rafał Miłecki <[email protected]>

It's a common practice that helps debugging problems.

Totally agree. I actually sent a patch to avoid the error message upon EPROBE_DEFER which has the side effect of printing the error (thanks to the use of dev_err_probe()):

https://lore.kernel.org/linux-mtd/[email protected]/

I see, thanks, we can drop this (my) patch.

Quoted 5 lines
Quoted 5 lines
---
  drivers/mtd/mtdcore.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 14 lines
Quoted 5 lines
drivers/mtd/mtdcore.c +0 -0
index 83a22566a8ce..8303ce62c751 100644

drivers/mtd/mtdcore.c static int mtd_nvmem_add(struct mtd_info *mtd) · line 546

Quoted 9 lines
drivers/mtd/mtdcore.c +2 -1
@@ -539,7 +539,8 @@ static int mtd_nvmem_add(struct mtd_info *mtd)
  		if (PTR_ERR(mtd->nvmem) == -EOPNOTSUPP) {
  			mtd->nvmem = NULL;
  		} else {
-			dev_err(&mtd->dev, "Failed to register NVMEM device\n");
+			dev_err(&mtd->dev, "Failed to register NVMEM device: %ld\n",
+				PTR_ERR(mtd->nvmem));
  			return PTR_ERR(mtd->nvmem);
  		}
  	}

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