aboutsummaryrefslogtreecommitdiff
path: root/common/hash.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-09-25 19:43:24 -0600
committerTom Rini <trini@konsulko.com>2021-10-08 15:53:26 -0400
commite7d285b2f38202f9d7ffbdcae59283f08bafd8b9 (patch)
treefb0f32f97c2267949ca6146cc6c0ab94d3ffe8a2 /common/hash.c
parent2bbed3ff8c7fa0c0fa3fd28a9497bf7a99e3388b (diff)
downloadu-boot-e7d285b2f38202f9d7ffbdcae59283f08bafd8b9.zip
u-boot-e7d285b2f38202f9d7ffbdcae59283f08bafd8b9.tar.gz
u-boot-e7d285b2f38202f9d7ffbdcae59283f08bafd8b9.tar.bz2
image: Use the correct checks for CRC32
Add a host Kconfig for CRC32. With this we can use CONFIG_IS_ENABLED(CRC32) directly in the host build, so drop the unnecessary indirection. Add a few more conditions to SPL_CRC32 to avoid build failures as well as TPL_CRC32. Also update hash.c to make crc32 optional and to actually take notice of SPL_CRC32. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
Diffstat (limited to 'common/hash.c')
-rw-r--r--common/hash.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/common/hash.c b/common/hash.c
index 3b591ba0..79202e1 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -178,7 +178,7 @@ static int hash_finish_crc16_ccitt(struct hash_algo *algo, void *ctx,
return 0;
}
-static int hash_init_crc32(struct hash_algo *algo, void **ctxp)
+static int __maybe_unused hash_init_crc32(struct hash_algo *algo, void **ctxp)
{
uint32_t *ctx = malloc(sizeof(uint32_t));
*ctx = 0;
@@ -186,15 +186,16 @@ static int hash_init_crc32(struct hash_algo *algo, void **ctxp)
return 0;
}
-static int hash_update_crc32(struct hash_algo *algo, void *ctx,
- const void *buf, unsigned int size, int is_last)
+static int __maybe_unused hash_update_crc32(struct hash_algo *algo, void *ctx,
+ const void *buf, unsigned int size,
+ int is_last)
{
*((uint32_t *)ctx) = crc32(*((uint32_t *)ctx), buf, size);
return 0;
}
-static int hash_finish_crc32(struct hash_algo *algo, void *ctx, void *dest_buf,
- int size)
+static int __maybe_unused hash_finish_crc32(struct hash_algo *algo, void *ctx,
+ void *dest_buf, int size)
{
if (size < algo->digest_size)
return -1;
@@ -311,6 +312,7 @@ static struct hash_algo hash_algo[] = {
.hash_update = hash_update_crc16_ccitt,
.hash_finish = hash_finish_crc16_ccitt,
},
+#if CONFIG_IS_ENABLED(CRC32)
{
.name = "crc32",
.digest_size = 4,
@@ -320,6 +322,7 @@ static struct hash_algo hash_algo[] = {
.hash_update = hash_update_crc32,
.hash_finish = hash_finish_crc32,
},
+#endif
};
/* Try to minimize code size for boards that don't want much hashing */