diff mbox

[U-Boot,V5,3/4] driver/fm: fdt.c: fix fdt_fixup_fman_firmware() to support ARM platforms

Message ID 1455771722-18111-4-git-send-email-Qianyu.Gong@nxp.com
State Accepted
Commit 6fc9535f397bace13324546f070e40979ac03d13
Delegated to: York Sun
Headers show

Commit Message

Gong Qianyu Feb. 18, 2016, 5:02 a.m. UTC
Use fdt32_to_cpu() to convert the data correctly for both endianness
platforms.

Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
---
V5:
 - New Patch.

 drivers/net/fm/fdt.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

York Sun Feb. 24, 2016, 4:55 p.m. UTC | #1
On 02/17/2016 09:11 PM, Gong Qianyu wrote:
> Use fdt32_to_cpu() to convert the data correctly for both endianness
> platforms.
> 
> Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com>
> ---
> V5:
>  - New Patch.
> 
>  drivers/net/fm/fdt.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 

Applied to fsl-qoriq master. Awaiting upstream.

York
diff mbox

Patch

diff --git a/drivers/net/fm/fdt.c b/drivers/net/fm/fdt.c
index 830d228..9918d80 100644
--- a/drivers/net/fm/fdt.c
+++ b/drivers/net/fm/fdt.c
@@ -45,7 +45,7 @@  void fdt_fixup_fman_firmware(void *blob)
 		return;
 
 	hdr = &fmanfw->header;
-	length = be32_to_cpu(hdr->length);
+	length = fdt32_to_cpu(hdr->length);
 
 	/* Verify the firmware. */
 	if ((hdr->magic[0] != 'Q') || (hdr->magic[1] != 'E') ||
@@ -61,14 +61,16 @@  void fdt_fixup_fman_firmware(void *blob)
 	}
 
 	length -= sizeof(u32);	/* Subtract the size of the CRC */
-	crc = be32_to_cpu(*(u32 *)((void *)fmanfw + length));
+	crc = fdt32_to_cpu(*(u32 *)((void *)fmanfw + length));
 	if (crc != crc32_no_comp(0, (void *)fmanfw, length)) {
 		printf("Fman firmware at %p has invalid CRC\n", fmanfw);
 		return;
 	}
 
+	length += sizeof(u32);
+
 	/* Increase the size of the fdt to make room for the node. */
-	rc = fdt_increase_size(blob, fmanfw->header.length);
+	rc = fdt_increase_size(blob, length);
 	if (rc < 0) {
 		printf("Unable to make room for Fman firmware: %s\n",
 		       fdt_strerror(rc));
@@ -101,8 +103,7 @@  void fdt_fixup_fman_firmware(void *blob)
 		       fdt_strerror(rc));
 		return;
 	}
-	rc = fdt_setprop(blob, fwnode, "fsl,firmware", fmanfw,
-			 fmanfw->header.length);
+	rc = fdt_setprop(blob, fwnode, "fsl,firmware", fmanfw, length);
 	if (rc < 0) {
 		char s[64];
 		fdt_get_path(blob, fwnode, s, sizeof(s));