From patchwork Mon Feb 25 03:33:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222836 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 715282C029E for ; Mon, 25 Feb 2013 14:37:13 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 308FB4A3B9; Mon, 25 Feb 2013 04:36:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 AQHg7yzsi-xz; Mon, 25 Feb 2013 04:36:22 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 90E554A160; Mon, 25 Feb 2013 04:34:46 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D61664A117 for ; Mon, 25 Feb 2013 04:34:11 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 cto7dSLbHsl9 for ; Mon, 25 Feb 2013 04:34:10 +0100 (CET) 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-yh0-f73.google.com (mail-yh0-f73.google.com [209.85.213.73]) by theia.denx.de (Postfix) with ESMTPS id 3CEE14A121 for ; Mon, 25 Feb 2013 04:33:56 +0100 (CET) Received: by mail-yh0-f73.google.com with SMTP id 28so254864yhr.4 for ; Sun, 24 Feb 2013 19:33:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=gFMVM9QfyHAPN3tgK7TZOjgxEZoLoeB8Eql2HOoLlx8=; b=A6J0Q1302+7zHflcnKWrSccylD4GzstB1ZrcpZHkjI0sxAOcqfZvmlDRcAMcPIqdzR cUBKEkcwScR0Qv7XJVGu0SdmSC+Iu8i8xmuEtw4hUx/nVh7hibwOGVkO+1MvkkorEw+e hUGBdMB7f/mJINvxsr1cF0s/C71VpnbsSisFj7BeBqjGqNQT2VBfRNuANkPnJ4OWycBz xwgERaQfegsROHMmaNgkfsSGSnPZgqOYZB1uwoc7HweAWvqDNA4Ke1rM5Xp3yUetC2eR 6kU0/OpSaxbXTUwz3mkTiFl0aWJMxzvH789it685Wpbv4lzcV8+c+zMRY2Cu4dTtM9Z7 O2ig== X-Received: by 10.101.10.39 with SMTP id n39mr1485215ani.13.1361763234667; Sun, 24 Feb 2013 19:33:54 -0800 (PST) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id t30si808392yhi.6.2013.02.24.19.33.54 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sun, 24 Feb 2013 19:33:54 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id 8460C5A4102; Sun, 24 Feb 2013 19:33:54 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 66274160537; Sun, 24 Feb 2013 19:33:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 24 Feb 2013 19:33:21 -0800 Message-Id: <1361763213-31183-12-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361763213-31183-1-git-send-email-sjg@chromium.org> References: <1361763213-31183-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQlGlo8+x4oRg0lWKe271Xb3rRwEbLDpvDaWgiyrjSmtr7ikFAST8kQSgQwjwjgYWyAZaX/0A1jFbYF3Rg2xg7+Pg1m7r6RONhj+eFgcZ1x4N3JKHF5I89k64RpRGpxJXzvxhdDEnVNsWd44/0Trnk4kkdvhMqkRAsBgjicAJCJ5EY6sR/rHd12NtcFgNyF3swvghpPU Cc: Tom Rini Subject: [U-Boot] [PATCH v3 11/22] Update set_working_fdt_addr() to use setenv_addr() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 We might as well use this common function instead of repeating the same code. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/cmd_fdt.c | 11 ++--------- common/cmd_nvedit.c | 8 ++++---- include/common.h | 14 +++++++++++++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 6eec947..ac77a08 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -55,12 +55,8 @@ struct fdt_header *working_fdt; void set_working_fdt_addr(void *addr) { - char buf[17]; - working_fdt = addr; - - sprintf(buf, "%lx", (unsigned long)addr); - setenv("fdtaddr", buf); + setenv_addr("fdtaddr", addr); } /* @@ -347,10 +343,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } if (subcmd[0] == 's') { /* get the num nodes at this level */ - char buf[11]; - - sprintf(buf, "%d", curIndex + 1); - setenv(var, buf); + setenv_ulong(var, curIndex + 1); } else { /* node index not found */ printf("libfdt node not found\n"); diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 7633f0c..44e88aa 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -295,17 +295,17 @@ int setenv_ulong(const char *varname, ulong value) } /** - * Set an environment variable to an address in hex + * Set an environment variable to an value in hex * * @param varname Environmet variable to set - * @param addr Value to set it to + * @param value Value to set it to * @return 0 if ok, 1 on error */ -int setenv_addr(const char *varname, const void *addr) +int setenv_hex(const char *varname, ulong value) { char str[17]; - sprintf(str, "%lx", (uintptr_t)addr); + sprintf(str, "%lx", value); return setenv(varname, str); } diff --git a/include/common.h b/include/common.h index 1d0728f..6d52924 100644 --- a/include/common.h +++ b/include/common.h @@ -358,7 +358,19 @@ int getenv_yesno(const char *var); int saveenv (void); int setenv (const char *, const char *); int setenv_ulong(const char *varname, ulong value); -int setenv_addr(const char *varname, const void *addr); +int setenv_hex(const char *varname, ulong value); +/** + * setenv_addr - Set an environment variable to an address in hex + * + * @varname: Environmet variable to set + * @addr: Value to set it to + * @return 0 if ok, 1 on error + */ +static inline int setenv_addr(const char *varname, const void *addr) +{ + return setenv_hex(varname, (ulong)addr); +} + #ifdef CONFIG_ARM # include # include