summaryrefslogtreecommitdiffstats
path: root/lib/show_progress.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/show_progress.c')
-rw-r--r--lib/show_progress.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/lib/show_progress.c b/lib/show_progress.c
index a32a13c16d..1b624bcb9a 100644
--- a/lib/show_progress.c
+++ b/lib/show_progress.c
@@ -3,9 +3,6 @@
*
* Copyright (c) 2010 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
*
- * See file CREDITS for list of people who contributed to this
- * project.
- *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
@@ -20,15 +17,15 @@
#include <common.h>
#include <fs.h>
#include <progress.h>
-#include <asm-generic/div64.h>
+#include <linux/math64.h>
-#define HASHES_PER_LINE 65
+#define HASHES_PER_LINE 64
-static int printed;
-static int progress_max;
-static int spin;
+static loff_t printed;
+static loff_t progress_max;
+static unsigned spin;
-void show_progress(int now)
+void show_progress(loff_t now)
{
char spinchr[] = "\\|/-";
@@ -38,9 +35,8 @@ void show_progress(int now)
}
if (progress_max && progress_max != FILESIZE_MAX) {
- uint64_t tmp = (int64_t)now * HASHES_PER_LINE;
- do_div(tmp, progress_max);
- now = tmp;
+ uint64_t tmp = now * HASHES_PER_LINE;
+ now = div64_u64(tmp, progress_max);
}
while (printed < now) {
@@ -51,7 +47,7 @@ void show_progress(int now)
}
}
-void init_progression_bar(int max)
+void init_progression_bar(loff_t max)
{
printed = 0;
progress_max = max;
@@ -61,3 +57,31 @@ void init_progression_bar(int max)
else
printf("\t");
}
+
+NOTIFIER_HEAD(progress_notifier_list);
+
+static int progress_logger(struct notifier_block *r, unsigned long stage, void *_prefix)
+{
+ const char *prefix = _prefix;
+
+ switch ((enum progress_stage)stage) {
+ case PROGRESS_UPDATING:
+ pr_info("%sSoftware update in progress\n", prefix);
+ break;
+ case PROGRESS_UPDATE_SUCCESS:
+ pr_info("%sSoftware update finished successfully\n", prefix);
+ break;
+ case PROGRESS_UPDATE_FAIL:
+ pr_info("%sSoftware update failed\n", prefix);
+ break;
+ case PROGRESS_UNSPECIFIED:
+ /* default state. This should not be reached */
+ break;
+ }
+
+ return 0;
+}
+
+struct notifier_block progress_log_client = {
+ .notifier_call = progress_logger
+};