From patchwork Thu Aug 28 17:53:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 36252 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 25FE82054F for ; Thu, 28 Aug 2014 17:52:22 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf9466323iga.6 for ; Thu, 28 Aug 2014 10:52:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=fieYnfAviugqnvS1KxwoajDmfLhvT2GeDbrZELvHaNA=; b=Sxq8/eYz7AGRd+O6mYQnXmQZ3zZs+/Lk3AmN8g5C4+RPOs5rfrWCg/nm84BCVqjNjH CiRbSRZV2xbKouOg24/F4HMfVALSauY467Y6nqrXnMxmGznI5pOHkb+1hTPQI2VJe1rG +EBC7jInWE0/8VSPm2n7czHja5OPpPv5hVVHqo4rDCMIncklZC1uao+nqh9kmBruuuDJ 7uNHUwU3BvHA6B06fbH1qoi8FL0SyvfcC3M7OhHZECwVhIbDaa4028CybBP/ygTt3FtW nMyY5l/4Ft9NACXA706HTfSWzb2xOJtPNeX7AHXvlYeHPPKScgDQ1bSILGwo3KdnNzm2 I8pA== X-Gm-Message-State: ALoCoQnPC+jJVhP5xEQ+V10XFFxLBaMzDpO/ryaoj1uk3TDyWLvDaJmp11nwDhQsPqrcUhPpnR3X X-Received: by 10.182.110.130 with SMTP id ia2mr3005806obb.42.1409248341451; Thu, 28 Aug 2014 10:52:21 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.95.182 with SMTP id i51ls718009qge.20.gmail; Thu, 28 Aug 2014 10:52:21 -0700 (PDT) X-Received: by 10.52.17.161 with SMTP id p1mr2267214vdd.88.1409248341375; Thu, 28 Aug 2014 10:52:21 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id 14si4511133vcn.84.2014.08.28.10.52.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 28 Aug 2014 10:52:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id la4so1271419vcb.1 for ; Thu, 28 Aug 2014 10:52:21 -0700 (PDT) X-Received: by 10.52.119.229 with SMTP id kx5mr2387842vdb.40.1409248341129; Thu, 28 Aug 2014 10:52:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp274654vcb; Thu, 28 Aug 2014 10:52:20 -0700 (PDT) X-Received: by 10.180.80.225 with SMTP id u1mr7787776wix.69.1409248339606; Thu, 28 Aug 2014 10:52:19 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id dn8si9366531wib.18.2014.08.28.10.52.18 for ; Thu, 28 Aug 2014 10:52:19 -0700 (PDT) Received-SPF: none (google.com: u-boot-bounces@lists.denx.de does not designate permitted sender hosts) client-ip=85.214.87.163; Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9D0CFA7627; Thu, 28 Aug 2014 19:52:14 +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 I9LNE9uvamoQ; Thu, 28 Aug 2014 19:52:14 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ECFDEA75BF; Thu, 28 Aug 2014 19:52:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4D51CA75BF for ; Thu, 28 Aug 2014 19:52:11 +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 5Crrths6pD02 for ; Thu, 28 Aug 2014 19:52:09 +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-gw2-out.broadcom.com (mail-gw2-out.broadcom.com [216.31.210.63]) by theia.denx.de (Postfix) with ESMTP id 4BA9CA7515 for ; Thu, 28 Aug 2014 19:52:08 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,418,1406617200"; d="scan'208";a="43932167" Received: from irvexchcas06.broadcom.com (HELO IRVEXCHCAS06.corp.ad.broadcom.com) ([10.9.208.53]) by mail-gw2-out.broadcom.com with ESMTP; 28 Aug 2014 11:07:15 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.3.174.1; Thu, 28 Aug 2014 10:52:06 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) with Microsoft SMTP Server id 14.3.174.1; Thu, 28 Aug 2014 10:52:06 -0700 Received: from mail.broadcom.com (lbrmn-vmlnx03.ric.broadcom.com [10.136.4.105]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 3D2DA9F9F7; Thu, 28 Aug 2014 10:52:06 -0700 (PDT) From: Steve Rae To: , Tom Rini Date: Thu, 28 Aug 2014 10:53:53 -0700 Message-ID: <1409248434-25762-4-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1409248434-25762-1-git-send-email-srae@broadcom.com> References: <1409248434-25762-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Steve Rae , Marek Vasut Subject: [U-Boot] [PATCH v2 3/4] cleanup code which handles the Android sparse image format X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srae@broadcom.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 - update license format - port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Changes in v2: - use BSD-3-Clause common/aboot.c | 120 ++++++++++++++++++++++++++------------------------------- 1 file changed, 55 insertions(+), 65 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index a302c92..351199e 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -3,31 +3,9 @@ * All rights reserved. * * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved. + * Portions Copyright 2014 Broadcom Corporation. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of The Linux Foundation nor - * the names of its contributors may be used to endorse or promote - * products derived from this software without specific prior written - * permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * SPDX-License-Identifier: BSD-3-Clause */ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) @@ -70,23 +48,24 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) } data += sparse_header->file_hdr_sz; - if(sparse_header->file_hdr_sz > sizeof(sparse_header_t)) + if (sparse_header->file_hdr_sz > sizeof(sparse_header_t)) { - /* Skip the remaining bytes in a header that is longer than + /* + * Skip the remaining bytes in a header that is longer than * we expected. */ data += (sparse_header->file_hdr_sz - sizeof(sparse_header_t)); } - dprintf (SPEW, "=== Sparse Image Header ===\n"); - dprintf (SPEW, "magic: 0x%x\n", sparse_header->magic); - dprintf (SPEW, "major_version: 0x%x\n", sparse_header->major_version); - dprintf (SPEW, "minor_version: 0x%x\n", sparse_header->minor_version); - dprintf (SPEW, "file_hdr_sz: %d\n", sparse_header->file_hdr_sz); - dprintf (SPEW, "chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz); - dprintf (SPEW, "blk_sz: %d\n", sparse_header->blk_sz); - dprintf (SPEW, "total_blks: %d\n", sparse_header->total_blks); - dprintf (SPEW, "total_chunks: %d\n", sparse_header->total_chunks); + debug("=== Sparse Image Header ===\n"); + debug("magic: 0x%x\n", sparse_header->magic); + debug("major_version: 0x%x\n", sparse_header->major_version); + debug("minor_version: 0x%x\n", sparse_header->minor_version); + debug("file_hdr_sz: %d\n", sparse_header->file_hdr_sz); + debug("chunk_hdr_sz: %d\n", sparse_header->chunk_hdr_sz); + debug("blk_sz: %d\n", sparse_header->blk_sz); + debug("total_blks: %d\n", sparse_header->total_blks); + debug("total_chunks: %d\n", sparse_header->total_chunks); /* Start processing chunks */ for (chunk=0; chunktotal_chunks; chunk++) @@ -95,33 +74,37 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) chunk_header = (chunk_header_t *) data; data += sizeof(chunk_header_t); - dprintf (SPEW, "=== Chunk Header ===\n"); - dprintf (SPEW, "chunk_type: 0x%x\n", chunk_header->chunk_type); - dprintf (SPEW, "chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); - dprintf (SPEW, "total_size: 0x%x\n", chunk_header->total_sz); + debug("=== Chunk Header ===\n"); + debug("chunk_type: 0x%x\n", chunk_header->chunk_type); + debug("chunk_data_sz: 0x%x\n", chunk_header->chunk_sz); + debug("total_size: 0x%x\n", chunk_header->total_sz); - if(sparse_header->chunk_hdr_sz > sizeof(chunk_header_t)) + if (sparse_header->chunk_hdr_sz > sizeof(chunk_header_t)) { - /* Skip the remaining bytes in a header that is longer than - * we expected. + /* + * Skip the remaining bytes in a header that is longer + * than we expected. */ - data += (sparse_header->chunk_hdr_sz - sizeof(chunk_header_t)); + data += (sparse_header->chunk_hdr_sz - + sizeof(chunk_header_t)); } chunk_data_sz = sparse_header->blk_sz * chunk_header->chunk_sz; switch (chunk_header->chunk_type) { case CHUNK_TYPE_RAW: - if(chunk_header->total_sz != (sparse_header->chunk_hdr_sz + - chunk_data_sz)) + if (chunk_header->total_sz != + (sparse_header->chunk_hdr_sz + chunk_data_sz)) { - fastboot_fail("Bogus chunk size for chunk type Raw"); + fastboot_fail( + "Bogus chunk size for chunk type Raw"); return; } - if(mmc_write(ptn + ((uint64_t)total_blocks*sparse_header->blk_sz), - chunk_data_sz, - (unsigned int*)data)) + if (mmc_write(ptn + + ((uint64_t)total_blocks * + sparse_header->blk_sz), + chunk_data_sz, (unsigned int *)data)) { fastboot_fail("flash write failure"); return; @@ -131,17 +114,22 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) break; case CHUNK_TYPE_FILL: - if(chunk_header->total_sz != (sparse_header->chunk_hdr_sz + - sizeof(uint32_t))) + if (chunk_header->total_sz != + (sparse_header->chunk_hdr_sz + sizeof(uint32_t))) { - fastboot_fail("Bogus chunk size for chunk type FILL"); + fastboot_fail( + "Bogus chunk size for chunk type FILL"); return; } - fill_buf = (uint32_t *)memalign(CACHE_LINE, ROUNDUP(sparse_header->blk_sz, CACHE_LINE)); + fill_buf = (uint32_t *) + memalign(CACHE_LINE, + ROUNDUP(sparse_header->blk_sz, + CACHE_LINE)); if (!fill_buf) { - fastboot_fail("Malloc failed for: CHUNK_TYPE_FILL"); + fastboot_fail( + "Malloc failed for: CHUNK_TYPE_FILL"); return; } @@ -156,9 +144,10 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) for (i = 0; i < chunk_blk_cnt; i++) { - if(mmc_write(ptn + ((uint64_t)total_blocks*sparse_header->blk_sz), - sparse_header->blk_sz, - fill_buf)) + if (mmc_write(ptn + + ((uint64_t)total_blocks * + sparse_header->blk_sz), + sparse_header->blk_sz, fill_buf)) { fastboot_fail("flash write failure"); free(fill_buf); @@ -176,9 +165,11 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) break; case CHUNK_TYPE_CRC: - if(chunk_header->total_sz != sparse_header->chunk_hdr_sz) + if (chunk_header->total_sz != + sparse_header->chunk_hdr_sz) { - fastboot_fail("Bogus chunk size for chunk type Dont Care"); + fastboot_fail( + "Bogus chunk size for chunk type Dont Care"); return; } total_blocks += chunk_header->chunk_sz; @@ -186,19 +177,18 @@ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) break; default: - dprintf(CRITICAL, "Unkown chunk type: %x\n",chunk_header->chunk_type); + debug("Unkown chunk type: %x\n", + chunk_header->chunk_type); fastboot_fail("Unknown chunk type"); return; } } - dprintf(INFO, "Wrote %d blocks, expected to write %d blocks\n", - total_blocks, sparse_header->total_blks); + debug("Wrote %d blocks, expected to write %d blocks\n", + total_blocks, sparse_header->total_blks); - if(total_blocks != sparse_header->total_blks) - { + if (total_blocks != sparse_header->total_blks) fastboot_fail("sparse image write failure"); - } fastboot_okay(""); return;