summaryrefslogtreecommitdiff
path: root/drivers/dfu
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2014-03-18 08:09:55 +0100
committerMarek Vasut <marex@denx.de>2014-03-23 02:20:09 +0100
commita2199afea169c1e13881ca90a02a28e4c9ffd114 (patch)
treee1659208cca3bededc225a383fe0cbe4c4710d53 /drivers/dfu
parent2c072c958bb544c72f0e848375803dbd6971f022 (diff)
downloadu-boot-imx-a2199afea169c1e13881ca90a02a28e4c9ffd114.zip
u-boot-imx-a2199afea169c1e13881ca90a02a28e4c9ffd114.tar.gz
u-boot-imx-a2199afea169c1e13881ca90a02a28e4c9ffd114.tar.bz2
usb, dfu: extract flush code into seperate function
move the flushing code into an extra function dfu_flush(), so it can be used from other code. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Marek Vasut <marex@denx.de> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Diffstat (limited to 'drivers/dfu')
-rw-r--r--drivers/dfu/dfu.c42
1 files changed, 24 insertions, 18 deletions
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index 07011e9..1aced26 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -126,6 +126,28 @@ static int dfu_write_buffer_drain(struct dfu_entity *dfu)
return ret;
}
+int dfu_flush(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
+{
+ int ret = 0;
+
+ if (dfu->flush_medium)
+ ret = dfu->flush_medium(dfu);
+
+ printf("\nDFU complete CRC32: 0x%08x\n", dfu->crc);
+
+ /* clear everything */
+ dfu_free_buf();
+ dfu->crc = 0;
+ dfu->offset = 0;
+ dfu->i_blk_seq_num = 0;
+ dfu->i_buf_start = dfu_buf;
+ dfu->i_buf_end = dfu_buf;
+ dfu->i_buf = dfu->i_buf_start;
+ dfu->inited = 0;
+
+ return ret;
+}
+
int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
{
int ret = 0;
@@ -197,24 +219,8 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
}
/* end? */
- if (size == 0) {
- /* Now try and flush to the medium if needed. */
- if (dfu->flush_medium)
- ret = dfu->flush_medium(dfu);
- printf("\nDFU complete CRC32: 0x%08x\n", dfu->crc);
-
- /* clear everything */
- dfu_free_buf();
- dfu->crc = 0;
- dfu->offset = 0;
- dfu->i_blk_seq_num = 0;
- dfu->i_buf_start = dfu_buf;
- dfu->i_buf_end = dfu_buf;
- dfu->i_buf = dfu->i_buf_start;
-
- dfu->inited = 0;
-
- }
+ if (size == 0)
+ ret = dfu_flush(dfu, buf, size, blk_seq_num);
return ret = 0 ? size : ret;
}