drivers:dfu: dfu_flush(): add raw data flush to complete dfu write
PATCH 1/2 drivers:dfu: dfu_flush(): add raw data flush to complete dfu write
Before dfu write and flush operations separation, dfu write data was flushed by host download request with len of zero size.
Since above change manually calling dfu write with zero size has non sense (e.g. in THOR). This should be done by flush operation.
So now dfu_write_buffer_drain() is called in dfu_flush(). If there is any raw data to flush (like it can be in thor) then it will be physically written to medium.
--- drivers/dfu/dfu.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/dfu/dfu.c +4 -0
@@ -131,6 +131,10 @@ int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) {int ret =0 ; + ret =dfu_write_buffer_drain (dfu); +if (ret) +return ret; +if (dfu->flush_medium) ret = dfu->flush_medium (dfu);
Signature · 1 line
1.9.1
PATCH 2/2 usb:gadget:f_thor: download_tail(): remove dfu_write with 0 size
Since dfu_flush() can write raw data, dfu_write() with zero size can be removed from download_tail() in thor gadget.
--- drivers/usb/gadget/f_thor.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/usb/gadget/f_thor.c +3 -9
@@ -219,21 +219,15 @@ static int download_tail(long long int left, int cnt) }/* -* To store last "packet" DFU storage backend requires dfu_write with -* size parameter equal to 0 +* To store last "packet" or write file from buffer to filesystem +* DFU storage backend requires dfu_flush * * This also frees memory malloc'ed by dfu_get_buf(), so no explicit * need fo call dfu_free_buf() is needed. */ - ret =dfu_write (dfu_entity, transfer_buffer,0 , cnt); -if (ret) -error ("DFU write failed [%d] cnt: %d" , ret, cnt); - ret =dfu_flush (dfu_entity, transfer_buffer,0 , cnt); -if (ret) { +if (ret)error ("DFU flush failed!" ); -return ret; - }return ret; }
Signature · 1 line
1.9.1
Marek Vasut
AppliedPATCH 1/2 drivers:dfu: dfu_flush(): add raw data flush to complete dfu write
In reply to Przemyslaw MarczakQuoted 10 lines · Przemyslaw Marczak
Before dfu write and flush operations separation, dfu write data was flushed by host download request with len of zero size.
Since above change manually calling dfu write with zero size has non sense (e.g. in THOR). This should be done by flush operation.
So nowdfu_write_buffer_drain()is called indfu_flush(). If there is any raw data to flush (like it can be in thor) then it will be physically written to medium.
Applied both, thanks.
Best regards,
Marek Vasut