summaryrefslogtreecommitdiff
path: root/lib_generic/display_options.c
diff options
context:
space:
mode:
authorMarkus Klotzbuecher <mk@denx.de>2008-07-10 10:26:07 +0200
committerMarkus Klotzbuecher <mk@denx.de>2008-07-10 10:26:07 +0200
commit794a5924972fc8073616e98a2668da4a5f9aea90 (patch)
treedd0db39b3e183b5bcb0300d5377d7a0d5ac5fd0c /lib_generic/display_options.c
parentf2aeecc320f5b181b30effcaa67683aec8d5a843 (diff)
parent4188f0491886b3b486164e819c0a83fdb97efd7d (diff)
downloadu-boot-imx-794a5924972fc8073616e98a2668da4a5f9aea90.zip
u-boot-imx-794a5924972fc8073616e98a2668da4a5f9aea90.tar.gz
u-boot-imx-794a5924972fc8073616e98a2668da4a5f9aea90.tar.bz2
Merge branch 'master' of git://www.denx.de/git/u-boot
Diffstat (limited to 'lib_generic/display_options.c')
-rw-r--r--lib_generic/display_options.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/lib_generic/display_options.c b/lib_generic/display_options.c
index 5ddd94f..2dc2567 100644
--- a/lib_generic/display_options.c
+++ b/lib_generic/display_options.c
@@ -39,27 +39,35 @@ int display_options (void)
}
/*
- * print sizes as "xxx kB", "xxx.y kB", "xxx MB" or "xxx.y MB" as needed;
- * allow for optional trailing string (like "\n")
+ * print sizes as "xxx kB", "xxx.y kB", "xxx MB", "xxx.y MB",
+ * xxx GB, or xxx.y GB as needed; allow for optional trailing string
+ * (like "\n")
*/
-void print_size (ulong size, const char *s)
+void print_size (phys_size_t size, const char *s)
{
- ulong m, n;
- ulong d = 1 << 20; /* 1 MB */
- char c = 'M';
-
- if (size < d) { /* print in kB */
- c = 'k';
- d = 1 << 10;
+ ulong m = 0, n;
+ phys_size_t d = 1 << 30; /* 1 GB */
+ char c = 'G';
+
+ if (size < d) { /* try MB */
+ c = 'M';
+ d = 1 << 20;
+ if (size < d) { /* print in kB */
+ c = 'k';
+ d = 1 << 10;
+ }
}
n = size / d;
- m = (10 * (size - (n * d)) + (d / 2) ) / d;
+ /* If there's a remainder, deal with it */
+ if(size % d) {
+ m = (10 * (size - (n * d)) + (d / 2) ) / d;
- if (m >= 10) {
- m -= 10;
- n += 1;
+ if (m >= 10) {
+ m -= 10;
+ n += 1;
+ }
}
printf ("%2ld", n);