<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 10 Mar 2021 at 14:57, Patrick Delaunay <<a href="mailto:patrick.delaunay@foss.st.com">patrick.delaunay@foss.st.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Fix the result of DFU_OP_WRITE operation in mtd_block_op function<br>
when mtd_lock is not supported (-EOPNOTSUPP) to avoid DFU stack<br>
error on the DFU manifestation of the MTD device, when<br>
dfu_flush_medium_mtd is called.<br>
<br>
Without this patch, dfu-util failed on dfuERROR state at the end<br>
of the write operation on the alternate even if MTD write<br>
opeartion is correctly performed.<br>
<br>
$> dfu-util -a 3 -D test.bin<br>
....<br>
DFU mode device DFU version 0110<br>
Device returned transfer size 4096<br>
Copying data from PC to DFU device<br>
....<br>
Download [=========================] 100% 225469 bytes<br>
Download done.<br>
state(10) = dfuERROR, status(14) = Something went wrong,<br>
but the device does not know what it was Done!<br>
<br>
Fixes: 65f3fc18fc1e ("dfu_mtd: Add provision to unlock mtd device")<br>
Signed-off-by: Patrick Delaunay <<a href="mailto:patrick.delaunay@foss.st.com" target="_blank">patrick.delaunay@foss.st.com</a>><br>
---<br></blockquote><div><br></div><div>Acked-by: Sughosh Ganu <<a href="mailto:sughosh.ganu@linaro.org">sughosh.ganu@linaro.org</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
drivers/dfu/dfu_mtd.c | 4 +++-<br>
1 file changed, 3 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/dfu/dfu_mtd.c b/drivers/dfu/dfu_mtd.c<br>
index ca67585a7e..ec40b8f6bb 100644<br>
--- a/drivers/dfu/dfu_mtd.c<br>
+++ b/drivers/dfu/dfu_mtd.c<br>
@@ -150,7 +150,9 @@ static int mtd_block_op(enum dfu_op op, struct dfu_entity *dfu,<br>
/* Write done, lock again */<br>
debug("Locking the mtd device\n");<br>
ret = mtd_lock(mtd, lock_ofs, lock_len);<br>
- if (ret && ret != -EOPNOTSUPP)<br>
+ if (ret == -EOPNOTSUPP)<br>
+ ret = 0;<br>
+ else if (ret)<br>
printf("MTD device lock failed\n");<br>
}<br>
return ret;<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div></div>