Skip to contentSkip to conversation

drivers:dfu: dfu_flush(): add raw data flush to complete dfu write

PATCH New Przemyslaw Marczak 2 participants 3 messages May 12, 2014 – May 14, 2014 USB

lore
Share & tools
lore
#0 lore raw

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.

Cc Lukasz Majewski <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Marek Vasut <[email protected]>
---
 drivers/dfu/dfu.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/dfu/dfu.c +4 -0
index 51b1026..a938109 100644
@@ -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
#1 lore raw

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.

Cc Lukasz Majewski <[email protected]>
Cc Heiko Schocher <[email protected]>
Cc Marek Vasut <[email protected]>
---
 drivers/usb/gadget/f_thor.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/usb/gadget/f_thor.c +3 -9
index feef9e4..28f215e 100644
@@ -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
Applied
#2 lore raw

PATCH 1/2 drivers:dfu: dfu_flush(): add raw data flush to complete dfu write

In reply to Przemyslaw Marczak
Quoted 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 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.

Applied both, thanks.

Best regards,
Marek Vasut