]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
lib: Allow crc16 code to be dropped
authorSimon Glass <sjg@chromium.org>
Sun, 26 Jan 2025 18:43:14 +0000 (11:43 -0700)
committerTom Rini <trini@konsulko.com>
Mon, 3 Feb 2025 22:00:42 +0000 (16:00 -0600)
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>
common/hash.c
lib/Kconfig
lib/Makefile
tools/Kconfig

index 8dd9da8576833d23b1e42945997a98a3468f0bd6..0c45992d5c7a70bc5ca437465b96c769496278fd 100644 (file)
@@ -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",
index b27965fc480ddc92276c98d78bc8b3d5f1129a4c..1a683dea6708dd1731ed6053aa1b393aec333ff4 100644 (file)
@@ -758,6 +758,16 @@ config VPL_CRC8
          checksum with feedback to produce an 8-bit result. The code is small
          and it does not require a lookup table (unlike CRC32).
 
+config CRC16
+       bool "Support CRC16"
+       default y
+       help
+         Enables CRC16 support. This is normally required. Two algorithms are
+         provided:
+
+           - CCITT, with a polynomical x^16 + x^12 + x^5 + 1
+           - standard, with polynomial x^16 + x^15 + x^2 + 1 (0x8005)
+
 config SPL_CRC16
        bool "Support CRC16 in SPL"
        depends on SPL
index fc6e68c901a338a938a911dd3101d2e59050b9c8..06bbbb48a055472b39f779c0bd937af12457478a 100644 (file)
@@ -35,8 +35,6 @@ obj-$(CONFIG_CIRCBUF) += circbuf.o
 endif
 
 obj-y += crc8.o
-obj-y += crc16.o
-obj-y += crc16-ccitt.o
 obj-$(CONFIG_ERRNO_STR) += errno_str.o
 obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
@@ -71,6 +69,7 @@ endif
 
 obj-$(CONFIG_$(PHASE_)CRC8) += crc8.o
 obj-$(CONFIG_$(PHASE_)CRC16) += crc16.o
+obj-$(CONFIG_$(PHASE_)CRC16) += crc16-ccitt.o
 
 obj-y += crypto/
 
index 5c75af48fe3204fa8650b192180f91bb4642ec54..01ff0fcf748186e9a416fb5f49a5b872a05890b8 100644 (file)
@@ -9,6 +9,11 @@ config MKIMAGE_DTC_PATH
          some cases the system dtc may not support all required features
          and the path to a different version should be given here.
 
+config TOOLS_CRC16
+       def_bool y
+       help
+         Enable CRC32 support in the tools builds
+
 config TOOLS_CRC32
        def_bool y
        help