From patchwork Fri Apr 5 23:11:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 234297 X-Patchwork-Delegate: wd@denx.de 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 D0A772C0128 for ; Sat, 6 Apr 2013 10:11:33 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0744D4A226; Sat, 6 Apr 2013 01:11:32 +0200 (CEST) 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 KvM8SjSCfycp; Sat, 6 Apr 2013 01:11:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7835A4A21E; Sat, 6 Apr 2013 01:11:30 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E5B124A21E for ; Sat, 6 Apr 2013 01:11:27 +0200 (CEST) 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 MddCAp0ANCPL for ; Sat, 6 Apr 2013 01:11:27 +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-oa0-f74.google.com (mail-oa0-f74.google.com [209.85.219.74]) by theia.denx.de (Postfix) with ESMTPS id 117184A21D for ; Sat, 6 Apr 2013 01:11:25 +0200 (CEST) Received: by mail-oa0-f74.google.com with SMTP id k14so1026208oag.1 for ; Fri, 05 Apr 2013 16:11:23 -0700 (PDT) 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 :x-gm-message-state; bh=QZ2REj5AyQTLhKgzvVywAIuyS/jDvG56+PzzG+GkUGc=; b=XKlTvOjRDsEOv3m60H3BOiN2QEAunIGjgZ3tZoNLUd8F7cu/FibVndhtq+NroS82bK LCpZolRzPpDVz+d7qyou2FSQtzo87QSjeh/v1vRmq15iQUSrCnM5OKUkdZyT/05T7bOI R4nGhZy2Xq4vLITRuhafYl/2YURIPKsX5WJIhLFfj7r2cY31kqJUL2B0+qYnxv6v+EVg /Oug85VybMIV2L1vwg4/Et4YXE5F+hf9wJJPxkmPPmMKm1lNopmXEzALZNoqByk27wEH R88s+Sg+R/tuTIijQvaDU43b+wFK4zinuiqjUZ7AFz06mL8W7unkr2M21QU8nygkp/hu yHMw== X-Received: by 10.50.76.164 with SMTP id l4mr851886igw.3.1365203482951; Fri, 05 Apr 2013 16:11:22 -0700 (PDT) Received: from corp2gmr1-1.hot.corp.google.com (corp2gmr1-1.hot.corp.google.com [172.24.189.92]) by gmr-mx.google.com with ESMTPS id l10si529125ige.0.2013.04.05.16.11.22 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Fri, 05 Apr 2013 16:11:22 -0700 (PDT) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.83.1]) by corp2gmr1-1.hot.corp.google.com (Postfix) with ESMTP id 5CF7631C158; Fri, 5 Apr 2013 16:11:22 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id CC75A1605B0; Fri, 5 Apr 2013 16:11:13 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Fri, 5 Apr 2013 16:11:10 -0700 Message-Id: <1365203470-9099-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.1.3 X-Gm-Message-State: ALoCoQmIjDcFJxAQeLp/+OJAAD1HQOd+sUpFhfkK0ZndECtRWE+v9uirolc8To+EayO1DYS/iF1SRL64JcMbVN2tOTFRyY+9o/5El/RHOMdvVKs1Gp8m+I1DiqfUSj4xU+bfTsNcNM0ChsCi4zopF6zfjPb+WRPc2mRPdJ6x23AeNU2pR5Dc3DPIGjoUK301Y0FhPLMZbepv Cc: Tom Rini , Allen Martin Subject: [U-Boot] [PATCH] crc32: Correct endianness of crc32 result 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 When crc32 is handled by the hash library, it requires the data to be in big-endian format, since it reads it byte-wise. Thus at present the 'crc32' command reports incorrect data. For example, previously we might see: Peach # crc32 40000000 100 CRC32 for 40000000 ... 400000ff ==> 0d968558 but instead with the hash library we see: Peach # crc32 40000000 100 CRC32 for 40000000 ... 400000ff ==> 5885960d Correct this. Signed-off-by: Simon Glass Reviewed-by: Vadim Bendebury Reviewed-by: Allen Martin Tested-by: Allen Martin --- lib/crc32.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/crc32.c b/lib/crc32.c index 76205da..94720bf 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -10,6 +10,7 @@ #ifndef USE_HOSTCC #include +#include #endif #include #include @@ -256,5 +257,10 @@ void crc32_wd_buf(const unsigned char *input, unsigned int ilen, uint32_t crc; crc = crc32_wd(0, input, ilen, chunk_sz); +#ifdef USE_HOSTCC + crc = htobe32(crc); memcpy(output, &crc, sizeof(crc)); +#else + put_unaligned_be32(crc, output); +#endif }