1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

Tidy up data sizes and function comment in display_options

Use inttypes.h and uint64_t to correct the code so that it will not issue
warnings on 64-bit machines where 'uint64_t' is 'unsigned long'.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2014-10-15 04:38:35 -06:00
committed by Tom Rini
parent 6bf6725962
commit c6da9ae8a4
2 changed files with 18 additions and 10 deletions

View File

@@ -253,7 +253,19 @@ int cpu_init(void);
/* */ /* */
phys_size_t initdram (int); phys_size_t initdram (int);
int display_options (void); int display_options (void);
void print_size(unsigned long long, const char *);
/**
* print_size() - Print a size with a suffic
*
* print sizes as "xxx KiB", "xxx.y KiB", "xxx MiB", "xxx.y MiB",
* xxx GiB, xxx.y GiB, etc as needed; allow for optional trailing string
* (like "\n")
*
* @size: Size to print
* @suffix String to print after the size
*/
void print_size(uint64_t size, const char *suffix);
int print_buffer(ulong addr, const void *data, uint width, uint count, int print_buffer(ulong addr, const void *data, uint width, uint count,
uint linelen); uint linelen);

View File

@@ -7,6 +7,7 @@
#include <config.h> #include <config.h>
#include <common.h> #include <common.h>
#include <inttypes.h>
#include <version.h> #include <version.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <asm/io.h> #include <asm/io.h>
@@ -21,15 +22,10 @@ int display_options (void)
return 0; return 0;
} }
/* void print_size(uint64_t size, const char *s)
* print sizes as "xxx KiB", "xxx.y KiB", "xxx MiB", "xxx.y MiB",
* xxx GiB, xxx.y GiB, etc as needed; allow for optional trailing string
* (like "\n")
*/
void print_size(unsigned long long size, const char *s)
{ {
unsigned long m = 0, n; unsigned long m = 0, n;
unsigned long long f; uint64_t f;
static const char names[] = {'E', 'P', 'T', 'G', 'M', 'K'}; static const char names[] = {'E', 'P', 'T', 'G', 'M', 'K'};
unsigned long d = 10 * ARRAY_SIZE(names); unsigned long d = 10 * ARRAY_SIZE(names);
char c = 0; char c = 0;
@@ -43,7 +39,7 @@ void print_size(unsigned long long size, const char *s)
} }
if (!c) { if (!c) {
printf("%llu Bytes%s", size, s); printf("%" PRIu64 " Bytes%s", size, s);
return; return;
} }
@@ -127,7 +123,7 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
else else
x = lb.uc[i] = *(volatile uint8_t *)data; x = lb.uc[i] = *(volatile uint8_t *)data;
#ifdef CONFIG_SYS_SUPPORT_64BIT_DATA #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA
printf(" %0*llx", width * 2, x); printf(" %0*" PRIx64, width * 2, x);
#else #else
printf(" %0*x", width * 2, x); printf(" %0*x", width * 2, x);
#endif #endif