Commit 0339f62a authored by ZhaoLong Wang's avatar ZhaoLong Wang Committed by Miquel Raynal

mtd: Add WARN_ON_ONCE() to mtd_read() to check the return value

If the driver cannot read all the requested data, -EBADMSG or
-EUCLEAN should never be returned.

Add a WARN_ON_ONCE() to help driver developers detect this error.
Signed-off-by: default avatarZhaoLong Wang <wangzhaolong1@huawei.com>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20230926065733.3240322-1-wangzhaolong1@huawei.com
parent 3cff177f
......@@ -1505,6 +1505,8 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
ret = mtd_read_oob(mtd, from, &ops);
*retlen = ops.retlen;
WARN_ON_ONCE(*retlen != len && mtd_is_bitflip_or_eccerr(ret));
return ret;
}
EXPORT_SYMBOL_GPL(mtd_read);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment