From patchwork Wed Sep 3 17:05: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: 36625 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f200.google.com (mail-qc0-f200.google.com [209.85.216.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8BCB1202E4 for ; Wed, 3 Sep 2014 17:03:56 +0000 (UTC) Received: by mail-qc0-f200.google.com with SMTP id w7sf27233224qcr.3 for ; Wed, 03 Sep 2014 10:03:53 -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=b01uATTiYd1q6zEG8YsZJX78oE5bcbXe2sjnhjAC/18=; b=kTxvGIaHoRex+UOMRjpWTLr3KTnIBl6W9Bl0UA4wd95osyp9/bchkUsvNOiOyJzaKW IO2Fzn4eSUCucvArZfNslCHOT840pwOBG7dYQr6HmoVF0bYvisd2ufv/hz4hewPQ/dRD cbL3j3P6R3oloV8kx18hxh8E/w0geB0wqorNDzECSfe5CoFEMq9+2LxXCJFDgYBx/+RY W55bYMPlDJPFFi53pkcYq4DyeaQHzPPxBdqhpkV6sM4odLXX6xh9z4X8kWxtrgj8/Wuh V3wGxIgY0HAHK0i6uWCU1+9znANlaXGGcJtDHX4bW07YGl/KPZBq+TfS2KbyUPul+m0g n7Ig== X-Gm-Message-State: ALoCoQljFZaH2VtuTx2Ta4xVKx52Ghtq1Mv4TTFlRR1hwN8wNU3pOJ0sZW63RTkcSWjVS0dBWMhI X-Received: by 10.236.207.101 with SMTP id m65mr21651446yho.41.1409763833902; Wed, 03 Sep 2014 10:03:53 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.193 with SMTP id 59ls3013412qgf.7.gmail; Wed, 03 Sep 2014 10:03:53 -0700 (PDT) X-Received: by 10.52.227.72 with SMTP id ry8mr1305678vdc.64.1409763833799; Wed, 03 Sep 2014 10:03:53 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id cc10si3994507vcb.48.2014.09.03.10.03.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 03 Sep 2014 10:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id ij19so9233968vcb.12 for ; Wed, 03 Sep 2014 10:03:53 -0700 (PDT) X-Received: by 10.220.175.17 with SMTP id v17mr6629691vcz.0.1409763833711; Wed, 03 Sep 2014 10:03:53 -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 uj3csp711038vcb; Wed, 3 Sep 2014 10:03:53 -0700 (PDT) X-Received: by 10.180.91.40 with SMTP id cb8mr5529296wib.45.1409763832401; Wed, 03 Sep 2014 10:03:52 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id j10si4268575wiz.0.2014.09.03.10.03.51 for ; Wed, 03 Sep 2014 10:03:52 -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 65E5FA7680; Wed, 3 Sep 2014 19:03:51 +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 QYqTp5w3KEwq; Wed, 3 Sep 2014 19:03:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 85D1DA7489; Wed, 3 Sep 2014 19:03:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 738F0A767F for ; Wed, 3 Sep 2014 19:03:37 +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 WdOaJvX0fLrs for ; Wed, 3 Sep 2014 19:03:34 +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-gw1-out.broadcom.com (mail-gw1-out.broadcom.com [216.31.210.62]) by theia.denx.de (Postfix) with ESMTP id 0322EA75C1 for ; Wed, 3 Sep 2014 19:03:33 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,458,1406617200"; d="scan'208";a="44758596" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 03 Sep 2014 11:01:43 -0700 Received: from IRVEXCHSMTP1.corp.ad.broadcom.com (10.9.207.51) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Wed, 3 Sep 2014 10:03:32 -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; Wed, 3 Sep 2014 10:03:32 -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 239F19F9FD; Wed, 3 Sep 2014 10:03:32 -0700 (PDT) From: Steve Rae To: , Tom Rini Date: Wed, 3 Sep 2014 10:05:53 -0700 Message-ID: <1409763954-5494-4-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1409763954-5494-1-git-send-email-srae@broadcom.com> References: <1409763954-5494-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Steve Rae Subject: [U-Boot] [PATCH v3 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.181 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 - port dprintf() to debug() - update formatting Signed-off-by: Steve Rae --- Changes in v3: - use original license text Changes in v2: - use BSD-3-Clause common/aboot.c | 97 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/common/aboot.c b/common/aboot.c index a302c92..3611feb 100644 --- a/common/aboot.c +++ b/common/aboot.c @@ -28,6 +28,9 @@ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + * NOTE: + * Although it is very similar, this license text is not identical + * to the "BSD-3-Clause", therefore, DO NOT MODIFY THIS LICENSE TEXT! */ void cmd_flash_mmc_sparse_img(const char *arg, void *data, unsigned sz) @@ -70,23 +73,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 +99,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 +139,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 +169,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 +190,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 +202,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;