From patchwork Wed Oct 15 10:38:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 399923 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 838881400B5 for ; Wed, 15 Oct 2014 21:39:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B4F07AB583; Wed, 15 Oct 2014 12:39:15 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nqG27U01t4yg; Wed, 15 Oct 2014 12:39:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7DBCBA7821; Wed, 15 Oct 2014 12:39:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EA070A780B for ; Wed, 15 Oct 2014 12:39:04 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 717bnRQL2U0y for ; Wed, 15 Oct 2014 12:39:04 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-qg0-f73.google.com (mail-qg0-f73.google.com [209.85.192.73]) by theia.denx.de (Postfix) with ESMTPS id 2575AA77F7 for ; Wed, 15 Oct 2014 12:39:00 +0200 (CEST) Received: by mail-qg0-f73.google.com with SMTP id i50so69422qgf.0 for ; Wed, 15 Oct 2014 03:38:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V8825Ym+hslnAuQhxSZjtFfwq/UkCsuZ3D+PJyixkvc=; b=kabh81w6nxwrZIty32XriMcxW9duRqliFHI5paDVR6aDPKyNqHlPuyvrLfkZuvPezT oYH2d/wy2zfnvykVJrsa2+N+eDCAkhjUS5bOeXOcuferutXobxljmcLACQ/B9YVb7a2p QGUsd+DkWul7+o69O7CaaoYebDS+0cuC4Sls07RMr9LvRv6C7emh4U3gtebbzpep1b9w odOGRwfJ3q8jiKImwhOHJFgWvxST+BqamFrYl7MYQlwdVt2KBw3CSSvUpfwOvONfcudb FZEDC4WBg91+XFNL/UPjYpagW/k+HBCWwAA7g7pPJvVzx1Tn2u020AmYSUPREqNwh+wA x5Sw== X-Gm-Message-State: ALoCoQnwkfyl+iSUK0UtudF+BvyVZFaQ7xZjdrj2ZAFvWhNVZXpKRUEap/A8GbTClU6KkxynQaQw X-Received: by 10.236.17.233 with SMTP id j69mr7239202yhj.47.1413369539422; Wed, 15 Oct 2014 03:38:59 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id k66si947339yho.7.2014.10.15.03.38.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Oct 2014 03:38:59 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id m5uKFk78.1; Wed, 15 Oct 2014 03:38:59 -0700 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 8BE63221091; Wed, 15 Oct 2014 04:38:58 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Wed, 15 Oct 2014 04:38:35 -0600 Message-Id: <1413369519-11677-7-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1413369519-11677-1-git-send-email-sjg@chromium.org> References: <1413369519-11677-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH 06/10] Tidy up data sizes and function comment in display_options X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 --- include/common.h | 14 +++++++++++++- lib/display_options.c | 14 +++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/common.h b/include/common.h index 02befa6..3ccde60 100644 --- a/include/common.h +++ b/include/common.h @@ -256,7 +256,19 @@ int cpu_init(void); /* */ phys_size_t initdram (int); 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, uint linelen); diff --git a/lib/display_options.c b/lib/display_options.c index 4c0c886..d5d17b2 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -21,15 +22,10 @@ int display_options (void) return 0; } -/* - * 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) +void print_size(uint64_t size, const char *s) { unsigned long m = 0, n; - unsigned long long f; + uint64_t f; static const char names[] = {'E', 'P', 'T', 'G', 'M', 'K'}; unsigned long d = 10 * ARRAY_SIZE(names); char c = 0; @@ -43,7 +39,7 @@ void print_size(unsigned long long size, const char *s) } if (!c) { - printf("%llu Bytes%s", size, s); + printf("%" PRIu64 " Bytes%s", size, s); return; } @@ -127,7 +123,7 @@ int print_buffer(ulong addr, const void *data, uint width, uint count, else x = lb.uc[i] = *(volatile uint8_t *)data; #ifdef CONFIG_SYS_SUPPORT_64BIT_DATA - printf(" %0*llx", width * 2, x); + printf(" %0*" PRIx64, width * 2, x); #else printf(" %0*x", width * 2, x); #endif