diff options
author | Patrick Delaunay <patrick.delaunay@foss.st.com> | 2021-05-18 16:12:12 +0300 |
---|---|---|
committer | Patrice Chotard <patrice.chotard@foss.st.com> | 2021-06-18 11:09:41 +0300 |
commit | d4710326c814ffbf84eab87dce8f8fd789b0da18 (patch) | |
tree | e32aae6b88ab806812fda4318bca456687e364c6 /drivers | |
parent | d4cb4025771e74dbf42c3aa0b6daa734f855928d (diff) | |
download | u-boot-d4710326c814ffbf84eab87dce8f8fd789b0da18.tar.xz |
dfu: add error callback
Add error callback in dfu stack to manage some board specific
behavior on DFU targets.
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/dfu/dfu.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 213a20e7bc..ff1859d946 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -45,6 +45,14 @@ __weak void dfu_initiated_callback(struct dfu_entity *dfu) } /* + * The purpose of the dfu_error_callback() function is to + * provide callback for dfu user + */ +__weak void dfu_error_callback(struct dfu_entity *dfu, const char *msg) +{ +} + +/* * The purpose of the dfu_usb_get_reset() function is to * provide information if after USB_DETACH request * being sent the dfu-util performed reset of USB @@ -342,6 +350,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) printf("%s: Wrong sequence number! [%d] [%d]\n", __func__, dfu->i_blk_seq_num, blk_seq_num); dfu_transaction_cleanup(dfu); + dfu_error_callback(dfu, "Wrong sequence number"); return -1; } @@ -366,6 +375,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) ret = dfu_write_buffer_drain(dfu); if (ret) { dfu_transaction_cleanup(dfu); + dfu_error_callback(dfu, "DFU write error"); return ret; } } @@ -375,6 +385,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) pr_err("Buffer overflow! (0x%p + 0x%x > 0x%p)\n", dfu->i_buf, size, dfu->i_buf_end); dfu_transaction_cleanup(dfu); + dfu_error_callback(dfu, "Buffer overflow"); return -1; } @@ -386,6 +397,7 @@ int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) ret = dfu_write_buffer_drain(dfu); if (ret) { dfu_transaction_cleanup(dfu); + dfu_error_callback(dfu, "DFU write error"); return ret; } } |