aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crc32.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/crc32.c')
-rw-r--r--lib/crc32.c54
1 files changed, 22 insertions, 32 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index 065198f98b3f..285fd9bc61be 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -42,20 +42,21 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch@dell.com>");
42MODULE_DESCRIPTION("Ethernet CRC32 calculations"); 42MODULE_DESCRIPTION("Ethernet CRC32 calculations");
43MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
44 44
45/**
46 * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
47 * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
48 * other uses, or the previous crc32 value if computing incrementally.
49 * @p: pointer to buffer over which CRC is run
50 * @len: length of buffer @p
51 */
52u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len);
53
45#if CRC_LE_BITS == 1 54#if CRC_LE_BITS == 1
46/* 55/*
47 * In fact, the table-based code will work in this case, but it can be 56 * In fact, the table-based code will work in this case, but it can be
48 * simplified by inlining the table in ?: form. 57 * simplified by inlining the table in ?: form.
49 */ 58 */
50 59
51/**
52 * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
53 * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
54 * other uses, or the previous crc32 value if computing incrementally.
55 * @p - pointer to buffer over which CRC is run
56 * @len - length of buffer @p
57 *
58 */
59u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len) 60u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
60{ 61{
61 int i; 62 int i;
@@ -68,14 +69,6 @@ u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
68} 69}
69#else /* Table-based approach */ 70#else /* Table-based approach */
70 71
71/**
72 * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
73 * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
74 * other uses, or the previous crc32 value if computing incrementally.
75 * @p - pointer to buffer over which CRC is run
76 * @len - length of buffer @p
77 *
78 */
79u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len) 72u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
80{ 73{
81# if CRC_LE_BITS == 8 74# if CRC_LE_BITS == 8
@@ -145,20 +138,21 @@ u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
145} 138}
146#endif 139#endif
147 140
141/**
142 * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
143 * @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
144 * other uses, or the previous crc32 value if computing incrementally.
145 * @p: pointer to buffer over which CRC is run
146 * @len: length of buffer @p
147 */
148u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len);
149
148#if CRC_BE_BITS == 1 150#if CRC_BE_BITS == 1
149/* 151/*
150 * In fact, the table-based code will work in this case, but it can be 152 * In fact, the table-based code will work in this case, but it can be
151 * simplified by inlining the table in ?: form. 153 * simplified by inlining the table in ?: form.
152 */ 154 */
153 155
154/**
155 * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
156 * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
157 * other uses, or the previous crc32 value if computing incrementally.
158 * @p - pointer to buffer over which CRC is run
159 * @len - length of buffer @p
160 *
161 */
162u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len) 156u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
163{ 157{
164 int i; 158 int i;
@@ -173,14 +167,6 @@ u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
173} 167}
174 168
175#else /* Table-based approach */ 169#else /* Table-based approach */
176/**
177 * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
178 * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
179 * other uses, or the previous crc32 value if computing incrementally.
180 * @p - pointer to buffer over which CRC is run
181 * @len - length of buffer @p
182 *
183 */
184u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len) 170u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
185{ 171{
186# if CRC_BE_BITS == 8 172# if CRC_BE_BITS == 8
@@ -249,6 +235,10 @@ u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
249} 235}
250#endif 236#endif
251 237
238/**
239 * bitreverse - reverse the order of bits in a u32 value
240 * @x: value to be bit-reversed
241 */
252u32 bitreverse(u32 x) 242u32 bitreverse(u32 x)
253{ 243{
254 x = (x >> 16) | (x << 16); 244 x = (x >> 16) | (x << 16);