From patchwork Wed Dec 26 18:57:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 208190 X-Patchwork-Delegate: sjg@chromium.org 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 5D7E52C00C1 for ; Thu, 27 Dec 2012 05:59:22 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DBA2E4A09C; Wed, 26 Dec 2012 19:59:17 +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 YDOk9tsElCUc; Wed, 26 Dec 2012 19:59:17 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AFF0A4A0BA; Wed, 26 Dec 2012 19:58:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 53C624A090 for ; Wed, 26 Dec 2012 19:57:44 +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 eI5RdEE60xWd for ; Wed, 26 Dec 2012 19:57:43 +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-bk0-f74.google.com (mail-bk0-f74.google.com [209.85.214.74]) by theia.denx.de (Postfix) with ESMTPS id 03E094A098 for ; Wed, 26 Dec 2012 19:57:32 +0100 (CET) Received: by mail-bk0-f74.google.com with SMTP id je9so517304bkc.3 for ; Wed, 26 Dec 2012 10:57:32 -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=Dojt2khU4rzjV1i8cBmzw457wq1P0tBigZVXCz3tT/A=; b=ddqtQ6nrTfPbqhd5DXUCPMbMeAxlx+elomYMu8/QOgj+JwS6m8nW+00c2lumc0qDSl w0ntTImAC+tHltKPq81AUIH6tsLn4EOYOy3Tyyl+3FoI9gD09oXhaftjbGWT3r3F7rcz tsZnrlfFTHtCSIt9uBV4qJGkdBqX1a8EPeXhHBgxfp1BmNLDwFrU/XaMGpQGPbD05pGS awCHQOZ4D0FdJy/gfHHPIek13QfJSm3trXU1cKYctv2VnIqWaTnihWWNxO9Fufae7HrT vR3OvRq6JvfMCVOZvmCVHnb2fpaLnPmxUURLTQdE6DsJNeDP5os9uKduQxf1Kg84b5Y0 /ypA== X-Received: by 10.14.179.198 with SMTP id h46mr35856892eem.4.1356548252145; Wed, 26 Dec 2012 10:57:32 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id g9si10338404eeo.1.2012.12.26.10.57.32 (version=TLSv1/SSLv3 cipher=AES128-SHA); Wed, 26 Dec 2012 10:57:32 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id C26B820005C; Wed, 26 Dec 2012 10:57:31 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 26751160CAE; Wed, 26 Dec 2012 10:57:31 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Wed, 26 Dec 2012 10:57:04 -0800 Message-Id: <1356548233-5570-12-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1356548233-5570-1-git-send-email-sjg@chromium.org> References: <1356548233-5570-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQkeWcgZGTITrPOE+FRoegb1PKJMOSHpubTZ4OOKV6jcqhSrib7ZPi7yAG4rzVA/Y2mvj8wk9k2o69wPXPxowNuVepzja6b/0gdpzE/7FsLh+ZvFkhGbHRRha5xACTiku41/HJ9U9LlkkGwGPFgfDCfcpttIdE75kpZvx0T7prSx/yYGjeVNLs0n+62qupgW/YQF+6Zu Cc: Tom Rini , Joe Hershberger , Kumar Gala Subject: [U-Boot] [PATCH 11/20] 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 --- 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 9e2de34..0bdf7b6 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -56,12 +56,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); } /* @@ -348,10 +344,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 08d01db..8ecaf56 100644 --- a/include/common.h +++ b/include/common.h @@ -349,7 +349,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