From patchwork Fri Nov 2 02:21:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Hershberger X-Patchwork-Id: 196459 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 CB4F92C0351 for ; Fri, 2 Nov 2012 13:22:00 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 586774A66E; Fri, 2 Nov 2012 03:21:59 +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 Z0fDgkbu36ic; Fri, 2 Nov 2012 03:21:59 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BC2434A679; Fri, 2 Nov 2012 03:21:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EC7F44A679 for ; Fri, 2 Nov 2012 03:21:54 +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 JeHmiFHarY33 for ; Fri, 2 Nov 2012 03:21:53 +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 spamkiller06.natinst.com (mailserver6.natinst.com [130.164.80.6]) by theia.denx.de (Postfix) with ESMTP id 72AC74A66E for ; Fri, 2 Nov 2012 03:21:52 +0100 (CET) Received: from mailserv59-us.natinst.com (nb-hsrp-1338.natinst.com [130.164.19.133]) by spamkiller06.natinst.com (8.14.5/8.14.5) with ESMTP id qA22LcF8023284; Thu, 1 Nov 2012 21:21:38 -0500 Received: from linux-xvxi.natinst.com ([130.164.14.197]) by mailserv59-us.natinst.com (Lotus Domino Release 8.5.3FP2 HF169) with ESMTP id 2012110121213908-883618 ; Thu, 1 Nov 2012 21:21:39 -0500 From: Joe Hershberger To: u-boot@lists.denx.de Date: Thu, 1 Nov 2012 21:21:14 -0500 Message-Id: <1351822874-9370-1-git-send-email-joe.hershberger@ni.com> X-Mailer: git-send-email 1.7.11.5 In-Reply-To: <20120902191042.920F7203B2F@gemini.denx.de> References: <20120902191042.920F7203B2F@gemini.denx.de> X-MIMETrack: Itemize by SMTP Server on MailServ59-US/AUS/H/NIC(Release 8.5.3FP2 HF169|September 14, 2012) at 11/01/2012 09:21:39 PM, Serialize by Router on MailServ59-US/AUS/H/NIC(Release 8.5.3FP2 HF169|September 14, 2012) at 11/01/2012 09:21:39 PM, Serialize complete at 11/01/2012 09:21:39 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.7.7855, 1.0.431, 0.0.0000 definitions=2012-11-01_07:2012-11-01, 2012-11-01, 1970-01-01 signatures=0 Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v2] Add a simple load option to setexpr 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 Make setexpr accept a 2 parameter variant that will simply load a value into a variable. This is useful for loading a value from memory. Signed-off-by: Joe Hershberger --- Changes in v2: - Replaced memory get command with option to setexpr common/cmd_setexpr.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/common/cmd_setexpr.c b/common/cmd_setexpr.c index 1b3edb7..70133b0 100644 --- a/common/cmd_setexpr.c +++ b/common/cmd_setexpr.c @@ -57,12 +57,22 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int w; /* Validate arguments */ - if ((argc != 5) || (strlen(argv[3]) != 1)) + if (argc != 5 && argc != 3) + return CMD_RET_USAGE; + if (argc == 5 && strlen(argv[3]) != 1) return CMD_RET_USAGE; w = cmd_get_data_size(argv[0], 4); a = get_arg(argv[2], w); + + if (argc == 3) { + sprintf(buf, "%lx", a); + setenv(argv[1], buf); + + return 0; + } + b = get_arg(argv[4], w); switch (argv[3][0]) { @@ -87,8 +97,11 @@ int do_setexpr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( setexpr, 5, 0, do_setexpr, "set environment variable as the result of eval expression", - "[.b, .w, .l] name value1 value2\n" + "[.b, .w, .l] name [*]value1 [*]value2\n" " - set environment variable 'name' to the result of the evaluated\n" " express specified by . can be &, |, ^, +, -, *, /, %\n" - " size argument is only meaningful if value1 and/or value2 are memory addresses" + " size argument is only meaningful if value1 and/or value2 are\n" + " memory addresses (*)\n" + "setexpr[.b, .w, .l] name *value\n" + " - load a memory address into a variable" );