mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Johannes Zink <j.zink@pengutronix.de>
To: patchwork-jzi@pengutronix.de
Cc: Johannes Zink <j.zink@pengutronix.de>,
	 Barebox Mailing List <barebox@lists.infradead.org>
Subject: [PATCH] crypto: crc32: make crc32 available in PBL
Date: Tue, 29 Aug 2023 11:28:59 +0200	[thread overview]
Message-ID: <20230829-crc32_in_pbl-v1-1-6a3e01a74c8d@pengutronix.de> (raw)

crc32 may be required in PBL for checking data integrity. Add
CONFIG_CRC32_EARLY to kconfig which allows adding crc32 also in the PBL.

As the PBL has no dynamic allocation, do not use dynamic CRC table
generation when CRC32 is added in PBL.

Signed-off-by: Johannes Zink <j.zink@pengutronix.de>
---
To: Barebox Mailing List <barebox@lists.infradead.org>
Cc: Johannes Zink <j.zink@pengutronix.de>
Cc: patchwork-jzi@pengutronix.de
---
 crypto/Kconfig  | 3 +++
 crypto/Makefile | 1 +
 crypto/crc32.c  | 6 +++---
 3 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index 04e5ef43705b..6e18b5868061 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -5,6 +5,9 @@ menu "Crypto support"
 config CRC32
 	bool
 
+config CRC32_EARLY
+	bool
+
 config CRC_ITU_T
 	bool
 
diff --git a/crypto/Makefile b/crypto/Makefile
index 22035d4f69ee..24e1f3d91797 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_DIGEST_SHA1_GENERIC)	+= sha1.o
 obj-$(CONFIG_DIGEST_SHA224_GENERIC)	+= sha2.o
 obj-$(CONFIG_DIGEST_SHA256_GENERIC)	+= sha2.o
 pbl-y					+= sha2.o digest.o
+lwl-$(CONFIG_CRC32_EARLY)		+= crc32.o
 obj-$(CONFIG_DIGEST_SHA384_GENERIC)	+= sha4.o
 obj-$(CONFIG_DIGEST_SHA512_GENERIC)	+= sha4.o
 obj-y	+= memneq.o
diff --git a/crypto/crc32.c b/crypto/crc32.c
index 95cb2212db2b..284d39351682 100644
--- a/crypto/crc32.c
+++ b/crypto/crc32.c
@@ -22,7 +22,7 @@
 #define STATIC static inline
 #endif
 
-#ifdef CONFIG_DYNAMIC_CRC_TABLE
+#if defined(CONFIG_DYNAMIC_CRC_TABLE) && !defined(__PBL__)
 
 static uint32_t *crc_table;
 
@@ -145,7 +145,7 @@ STATIC uint32_t crc32(uint32_t crc, const void *_buf, unsigned int len)
 {
     const unsigned char *buf = _buf;
 
-#ifdef CONFIG_DYNAMIC_CRC_TABLE
+#if defined(CONFIG_DYNAMIC_CRC_TABLE) && !defined(__PBL__)
 	if (!crc_table)
 		make_crc_table();
 #endif
@@ -171,7 +171,7 @@ STATIC uint32_t crc32_no_comp(uint32_t crc, const void *_buf, unsigned int len)
 {
    const unsigned char *buf = _buf;
 
-#ifdef CONFIG_DYNAMIC_CRC_TABLE
+#if defined(CONFIG_DYNAMIC_CRC_TABLE) && !defined(__PBL__)
 	if (!crc_table)
 		make_crc_table();
 #endif

---
base-commit: bef38b18eeb5d2f1fac334fb8b831e47261e099c
change-id: 20230829-crc32_in_pbl-4d824629d4e2

Best regards,
-- 
Johannes Zink <j.zink@pengutronix.de>




             reply	other threads:[~2023-08-29  9:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29  9:28 Johannes Zink [this message]
2023-08-29 10:29 ` Ahmad Fatoum
2023-08-29 10:45   ` Ahmad Fatoum
2023-08-29 10:55     ` Johannes Zink
2023-08-29 11:08       ` Ahmad Fatoum
2023-08-29 12:05         ` Johannes Zink
2023-08-29 12:17           ` Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230829-crc32_in_pbl-v1-1-6a3e01a74c8d@pengutronix.de \
    --to=j.zink@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=patchwork-jzi@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox