fastboot: sparse: make write_sparse_image useable for non-fastboot
write_sparse_image could be useful for non-fastboot users.
For ex a platform, without usb-device/fastboot support, could
get sparse images over tftp and write using the mmc command.
Or non-android systems could also leverage the sparse format.
Towards that, this patch removes anything fastboot specific from
the write_sparse_image implementation. Which includes making the
function return integer as error code and calls for fastboot logging
via an optional callback function 'mssg'.
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 234ce83..46f0073 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -329,6 +329,7 @@
if (is_sparse_image(download_buffer)) {
struct fb_mmc_sparse sparse_priv;
struct sparse_storage sparse;
+ int err;
sparse_priv.dev_desc = dev_desc;
@@ -337,12 +338,15 @@
sparse.size = info.size;
sparse.write = fb_mmc_sparse_write;
sparse.reserve = fb_mmc_sparse_reserve;
+ sparse.mssg = fastboot_fail;
printf("Flashing sparse image at offset " LBAFU "\n",
sparse.start);
sparse.priv = &sparse_priv;
- write_sparse_image(&sparse, cmd, download_buffer);
+ err = write_sparse_image(&sparse, cmd, download_buffer);
+ if (!err)
+ fastboot_okay("");
} else {
write_raw_image(dev_desc, &info, cmd, download_buffer,
download_bytes);