diff mbox

[v2,3/4] cleanup code which handles the Android sparse image format

Message ID 1409248434-25762-4-git-send-email-srae@broadcom.com
State New
Headers show

Commit Message

Steve Rae Aug. 28, 2014, 5:53 p.m. UTC
- update license format
- port dprintf() to debug()
- update formatting

Signed-off-by: Steve Rae <srae@broadcom.com>
---

Changes in v2:
- use BSD-3-Clause

 common/aboot.c | 120 ++++++++++++++++++++++++++-------------------------------
 1 file changed, 55 insertions(+), 65 deletions(-)

Comments

Tom Rini Aug. 28, 2014, 7:43 p.m. UTC | #1
On Thu, Aug 28, 2014 at 10:53:53AM -0700, Steve Rae wrote:
> - update license format
> - port dprintf() to debug()
> - update formatting
> 
> Signed-off-by: Steve Rae <srae@broadcom.com>
> ---
> 
> 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
>   */

OK, sorry for the churn.  After you pointed out the other differences, I
re-asked legal who look a closer look (they started with my "they just
changed this one thing..") and do believe the license is GPL compatible
but it is NOT BSD-3-Clause.  So I think rather than make a one-off tag
lets just leave the full text and insert a note saying it's a slightly
different wording from normal BSD-3, and we inherit this license as-is
from Android.
Steve Rae Aug. 28, 2014, 8:33 p.m. UTC | #2
On 14-08-28 12:43 PM, Tom Rini wrote:
> On Thu, Aug 28, 2014 at 10:53:53AM -0700, Steve Rae wrote:
>> - update license format
>> - port dprintf() to debug()
>> - update formatting
>>
>> Signed-off-by: Steve Rae <srae@broadcom.com>
>> ---
>>
>> 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
>>    */
>
> OK, sorry for the churn.  After you pointed out the other differences, I
> re-asked legal who look a closer look (they started with my "they just
> changed this one thing..") and do believe the license is GPL compatible
> but it is NOT BSD-3-Clause.  So I think rather than make a one-off tag
> lets just leave the full text and insert a note saying it's a slightly
> different wording from normal BSD-3, and we inherit this license as-is
> from Android.
>

comments:
(1) I suspect that the "Linux Foundation" has adopted this "license 
text", and I also suspect that we will likely getting more code from 
there; thus, while it is one-off right now, I 'm guessing that will 
change...
(2) so "v3" will leave the original text in place, and add the following:
  * NOTE:
  *   Although it is very similar, this license text is not identical
  *   to the "BSD-3-Clause", therefore, DO NOT MODIFY THIS LICENSE TEXT!
Is this what you would like?
  ( my preference would be to add the BSD-3L-Clause ... )
Thanks, Steve
diff mbox

Patch

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; chunk<sparse_header->total_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;