From patchwork Thu Apr 18 20:25:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 237733 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 350502C0201 for ; Fri, 19 Apr 2013 06:26:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4110E4A384; Thu, 18 Apr 2013 22:26:02 +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 ZQGg5bAAQwUp; Thu, 18 Apr 2013 22:26:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C896B4A386; Thu, 18 Apr 2013 22:26:00 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 483E54A386 for ; Thu, 18 Apr 2013 22:25:59 +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 l6aGQDvyWZDv for ; Thu, 18 Apr 2013 22:25:58 +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-yh0-f74.google.com (mail-yh0-f74.google.com [209.85.213.74]) by theia.denx.de (Postfix) with ESMTPS id 3745C4A384 for ; Thu, 18 Apr 2013 22:25:56 +0200 (CEST) Received: by mail-yh0-f74.google.com with SMTP id q10so345583yhf.1 for ; Thu, 18 Apr 2013 13:25:55 -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=+eKcWXsOvdo/CQ0mQNJ4ibhz05HxwOcjKEyMzw62myE=; b=H11DIWPdYjm9TMVjNBxC79Z8mCUK0hSLDmsc1Tw3ZvLky7FgvL0SVjBQilav7kCjq9 75eE/78ydxcRpaW0MZdKqeDpXTpmqgkkE6qxP9GoQgnX+7ikrM/emGDfgnTf9HxOkEEC VifnH2u3RuskhKxi7olFP+jRT19l80UI/IvssgznFqVSjMfmnuHAjF5J8TV8UYsF5YrP VnZj5XBBgMl/ZKKZp4Z3USrz88rCLN6rLebCJ8Z/4ZuUXokRLClzWYQsBkKxC91PORbn ChBsYWR65iDTsCEpB3nhDGgrnS6iFnTSlSs5F8pwfs9XCV/c3KsfypUDpPprAyTYQ/Vn OGVQ== X-Received: by 10.236.78.103 with SMTP id f67mr6121479yhe.52.1366316755344; Thu, 18 Apr 2013 13:25:55 -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 q58si3408978yhe.4.2013.04.18.13.25.55 (version=TLSv1.1 cipher=AES128-SHA bits=128/128); Thu, 18 Apr 2013 13:25:55 -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 1835D31C1FB; Thu, 18 Apr 2013 13:25:55 -0700 (PDT) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id A149716068E; Thu, 18 Apr 2013 13:25:54 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Thu, 18 Apr 2013 13:25:51 -0700 Message-Id: <1366316751-22465-1-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.8.2.1 X-Gm-Message-State: ALoCoQm1JwM7sDCnINgmjEIuFNMPFno/0vbKKVILiOnWVPPnhns2AzhAqywR7iPfNi1biPnvmcF1QkRpCol6siYQ7weerb18QN8k66nnDu84NXrWWJNCAvcZboC1bH37TIvh2ns1eltF/6OWi8fy3H60vea/5H8bJrXUmKJbnwl5deCwSd9vy0dKa/z4JMZriWq5faoz9s4P Cc: Tom Rini , Allen Martin Subject: [U-Boot] [PATCH v2] 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 --- Changes in v2: - Remove use of put_unaligned_be32() - Use htonl() instead of htobe32() lib/crc32.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/crc32.c b/lib/crc32.c index 76205da..9759212 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -8,7 +8,9 @@ * For conditions of distribution and use, see copyright notice in zlib.h */ -#ifndef USE_HOSTCC +#ifdef USE_HOSTCC +#include +#else #include #endif #include @@ -256,5 +258,6 @@ void crc32_wd_buf(const unsigned char *input, unsigned int ilen, uint32_t crc; crc = crc32_wd(0, input, ilen, chunk_sz); + crc = htonl(crc); memcpy(output, &crc, sizeof(crc)); }