Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 29786
b: refs/heads/master
c: 2f72100
h: refs/heads/master
v: v3
  • Loading branch information
Randy Dunlap authored and Linus Torvalds committed Jun 25, 2006
1 parent 72cd926 commit f41c428
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 28e83baac20e3fe624af89a55eb06c2a7cab6828
refs/heads/master: 2f72100c01dd31d769097c58874e8ab1e70b2518
6 changes: 6 additions & 0 deletions trunk/Documentation/DocBook/kernel-api.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ X!Ilib/string.c
<sect1><title>Command-line Parsing</title>
!Elib/cmdline.c
</sect1>

<sect1><title>CRC Functions</title>
!Elib/crc16.c
!Elib/crc32.c
!Elib/crc-ccitt.c
</sect1>
</chapter>

<chapter id="mm">
Expand Down
6 changes: 3 additions & 3 deletions trunk/lib/crc-ccitt.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ EXPORT_SYMBOL(crc_ccitt_table);

/**
* crc_ccitt - recompute the CRC for the data buffer
* @crc - previous CRC value
* @buffer - data pointer
* @len - number of bytes in the buffer
* @crc: previous CRC value
* @buffer: data pointer
* @len: number of bytes in the buffer
*/
u16 crc_ccitt(u16 crc, u8 const *buffer, size_t len)
{
Expand Down
10 changes: 5 additions & 5 deletions trunk/lib/crc16.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ u16 const crc16_table[256] = {
EXPORT_SYMBOL(crc16_table);

/**
* Compute the CRC-16 for the data buffer
* crc16 - compute the CRC-16 for the data buffer
* @crc: previous CRC value
* @buffer: data pointer
* @len: number of bytes in the buffer
*
* @param crc previous CRC value
* @param buffer data pointer
* @param len number of bytes in the buffer
* @return the updated CRC value
* Returns the updated CRC value.
*/
u16 crc16(u16 crc, u8 const *buffer, size_t len)
{
Expand Down
54 changes: 22 additions & 32 deletions trunk/lib/crc32.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ MODULE_AUTHOR("Matt Domsch <Matt_Domsch@dell.com>");
MODULE_DESCRIPTION("Ethernet CRC32 calculations");
MODULE_LICENSE("GPL");

/**
* crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
* @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
* other uses, or the previous crc32 value if computing incrementally.
* @p: pointer to buffer over which CRC is run
* @len: length of buffer @p
*/
u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len);

#if CRC_LE_BITS == 1
/*
* In fact, the table-based code will work in this case, but it can be
* simplified by inlining the table in ?: form.
*/

/**
* crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
* @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
* other uses, or the previous crc32 value if computing incrementally.
* @p - pointer to buffer over which CRC is run
* @len - length of buffer @p
*
*/
u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
{
int i;
Expand All @@ -68,14 +69,6 @@ u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
}
#else /* Table-based approach */

/**
* crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
* @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
* other uses, or the previous crc32 value if computing incrementally.
* @p - pointer to buffer over which CRC is run
* @len - length of buffer @p
*
*/
u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
{
# if CRC_LE_BITS == 8
Expand Down Expand Up @@ -145,20 +138,21 @@ u32 __attribute_pure__ crc32_le(u32 crc, unsigned char const *p, size_t len)
}
#endif

/**
* crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
* @crc: seed value for computation. ~0 for Ethernet, sometimes 0 for
* other uses, or the previous crc32 value if computing incrementally.
* @p: pointer to buffer over which CRC is run
* @len: length of buffer @p
*/
u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len);

#if CRC_BE_BITS == 1
/*
* In fact, the table-based code will work in this case, but it can be
* simplified by inlining the table in ?: form.
*/

/**
* crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
* @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
* other uses, or the previous crc32 value if computing incrementally.
* @p - pointer to buffer over which CRC is run
* @len - length of buffer @p
*
*/
u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
{
int i;
Expand All @@ -173,14 +167,6 @@ u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
}

#else /* Table-based approach */
/**
* crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
* @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
* other uses, or the previous crc32 value if computing incrementally.
* @p - pointer to buffer over which CRC is run
* @len - length of buffer @p
*
*/
u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
{
# if CRC_BE_BITS == 8
Expand Down Expand Up @@ -249,6 +235,10 @@ u32 __attribute_pure__ crc32_be(u32 crc, unsigned char const *p, size_t len)
}
#endif

/**
* bitreverse - reverse the order of bits in a u32 value
* @x: value to be bit-reversed
*/
u32 bitreverse(u32 x)
{
x = (x >> 16) | (x << 16);
Expand Down

0 comments on commit f41c428

Please sign in to comment.