summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2019-10-14 09:28:03 +0200
committerMarek Vasut <marek.vasut+renesas@gmail.com>2019-10-31 12:12:31 +0100
commit0de1022d885a4a637cae2955b4e32e1407696429 (patch)
tree7a36588f5a238dc2ea4fc47299047fcf19c54f42
parentfebabe3ed4f422a39e461ba4c2aff5f0fde6e4d2 (diff)
downloadu-boot-0de1022d885a4a637cae2955b4e32e1407696429.tar.gz
dfu: allow read with no data without error for EOF indication
This patch allows the DFU backend to indicate that that it can't provide no more data to fill the DFU buffer, by setting b_left =0 without error, even if the size of received data is lower of the expected total size indicated by get_medium_size. For USB DFU stack point of view, it is acceptable: the read length < requested size in DFU_UPLOAD and the transaction is stopped. That avoid infinite loop issue in dfu_read_buffer_fill because the size for the DFU read is limited by get_medium_size = r_left and the DFU stack expects that read is allowed up to this size. This issue never occurs for current flash device (where chunk are always completely read, and b_left will be never 0) but it is useful for virtual partition when the backend only know the max size of this alternate, the real size of the data are only known in the read treatment. PS: for file access on mmc, EOF is never reached as dfu_get_medium_size_mmc returns the exact size of the file. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
-rw-r--r--drivers/dfu/dfu.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 8bd5216017..50919fcae9 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -396,6 +396,8 @@ static int dfu_read_buffer_fill(struct dfu_entity *dfu, void *buf, int size)
debug("%s: Read error!\n", __func__);
return ret;
}
+ if (dfu->b_left == 0)
+ break;
dfu->offset += dfu->b_left;
dfu->r_left -= dfu->b_left;