diff mbox series

[4/4] Partitioning handlers: signal when they have completed

Message ID 20230228124709.2629819-4-sbabic@denx.de
State Accepted
Headers show
Series [1/4] Revert "core/stream_interface.c: increment progress step" | expand

Commit Message

Stefano Babic Feb. 28, 2023, 12:47 p.m. UTC
Handlers must signal the core when they have finished or which percent
was already completed. This allows to maintain the progress interface in
sync and to show the correct step during the update.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---
 handlers/diskformat_handler.c |  7 +++++++
 handlers/diskpart_handler.c   | 26 ++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)
diff mbox series

Patch

diff --git a/handlers/diskformat_handler.c b/handlers/diskformat_handler.c
index bf236b2..d4c4520 100644
--- a/handlers/diskformat_handler.c
+++ b/handlers/diskformat_handler.c
@@ -11,6 +11,7 @@ 
 #include <handler.h>
 #include <blkid/blkid.h>
 #include <fs_interface.h>
+#include "progress.h"
 
 void diskformat_handler(void);
 
@@ -51,6 +52,12 @@  static int diskformat(struct img_type *img,
 
 	/* File system does not exist, create new file system */
 	ret = diskformat_mkfs(img->device, fstype);
+
+	/*
+	 * Declare that handler has finished
+	 */
+	swupdate_progress_update(100);
+
 	return ret;
 }
 
diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index e4da184..316db56 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -25,6 +25,7 @@ 
 #include "swupdate.h"
 #include "handler.h"
 #include "util.h"
+#include "progress.h"
 
 void diskpart_handler(void);
 void diskpart_toggle_boot(void);
@@ -1140,6 +1141,11 @@  handler_release:
 	if (createtable)
 		free(createtable);
 
+	/*
+	 * Declare that handler has finished
+	 */
+	swupdate_progress_update(100);
+
 	return ret;
 }
 
@@ -1444,6 +1450,11 @@  handler_release:
 	if (createtable)
 		free(createtable);
 
+	/*
+	 * Declare that handler has finished
+	 */
+	swupdate_progress_update(100);
+
 	return ret;
 }
 
@@ -1542,6 +1553,11 @@  toggle_boot_exit:
 	if (cxt)
 		diskpart_unref_context(cxt);
 
+	/*
+	 * Declare that handler has finished
+	 */
+	swupdate_progress_update(100);
+
 	return ret;
 }
 
@@ -1668,6 +1684,11 @@  static int gpt_swap_partition(struct img_type *img, void *data)
 		goto handler_exit;
 	}
 
+	/*
+	 * Declare that handler has finished
+	 */
+	swupdate_progress_update(100);
+
 handler_exit:
 	if (tb)
 		diskpart_unref_table(tb);
@@ -1688,6 +1709,11 @@  handler_release:
 	 */
 	diskpart_reread_partition(img->device);
 
+	/*
+	 * Declare that handler has finished
+	 */
+	swupdate_progress_update(100);
+
 	return ret;
 }