From patchwork Mon Feb 25 03:33:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 222840 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 037D52C02AC for ; Mon, 25 Feb 2013 14:38:00 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 992AD4A481; Mon, 25 Feb 2013 04:36: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 a0zzKBtkMJVL; Mon, 25 Feb 2013 04:36:54 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 582124A1B5; Mon, 25 Feb 2013 04:34:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D19F94A117 for ; Mon, 25 Feb 2013 04:34:15 +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 maB4M7e-IYO7 for ; Mon, 25 Feb 2013 04:34:12 +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-vc0-f202.google.com (mail-vc0-f202.google.com [209.85.220.202]) by theia.denx.de (Postfix) with ESMTPS id 59B6A4A129 for ; Mon, 25 Feb 2013 04:33:57 +0100 (CET) Received: by mail-vc0-f202.google.com with SMTP id m8so254430vcd.3 for ; Sun, 24 Feb 2013 19:33:56 -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=RkBq3oqDPnGYwMFNKse8Ao3zIgyBrxN/80V5Wa3rLDc=; b=RRij2BswId0AtP+5OPxdHjL+xdGNKtmhG5tOC3yQxxeLHrfT+91jJU4syBAFHwk3DB v4FtiPgffnryXG6bmoJ/kfxCHCjAMXmoSAD/w0nSfjzLgM2MKoxO/hX8cTbd+ob5girm ODz990Dpr+AiNvqmzVNLAlf+NeFFc00VSP3T4YfV7d006Qhx7I3+xKShltS9aGyOVTul /i6HRjWWwtQJymo5EpAW5SfZDk1F9uaKqFS7SkK6nE6vQcUvK6D83pJ55O5b8FWQ0fsJ o6oBctbGFfrjVxWspORKUXhVkrEfQcz3QHKafwEAtSGV1An4BbT3wTamguuyRhxJMmZH C6lw== X-Received: by 10.101.44.11 with SMTP id w11mr1476343anj.16.1361763235936; Sun, 24 Feb 2013 19:33:55 -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 f47si808709yhg.4.2013.02.24.19.33.55 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Sun, 24 Feb 2013 19:33:55 -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 C3C655A41B5; Sun, 24 Feb 2013 19:33:55 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id A37561609DF; Sun, 24 Feb 2013 19:33:55 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Sun, 24 Feb 2013 19:33:32 -0800 Message-Id: <1361763213-31183-23-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: ALoCoQm5GtVpeN/UxhkEQAbwYHkbtniRQcLrOJCcYzbqN0e6AcgUkvTLrAKy8COUXv+D0G4EN8cYGj6x3BNKACD2FTg3a1IAB2iVPEOBtb9FpPeWBaSVlzlrHzTK0xSJpkpb0FnO+8yk51G8J2vAzkph4ABrurkmgmxpFMSUqw3ym6h6kq8jE4MJl/fpiFMcMIeK2I08vYzy Cc: Tom Rini , Joe Hershberger Subject: [U-Boot] [PATCH v3 22/22] hash: Use lower case for hash algorithm names 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 Rather than use strcasecmp() in the hash algorithm search, require the caller to do this first. Most of U-Boot can use lower case anyway, and the hash command can convert to lower case before calling hash_command(). This saves needing strcasecmp() for boards that use hashing but not the hash command. Signed-off-by: Simon Glass --- Changes in v3: None Changes in v2: None common/cmd_hash.c | 4 ++++ common/hash.c | 11 ++++++----- include/hash.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/common/cmd_hash.c b/common/cmd_hash.c index 8c03b5c..4fe0e78 100644 --- a/common/cmd_hash.c +++ b/common/cmd_hash.c @@ -26,9 +26,11 @@ #include #include #include +#include static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { + char *s; #ifdef CONFIG_HASH_VERIFY int flags = HASH_FLAG_ENV; @@ -45,6 +47,8 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* Move forward to 'algorithm' parameter */ argc--; argv++; + for (s = *argv; *s; s++) + *s = tolower(*s); return hash_command(*argv, flags, cmdtp, flag, argc - 1, argv + 1); } diff --git a/common/hash.c b/common/hash.c index d6f4aa1..dc15596 100644 --- a/common/hash.c +++ b/common/hash.c @@ -32,7 +32,8 @@ /* * These are the hash algorithms we support. Chips which support accelerated - * crypto could perhaps add named version of these algorithms here. + * crypto could perhaps add named version of these algorithms here. Note that + * algorithm names must be in lower case. */ static struct hash_algo hash_algo[] = { /* @@ -42,7 +43,7 @@ static struct hash_algo hash_algo[] = { */ #ifdef CONFIG_CMD_SHA1 { - "SHA1", + "sha1", SHA1_SUM_LEN, sha1_csum_wd, CHUNKSZ_SHA1, @@ -51,7 +52,7 @@ static struct hash_algo hash_algo[] = { #endif #ifdef CONFIG_SHA256 { - "SHA256", + "sha256", SHA256_SUM_LEN, sha256_csum_wd, CHUNKSZ_SHA256, @@ -59,7 +60,7 @@ static struct hash_algo hash_algo[] = { #define MULTI_HASH #endif { - "CRC32", + "crc32", 4, crc32_wd_buf, CHUNKSZ_CRC32, @@ -202,7 +203,7 @@ static struct hash_algo *find_hash_algo(const char *name) int i; for (i = 0; i < ARRAY_SIZE(hash_algo); i++) { - if (!strcasecmp(name, hash_algo[i].name)) + if (!strcmp(name, hash_algo[i].name)) return &hash_algo[i]; } diff --git a/include/hash.h b/include/hash.h index f2b2c45..2dbbd9b 100644 --- a/include/hash.h +++ b/include/hash.h @@ -61,7 +61,7 @@ enum { * * This common function is used to implement specific hash commands. * - * @algo_name: Hash algorithm being used + * @algo_name: Hash algorithm being used (lower case!) * @flags: Flags value (HASH_FLAG_...) * @cmdtp: Pointer to command table entry * @flag: Some flags normally 0 (see CMD_FLAG_.. above)