From patchwork Sat Aug 23 17:39:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Rae X-Patchwork-Id: 35872 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D5BEC20293 for ; Sat, 23 Aug 2014 17:39:45 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id rp18sf31440563iec.4 for ; Sat, 23 Aug 2014 10:39:45 -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=ye1Jv63qHIiEzrf1didigS7YG6uT+zvONuasAOz2sEo=; b=SS+6oAMCRlYDuXIRcxjAHhH0pEMKBP0v+qoqFakk2wcES2hh+3XJUBrx3GPfzFYW7e 7Ox2+r1KkAGAXzGhSluBGxGcRVmbX1lshgVwVEtVMTmCgz1Z2aN3UhJN87UbpPHIBGyY vwaAPpzJwJSGizLvsW/sjqXXgG/WtIE+Q2/36hRLrh/3fMq0+Kapg2CfJ7JMqLmg49GV l34LOFIAcsb23RshzGkA/5D5LBMscNnuo++eEtvdmmoJ1IamlBdK3z39oqpad1oMPw8c qdmuk4iHFSI/bq5Ci0mxPXMpqiHlJ8+zbXVlFeOfMXXwaue2HUMgsUOnqFvFimzllDg1 alAg== X-Gm-Message-State: ALoCoQnAAfuwTuIBYc/DiDA1kaQdXrMsol7yJBBOFyycMX5i6HGrCLaQU1zHRvxUJD29Q/VNOCU6 X-Received: by 10.42.82.79 with SMTP id c15mr10840560icl.7.1408815585422; Sat, 23 Aug 2014 10:39:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.42 with SMTP id j39ls1621508qge.89.gmail; Sat, 23 Aug 2014 10:39:45 -0700 (PDT) X-Received: by 10.52.52.136 with SMTP id t8mr7806619vdo.21.1408815585334; Sat, 23 Aug 2014 10:39:45 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id cb8si14254816vcb.36.2014.08.23.10.39.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 23 Aug 2014 10:39:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so13577852vcb.19 for ; Sat, 23 Aug 2014 10:39:45 -0700 (PDT) X-Received: by 10.220.44.80 with SMTP id z16mr9223568vce.7.1408815585251; Sat, 23 Aug 2014 10:39:45 -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 uj3csp3460vcb; Sat, 23 Aug 2014 10:39:44 -0700 (PDT) X-Received: by 10.180.74.42 with SMTP id q10mr5057601wiv.39.1408815584122; Sat, 23 Aug 2014 10:39:44 -0700 (PDT) Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id n1si3059012wia.93.2014.08.23.10.39.43 for ; Sat, 23 Aug 2014 10:39:44 -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 D0B0D4A051; Sat, 23 Aug 2014 19:39:42 +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 9tn+qYbADFJS; Sat, 23 Aug 2014 19:39:42 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 629514A056; Sat, 23 Aug 2014 19:39:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8ECA74A051 for ; Sat, 23 Aug 2014 19:39:38 +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 ANm6AOtbH-55 for ; Sat, 23 Aug 2014 19:39:37 +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 376144B14B for ; Sat, 23 Aug 2014 19:39:26 +0200 (CEST) X-IronPort-AV: E=Sophos;i="5.04,387,1406617200"; d="scan'208";a="43680143" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw1-out.broadcom.com with ESMTP; 23 Aug 2014 11:31:25 -0700 Received: from IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Sat, 23 Aug 2014 10:39:14 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP3.corp.ad.broadcom.com (10.9.207.53) with Microsoft SMTP Server id 14.3.174.1; Sat, 23 Aug 2014 10:39:14 -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 E53AD9F9F9; Sat, 23 Aug 2014 10:39:13 -0700 (PDT) From: Steve Rae To: , Tom Rini Date: Sat, 23 Aug 2014 10:39:02 -0700 Message-ID: <1408815543-4591-4-git-send-email-srae@broadcom.com> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1408815543-4591-1-git-send-email-srae@broadcom.com> References: <1408815543-4591-1-git-send-email-srae@broadcom.com> MIME-Version: 1.0 Cc: Steve Rae Subject: [U-Boot] [PATCH v1 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.174 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 --- Licenses/bsd-3L-clause.txt | 24 +++++++++ common/aboot.c | 120 +++++++++++++++++++++------------------------ 2 files changed, 79 insertions(+), 65 deletions(-) create mode 100644 Licenses/bsd-3L-clause.txt diff --git a/Licenses/bsd-3L-clause.txt b/Licenses/bsd-3L-clause.txt new file mode 100644 index 0000000..3a08ce4 --- /dev/null +++ b/Licenses/bsd-3L-clause.txt @@ -0,0 +1,24 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. 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. +3. 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. diff --git a/common/aboot.c b/common/aboot.c index a302c92..f38fc95 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-3L-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;