From 6035b520b71615c95af9f4a64307495fe16a4ed1 Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 29 Nov 2020 10:10:03 +0100 Subject: [PATCH] bcm57xx: Refactor CRC code to remove extra byteswap --- plugins/bcm57xx/fu-bcm57xx-common.c | 4 ++-- plugins/bcm57xx/fu-bcm57xx-dict-image.c | 2 +- plugins/bcm57xx/fu-bcm57xx-firmware.c | 2 +- plugins/bcm57xx/fu-bcm57xx-stage1-image.c | 2 +- plugins/bcm57xx/fu-bcm57xx-stage2-image.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/bcm57xx/fu-bcm57xx-common.c b/plugins/bcm57xx/fu-bcm57xx-common.c index d7df0cf58..88639ed66 100644 --- a/plugins/bcm57xx/fu-bcm57xx-common.c +++ b/plugins/bcm57xx/fu-bcm57xx-common.c @@ -14,7 +14,7 @@ guint32 fu_bcm57xx_nvram_crc (const guint8 *buf, gsize bufsz) { - return GUINT32_SWAP_LE_BE (fu_common_crc32 (buf, bufsz)); + return fu_common_crc32 (buf, bufsz); } gboolean @@ -27,7 +27,7 @@ fu_bcm57xx_verify_crc (GBytes *fw, GError **error) /* expected */ if (!fu_common_read_uint32_safe (buf, bufsz, bufsz - sizeof(guint32), - &crc_file, G_BIG_ENDIAN, error)) + &crc_file, G_LITTLE_ENDIAN, error)) return FALSE; /* reality */ diff --git a/plugins/bcm57xx/fu-bcm57xx-dict-image.c b/plugins/bcm57xx/fu-bcm57xx-dict-image.c index c499bbb94..cddc74933 100644 --- a/plugins/bcm57xx/fu-bcm57xx-dict-image.c +++ b/plugins/bcm57xx/fu-bcm57xx-dict-image.c @@ -71,7 +71,7 @@ fu_bcm57xx_dict_image_write (FuFirmwareImage *image, GError **error) /* add CRC */ crc = fu_bcm57xx_nvram_crc (buf, bufsz); - fu_byte_array_append_uint32 (blob, crc, G_BIG_ENDIAN); + fu_byte_array_append_uint32 (blob, crc, G_LITTLE_ENDIAN); return g_byte_array_free_to_bytes (g_steal_pointer (&blob)); } diff --git a/plugins/bcm57xx/fu-bcm57xx-firmware.c b/plugins/bcm57xx/fu-bcm57xx-firmware.c index 8e49baec8..f23253411 100644 --- a/plugins/bcm57xx/fu-bcm57xx-firmware.c +++ b/plugins/bcm57xx/fu-bcm57xx-firmware.c @@ -443,7 +443,7 @@ fu_bcm57xx_firmware_write (FuFirmware *firmware, GError **error) fu_byte_array_append_uint32 (buf, self->phys_addr, G_BIG_ENDIAN); fu_byte_array_append_uint32 (buf, g_bytes_get_size (blob_stage1) / sizeof(guint32), G_BIG_ENDIAN); fu_byte_array_append_uint32 (buf, BCM_NVRAM_STAGE1_BASE, G_BIG_ENDIAN); - fu_byte_array_append_uint32 (buf, fu_bcm57xx_nvram_crc (buf->data, buf->len), G_BIG_ENDIAN); + fu_byte_array_append_uint32 (buf, fu_bcm57xx_nvram_crc (buf->data, buf->len), G_LITTLE_ENDIAN); /* add directory entries */ blob_dicts = g_ptr_array_new_with_free_func ((GDestroyNotify) g_bytes_unref); diff --git a/plugins/bcm57xx/fu-bcm57xx-stage1-image.c b/plugins/bcm57xx/fu-bcm57xx-stage1-image.c index 93d5a1268..94fa6c884 100644 --- a/plugins/bcm57xx/fu-bcm57xx-stage1-image.c +++ b/plugins/bcm57xx/fu-bcm57xx-stage1-image.c @@ -104,7 +104,7 @@ fu_bcm57xx_stage1_image_write (FuFirmwareImage *image, GError **error) /* add CRC */ crc = fu_bcm57xx_nvram_crc (buf, bufsz); - fu_byte_array_append_uint32 (blob, crc, G_BIG_ENDIAN); + fu_byte_array_append_uint32 (blob, crc, G_LITTLE_ENDIAN); return g_byte_array_free_to_bytes (g_steal_pointer (&blob)); } diff --git a/plugins/bcm57xx/fu-bcm57xx-stage2-image.c b/plugins/bcm57xx/fu-bcm57xx-stage2-image.c index f9c2f6fc4..20025f1f2 100644 --- a/plugins/bcm57xx/fu-bcm57xx-stage2-image.c +++ b/plugins/bcm57xx/fu-bcm57xx-stage2-image.c @@ -61,7 +61,7 @@ fu_bcm57xx_stage2_image_write (FuFirmwareImage *image, GError **error) g_byte_array_append (blob, buf, bufsz); /* add CRC */ - fu_byte_array_append_uint32 (blob, fu_bcm57xx_nvram_crc (buf, bufsz), G_BIG_ENDIAN); + fu_byte_array_append_uint32 (blob, fu_bcm57xx_nvram_crc (buf, bufsz), G_LITTLE_ENDIAN); return g_byte_array_free_to_bytes (g_steal_pointer (&blob)); }