[PATCH v2025.09.y 12/49] mtd: peb: mtd_peb_read(): move error message to caller
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Dec 19 01:20:48 PST 2025
From: Sascha Hauer <s.hauer at pengutronix.de>
Move the error message about a failure to read a PEB to the caller.
In some cases like for example i.MX6 with NAND boot it can happen
that mtd_peb_read() is called on the NAND blocks containing the FCB.
These are not protected with regular ECC, so are not readable. The error
message is expected and harmless. UBI needs this error message though,
so move it there. Other callers have their own error message already.
Link: https://lore.barebox.org/20251029131617.1607191-1-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
(cherry picked from commit 7605338da017da2492d83e919f7a88eefe4cd306)
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/mtd/peb.c | 2 +-
drivers/mtd/ubi/io.c | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c
index 840fc1799a38..10ccf188c798 100644
--- a/drivers/mtd/peb.c
+++ b/drivers/mtd/peb.c
@@ -239,7 +239,7 @@ int mtd_peb_read(struct mtd_info *mtd, void *buf, int pnum, int offset,
if (mtd_is_eccerr(err) && retries++ < MTD_IO_RETRIES)
goto retry;
- dev_err(&mtd->dev, "error %d%s while reading %d bytes from PEB %d:%d\n",
+ dev_dbg(&mtd->dev, "error %d%s while reading %d bytes from PEB %d:%d\n",
err, errstr, len, pnum, offset);
return err;
}
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 88df185789df..340a601426a0 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -115,6 +115,14 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
ret = mtd_peb_read(ubi->mtd, buf, pnum, offset, len);
if (mtd_is_bitflip(ret))
return UBI_IO_BITFLIPS;
+
+ if (ret) {
+ const char *errstr = mtd_is_eccerr(ret) ? " (ECC error)" : "";
+
+ ubi_err(ubi, "error %d%s while reading %d bytes from PEB %d:%d\n",
+ ret, errstr, len, pnum, offset);
+ }
+
return ret;
}
--
2.47.3
More information about the barebox
mailing list