* [PATCH] crc32: Don't reference unnecessary crc32 tables in single-bit mode
@ 2012-01-21 0:36 Darrick J. Wong
2012-01-21 1:47 ` Randy Dunlap
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2012-01-21 0:36 UTC (permalink / raw)
To: Andrew Morton, Randy Dunlap; +Cc: linux-kernel, Stephen Rothwell
When compiling with single bit mode (CRC32_BIT=y) we shouldn't reference the
crc32 tables, since they aren't built in single-bit mode. Many thanks to Randy
Dunlap for finding this bug:
http://marc.info/?l=linux-kernel&m=132709702422141&w=2
This patch is against next-20120120.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
lib/crc32.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/lib/crc32.c b/lib/crc32.c
index ebc5911..b0d278f 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -174,16 +174,26 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p,
return crc;
}
+#if CRC_LE_BITS == 1
+u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
+{
+ return crc32_le_generic(crc, p, len, NULL, CRCPOLY_LE);
+}
+u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
+{
+ return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE);
+}
+#else
u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
{
return crc32_le_generic(crc, p, len, crc32table_le, CRCPOLY_LE);
}
-EXPORT_SYMBOL(crc32_le);
-
u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
{
return crc32_le_generic(crc, p, len, crc32ctable_le, CRC32C_POLY_LE);
}
+#endif
+EXPORT_SYMBOL(crc32_le);
EXPORT_SYMBOL(__crc32c_le);
/**
@@ -233,10 +243,17 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p,
return crc;
}
+#if CRC_LE_BITS == 1
+u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
+{
+ return crc32_be_generic(crc, p, len, NULL, CRCPOLY_BE);
+}
+#else
u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
{
return crc32_be_generic(crc, p, len, crc32table_be, CRCPOLY_BE);
}
+#endif
EXPORT_SYMBOL(crc32_be);
#ifdef CONFIG_CRC32_SELFTEST
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] crc32: Don't reference unnecessary crc32 tables in single-bit mode
2012-01-21 0:36 [PATCH] crc32: Don't reference unnecessary crc32 tables in single-bit mode Darrick J. Wong
@ 2012-01-21 1:47 ` Randy Dunlap
0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2012-01-21 1:47 UTC (permalink / raw)
To: djwong; +Cc: Andrew Morton, linux-kernel, Stephen Rothwell
On 01/20/2012 04:36 PM, Darrick J. Wong wrote:
> When compiling with single bit mode (CRC32_BIT=y) we shouldn't reference the
> crc32 tables, since they aren't built in single-bit mode. Many thanks to Randy
> Dunlap for finding this bug:
> http://marc.info/?l=linux-kernel&m=132709702422141&w=2
>
> This patch is against next-20120120.
>
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Thanks.
> ---
>
> lib/crc32.c | 21 +++++++++++++++++++--
> 1 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/lib/crc32.c b/lib/crc32.c
> index ebc5911..b0d278f 100644
> --- a/lib/crc32.c
> +++ b/lib/crc32.c
> @@ -174,16 +174,26 @@ static inline u32 __pure crc32_le_generic(u32 crc, unsigned char const *p,
> return crc;
> }
>
> +#if CRC_LE_BITS == 1
> +u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
> +{
> + return crc32_le_generic(crc, p, len, NULL, CRCPOLY_LE);
> +}
> +u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
> +{
> + return crc32_le_generic(crc, p, len, NULL, CRC32C_POLY_LE);
> +}
> +#else
> u32 __pure crc32_le(u32 crc, unsigned char const *p, size_t len)
> {
> return crc32_le_generic(crc, p, len, crc32table_le, CRCPOLY_LE);
> }
> -EXPORT_SYMBOL(crc32_le);
> -
> u32 __pure __crc32c_le(u32 crc, unsigned char const *p, size_t len)
> {
> return crc32_le_generic(crc, p, len, crc32ctable_le, CRC32C_POLY_LE);
> }
> +#endif
> +EXPORT_SYMBOL(crc32_le);
> EXPORT_SYMBOL(__crc32c_le);
>
> /**
> @@ -233,10 +243,17 @@ static inline u32 __pure crc32_be_generic(u32 crc, unsigned char const *p,
> return crc;
> }
>
> +#if CRC_LE_BITS == 1
> +u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
> +{
> + return crc32_be_generic(crc, p, len, NULL, CRCPOLY_BE);
> +}
> +#else
> u32 __pure crc32_be(u32 crc, unsigned char const *p, size_t len)
> {
> return crc32_be_generic(crc, p, len, crc32table_be, CRCPOLY_BE);
> }
> +#endif
> EXPORT_SYMBOL(crc32_be);
>
> #ifdef CONFIG_CRC32_SELFTEST
>
> --
--
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-21 0:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-21 0:36 [PATCH] crc32: Don't reference unnecessary crc32 tables in single-bit mode Darrick J. Wong
2012-01-21 1:47 ` Randy Dunlap
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®