bcm57xx: Refactor CRC code to remove extra byteswap

This commit is contained in:
Marcus Comstedt 2020-11-29 10:10:03 +01:00 committed by Richard Hughes
parent 4a74a87d1e
commit 6035b520b7
5 changed files with 6 additions and 6 deletions

View File

@ -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 */

View File

@ -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));
}

View File

@ -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);

View File

@ -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));
}

View File

@ -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));
}