[PATCH 15/22] mtd: have mtd_read populate retlen always

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We currently populate retlen only on successful reads of more than zero
bytes, while Linux function with the same name populates it
unconditionally.

Mimic the Linux API for compatibility.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/mtd/core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 562443275fe6..c75c52dcb3a5 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -375,16 +375,15 @@ int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
 		.len = len,
 		.datbuf = buf,
 	};
-	int ret;
+	int ret = 0;
 
 	if (from < 0 || from >= mtd->size || len > mtd->size - from)
 		return -EINVAL;
-	if (!len)
-		return 0;
 
-	ret = mtd_read_oob(mtd, from, &ops);
+	if (len)
+		ret = mtd_read_oob(mtd, from, &ops);
+
 	*retlen = ops.retlen;
-
 	return ret;
 }
 
-- 
2.39.5





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux