From: Eric Biggers <ebiggers@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>, linux-crypto@vger.kernel.org
Subject: [PATCH 2/3] lib/crc/crc32: change crc32() from macro to inline function and remove cast
Date: Thu, 19 Jun 2025 11:34:13 -0700 [thread overview]
Message-ID: <20250619183414.100082-3-ebiggers@kernel.org> (raw)
In-Reply-To: <20250619183414.100082-1-ebiggers@kernel.org>
From: Eric Biggers <ebiggers@google.com>
There's no need for crc32() to be a macro. Make it an inline function
instead. Also, remove the cast of the data pointer to
'unsigned char const *', which is no longer necessary now that the type
used in the function prototype is 'const void *'.
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
include/linux/crc32.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/crc32.h b/include/linux/crc32.h
index f9c173206d4d1..da78b215ff2e9 100644
--- a/include/linux/crc32.h
+++ b/include/linux/crc32.h
@@ -28,10 +28,16 @@
* Context: Any context
* Return: The new CRC value
*/
u32 crc32_le(u32 crc, const void *p, size_t len);
+/* This is just an alias for crc32_le(). */
+static inline u32 crc32(u32 crc, const void *p, size_t len)
+{
+ return crc32_le(crc, p, len);
+}
+
/**
* crc32_be() - Compute most-significant-bit-first IEEE CRC-32
* @crc: Initial CRC value. ~0 (recommended) or 0 for a new CRC computation, or
* the previous CRC value if computing incrementally.
* @p: Pointer to the data buffer
@@ -88,12 +94,10 @@ u32 crc32c(u32 crc, const void *p, size_t len);
u32 crc32_optimizations(void);
#else
static inline u32 crc32_optimizations(void) { return 0; }
#endif
-#define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)(data), length)
-
/*
* Helpers for hash table generation of ethernet nics:
*
* Ethernet sends the least significant bit of a byte first, thus crc32_le
* is used. The output of crc32_le is bit reversed [most significant bit
--
2.50.0
next prev parent reply other threads:[~2025-06-19 18:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-19 18:34 [PATCH 0/3] lib/crc: improve docs and change crc32() to inline function Eric Biggers
2025-06-19 18:34 ` [PATCH 1/3] lib/crc/crc32: document crc32_le(), crc32_be(), and crc32c() Eric Biggers
2025-06-19 18:34 ` Eric Biggers [this message]
2025-06-20 7:01 ` [PATCH 2/3] lib/crc/crc32: change crc32() from macro to inline function and remove cast kernel test robot
2025-06-19 18:34 ` [PATCH 3/3] lib/crc/crc64: add include/linux/crc64.h to kernel-api.rst Eric Biggers
2025-06-20 21:40 ` [PATCH 0/3] lib/crc: improve docs and change crc32() to inline function Ard Biesheuvel
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=20250619183414.100082-3-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=ardb@kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).