summaryrefslogtreecommitdiff
path: root/common/hash.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-01-26 11:43:14 -0700
committerTom Rini <trini@konsulko.com>2025-02-03 16:00:42 -0600
commit5929c2f39f557940a49d2852f95ade939358b705 (patch)
tree2c9a6ace6bddd7958f312afcbed2549499b5cf49 /common/hash.c
parent00ae9b2ac3493ed74449cd3b7cf50bce1b98d36d (diff)
lib: Allow crc16 code to be dropped
This code is not necessarily needed in VPL, even if SPL uses it, so adjust the rules to allow it to be dropped. Do the same for the hash API. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/hash.c')
-rw-r--r--common/hash.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/common/hash.c b/common/hash.c
index 8dd9da85768..0c45992d5c7 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -143,7 +143,8 @@ static int __maybe_unused hash_finish_sha512(struct hash_algo *algo, void *ctx,
return 0;
}
-static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp)
+static int __maybe_unused hash_init_crc16_ccitt(struct hash_algo *algo,
+ void **ctxp)
{
uint16_t *ctx = malloc(sizeof(uint16_t));
*ctx = 0;
@@ -151,16 +152,18 @@ static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp)
return 0;
}
-static int hash_update_crc16_ccitt(struct hash_algo *algo, void *ctx,
- const void *buf, unsigned int size,
- int is_last)
+static int __maybe_unused hash_update_crc16_ccitt(struct hash_algo *algo,
+ void *ctx, const void *buf,
+ unsigned int size,
+ int is_last)
{
*((uint16_t *)ctx) = crc16_ccitt(*((uint16_t *)ctx), buf, size);
return 0;
}
-static int hash_finish_crc16_ccitt(struct hash_algo *algo, void *ctx,
- void *dest_buf, int size)
+static int __maybe_unused hash_finish_crc16_ccitt(struct hash_algo *algo,
+ void *ctx, void *dest_buf,
+ int size)
{
if (size < algo->digest_size)
return -1;
@@ -295,6 +298,7 @@ static struct hash_algo hash_algo[] = {
#endif
},
#endif
+#if CONFIG_IS_ENABLED(CRC16)
{
.name = "crc16-ccitt",
.digest_size = 2,
@@ -304,6 +308,7 @@ static struct hash_algo hash_algo[] = {
.hash_update = hash_update_crc16_ccitt,
.hash_finish = hash_finish_crc16_ccitt,
},
+#endif
#if CONFIG_IS_ENABLED(CRC8) && IS_ENABLED(CONFIG_HASH_CRC8)
{
.name = "crc8",