blob: e273c275d0850fe04a00c87be8ab4e7e905cd4ba [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001--- 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,
5 uint16_t length_bytes)
6 {
7- header.validation = htole32(VALIDATION_WORD);
8+ header.validation = cpu_to_le32(VALIDATION_WORD);
9 header.version = version;
10 header.flags = flags;
11- header.length_u32 = htole16(length_bytes/4);
12+ header.length_u32 = cpu_to_le16(length_bytes/4);
13 header.zero = 0;
14- header.checksum = htole16(hdr_checksum(&header));
15+ header.checksum = cpu_to_le16(hdr_checksum(&header));
16
17 memcpy(buf, &header, sizeof(header));
18 }
19@@ -92,12 +92,12 @@ static int verify_header(const uint8_t *
20 {
21 memcpy(&header, buf, sizeof(header));
22
23- if (le32toh(header.validation) != VALIDATION_WORD)
24+ if (le32_to_cpu(header.validation) != VALIDATION_WORD)
25 return -1;
26- if (le16toh(header.checksum) != hdr_checksum(&header))
27+ if (le16_to_cpu(header.checksum) != hdr_checksum(&header))
28 return -1;
29
30- return le16toh(header.length_u32) * 4;
31+ return le16_to_cpu(header.length_u32) * 4;
32 }
33
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);
38
39- *((uint32_t *)(buf + len)) = htole32(calc_crc);
40+ *((uint32_t *)(buf + len)) = cpu_to_le32(calc_crc);
41
42 if (!pad_64k)
43 return len + 4;
44@@ -150,7 +150,7 @@ static int verify_buffer(const uint8_t *
45
46 calc_crc = ~pbl_crc32(0, (const char *)buf, len);
47
48- buf_crc = le32toh(*((uint32_t *)(buf + len)));
49+ buf_crc = le32_to_cpu(*((uint32_t *)(buf + len)));
50
51 if (buf_crc != calc_crc) {
52 fprintf(stderr, "CRC32 does not match (%08x != %08x)\n",