1 --- a/tools/socfpgaimage.c
2 +++ b/tools/socfpgaimage.c
3 @@ -74,12 +74,12 @@ static uint16_t hdr_checksum(struct socf
4 static void build_header(uint8_t *buf, uint8_t version, uint8_t flags,
7 - header.validation = htole32(VALIDATION_WORD);
8 + header.validation = cpu_to_le32(VALIDATION_WORD);
9 header.version = version;
11 - header.length_u32 = htole16(length_bytes/4);
12 + header.length_u32 = cpu_to_le16(length_bytes/4);
14 - header.checksum = htole16(hdr_checksum(&header));
15 + header.checksum = cpu_to_le16(hdr_checksum(&header));
17 memcpy(buf, &header, sizeof(header));
19 @@ -92,12 +92,12 @@ static int verify_header(const uint8_t *
21 memcpy(&header, buf, sizeof(header));
23 - if (le32toh(header.validation) != VALIDATION_WORD)
24 + if (le32_to_cpu(header.validation) != VALIDATION_WORD)
26 - if (le16toh(header.checksum) != hdr_checksum(&header))
27 + if (le16_to_cpu(header.checksum) != hdr_checksum(&header))
30 - return le16toh(header.length_u32) * 4;
31 + return le16_to_cpu(header.length_u32) * 4;
34 /* Sign the buffer and return the signed buffer size */
35 @@ -116,7 +116,7 @@ static int sign_buffer(uint8_t *buf,
36 /* Calculate and apply the CRC */
37 calc_crc = ~pbl_crc32(0, (char *)buf, len);
39 - *((uint32_t *)(buf + len)) = htole32(calc_crc);
40 + *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc);
44 @@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *
46 calc_crc = ~pbl_crc32(0, (const char *)buf, len);
48 - buf_crc = le32toh(*((uint32_t *)(buf + len)));
49 + buf_crc = le32_to_cpu(*((uint32_t *)(buf + len)));
51 if (buf_crc != calc_crc) {
52 fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",