linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* wrong log on NOR
@ 2018-06-06 12:36 Michele Dionisio
  2018-06-07  8:42 ` Miquel Raynal
  0 siblings, 1 reply; 2+ messages in thread
From: Michele Dionisio @ 2018-06-06 12:36 UTC (permalink / raw)
  To: linux-mtd

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

Hi all,
with version v2.0.2 working on NOR I have not so nice log message that say:

ECCGETLAYOUT ioctl request failed

but on NOR is useless to try to read OBB so I suggest to apply the
attached patch.

regards

[-- Attachment #2: 0000_remove_reading_oob_from_nand.patch --]
[-- Type: text/x-patch, Size: 2790 bytes --]

diff --git a/lib/libmtd.c b/lib/libmtd.c
index 7382229..99fcb1b 100644
--- a/lib/libmtd.c
+++ b/lib/libmtd.c
@@ -763,6 +763,7 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
 	if (ret < 0)
 		return -1;
 	((char *)mtd->type_str)[ret - 1] = '\0';
+	mtd->type = type_str2int(mtd->type_str);
 
 	if (dev_read_pos_int(lib->mtd_eb_size, mtd_num, &mtd->eb_size))
 		return -1;
@@ -774,14 +775,20 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
 		return -1;
 	if (dev_read_pos_int(lib->mtd_oob_size, mtd_num, &mtd->oob_size))
 		return -1;
-	if (dev_read_pos_int(lib->mtd_oobavail, mtd_num, &mtd->oobavail)) {
-		/*
-		 * Fail to access oobavail sysfs file,
-		 * try ioctl ECCGETLAYOUT. */
-		mtd->oobavail = legacy_get_mtd_oobavail1(mtd_num);
-		/* Set 0 as default if can not get valid ecc layout */
-		if (mtd->oobavail < 0)
-			mtd->oobavail = 0;
+	if (mtd->type != MTD_NORFLASH) {
+		if (dev_read_pos_int(lib->mtd_oobavail, mtd_num, &mtd->oobavail)) {
+			/*
+			 * Fail to access oobavail sysfs file,
+			 * try ioctl ECCGETLAYOUT. */
+			mtd->oobavail = legacy_get_mtd_oobavail1(mtd_num);
+			/* Set 0 as default if can not get valid ecc layout */
+			if (mtd->oobavail < 0) {
+				mtd->oobavail = 0;
+				errmsg("not possible to get oob for mtd_num %d (type: %d %s)", mtd_num, mtd->type, mtd->type_str);
+			}
+		}
+	} else {
+		mtd->oobavail = 0;
 	}
 	if (dev_read_pos_int(lib->mtd_region_cnt, mtd_num, &mtd->region_cnt))
 		return -1;
@@ -790,7 +797,6 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
 	mtd->writable = !!(ret & MTD_WRITEABLE);
 
 	mtd->eb_cnt = mtd->size / mtd->eb_size;
-	mtd->type = type_str2int(mtd->type_str);
 	mtd->bb_allowed = !!(mtd->type == MTD_NANDFLASH ||
 				mtd->type == MTD_MLCNANDFLASH);
 
diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
index 97fef04..a882e52 100644
--- a/lib/libmtd_legacy.c
+++ b/lib/libmtd_legacy.c
@@ -235,7 +235,7 @@ int legacy_get_mtd_oobavail(const char *node)
 
 	ret = ioctl(fd, ECCGETLAYOUT, &usrlay);
 	if (ret < 0) {
-		sys_errmsg("ECCGETLAYOUT ioctl request failed");
+		sys_errmsg("ECCGETLAYOUT ioctl request failed on \"%s\"", node);
 		goto out_close;
 	}
 
@@ -375,8 +375,17 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
 
 	close(fd);
 
-	ret = legacy_get_mtd_oobavail(node);
-	mtd->oobavail = ret > 0 ? ret : 0;
+	if (mtd->type != MTD_NORFLASH) {
+		ret = legacy_get_mtd_oobavail(node);
+		if (ret < 0) {
+			mtd->oobavail = 0;
+			errmsg("not possible to get oob for mtd_num %d (type: %d %s)", mtd->mtd_num, mtd->type, mtd->type_str);
+		} else {
+			mtd->oobavail = ret;
+		}
+	} else {
+		mtd->oobavail = 0;
+	}
 
 	/*
 	 * Unfortunately, the device name is not available via ioctl, and

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

* Re: wrong log on NOR
  2018-06-06 12:36 wrong log on NOR Michele Dionisio
@ 2018-06-07  8:42 ` Miquel Raynal
  0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2018-06-07  8:42 UTC (permalink / raw)
  To: Michele Dionisio; +Cc: linux-mtd

Hi Michele,

On Wed, 6 Jun 2018 14:36:42 +0200, Michele Dionisio
<michele.dionisio@gmail.com> wrote:

> Hi all,
> with version v2.0.2 working on NOR I have not so nice log message that say:
> 
> ECCGETLAYOUT ioctl request failed
> 
> but on NOR is useless to try to read OBB so I suggest to apply the
> attached patch.

Thanks a lot for contributing.

As depicted in Documentation/process/submitting-patches.rst, could you
please re-send your patch inline (no attachments) to ease the review
process?

Don't forget to add a proper title and commit message.

Thank you,
Miquèl

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

end of thread, other threads:[~2018-06-07  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06 12:36 wrong log on NOR Michele Dionisio
2018-06-07  8:42 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).