mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-06 04:57:59 +00:00
bcm57xx: Refactor CRC code to remove extra byteswap
This commit is contained in:
parent
4a74a87d1e
commit
6035b520b7
@ -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 */
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user