WOLK v4.16s: usbnet needs crc32 (patch attached)
Carl Hagmueller <[email protected]> Tue, 26 Oct 2004 14:39:33 -0400
| Newsgroups | gmane.linux.wolk.devel |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C4BB8B.2347E8E0
Content-Type: text/plain;
charset="iso-8859-1"
Hi Marc,
I ran across the following issue after building a kernel with usbnet as a
module:
depmod: *** Unresolved symbols in
/lib/modules/2.4.20-4.16.WOLKsmp/kernel/drivers/usb/usbnet.o
depmod: crc32_le
I did some investigation and found that indeed, usbnet requires crc32_le.
I've attached a patch, derived from Alan Cox's 2.4.21 patchset, which
defines crc32 as a library module and adjusts all references to crc32_le,
crc32_be and bitreverse to use this new module. I went over the patch
carefully, but as I'm a 'newbie kernel hacker', you might want to take a
look at it yourself.
Thanks for all your hard work on WOLK!
-- Carl
------_=_NextPart_000_01C4BB8B.2347E8E0
Content-Type: application/octet-stream;
name="linux-2.4.20-crc32-lib.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="linux-2.4.20-crc32-lib.patch"
diff -Naurp linux-10/drivers/net/Makefile.lib =
linux-20/drivers/net/Makefile.lib=0A=
--- linux-10/drivers/net/Makefile.lib 1969-12-31 19:00:00.000000000 =
-0500=0A=
+++ linux-20/drivers/net/Makefile.lib 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -0,0 +1,71 @@=0A=
+# These drivers all require crc32.o=0A=
+obj-$(CONFIG_8139CP) +=3D crc32.o=0A=
+obj-$(CONFIG_8139TOO) +=3D crc32.o=0A=
+obj-$(CONFIG_A2065) +=3D crc32.o=0A=
+obj-$(CONFIG_ADAPTEC_STARFIRE) +=3D crc32.o=0A=
+obj-$(CONFIG_ARM_AM79C961A) +=3D crc32.o=0A=
+obj-$(CONFIG_ATP) +=3D crc32.o=0A=
+obj-$(CONFIG_AT1700) +=3D crc32.o=0A=
+obj-$(CONFIG_NET_AMD811) +=3D crc32.o=0A=
+obj-$(CONFIG_BMAC) +=3D crc32.o=0A=
+obj-$(CONFIG_DE4X5) +=3D crc32.o=0A=
+obj-$(CONFIG_DECLANCE) +=3D crc32.o=0A=
+obj-$(CONFIG_DEPCA) +=3D crc32.o=0A=
+obj-$(CONFIG_DL2K) +=3D crc32.o=0A=
+obj-$(CONFIG_DM9102) +=3D crc32.o=0A=
+obj-$(CONFIG_EPIC100) +=3D crc32.o=0A=
+obj-$(CONFIG_EWRK3) +=3D crc32.o=0A=
+obj-$(CONFIG_FEALNX) +=3D crc32.o=0A=
+obj-$(CONFIG_GMAC) +=3D crc32.o=0A=
+obj-$(CONFIG_SGI_IOC3_ETH) +=3D crc32.o=0A=
+obj-$(CONFIG_HAPPYMEAL) +=3D crc32.o=0A=
+obj-$(CONFIG_MACE) +=3D crc32.o=0A=
+obj-$(CONFIG_PCNET32) +=3D crc32.o=0A=
+obj-$(CONFIG_R8169) +=3D crc32.o=0A=
+obj-$(CONFIG_SGI_IOC3_ETH) +=3D crc32.o=0A=
+obj-$(CONFIG_SIS900) +=3D crc32.o=0A=
+obj-$(CONFIG_SMC9194) +=3D crc32.o=0A=
+obj-$(CONFIG_SUNBMAC) +=3D crc32.o=0A=
+obj-$(CONFIG_SUNDANCE) +=3D crc32.o=0A=
+obj-$(CONFIG_SUNGEM) +=3D crc32.o=0A=
+obj-$(CONFIG_SUNLANCE) +=3D crc32.o=0A=
+obj-$(CONFIG_SUNQE) +=3D crc32.o=0A=
+obj-$(CONFIG_TYPHOON) +=3D crc32.o=0A=
+obj-$(CONFIG_VIA_RHINE) +=3D crc32.o=0A=
+obj-$(CONFIG_WINBOND_840) +=3D crc32.o=0A=
+obj-$(CONFIG_YELLOWFIN) +=3D crc32.o=0A=
+=0A=
+# These rely on drivers/net/7990.o which requires crc32.o=0A=
+obj-$(CONFIG_HPLANCE) +=3D crc32.o=0A=
+obj-$(CONFIG_MVME147_NET) +=3D crc32.o=0A=
+=0A=
+# These rely on drivers/net/8390.o which requires crc32.o=0A=
+obj-$(CONFIG_NE2K_ZORRO) +=3D crc32.o=0A=
+obj-$(CONFIG_MAC8390) +=3D crc32.o=0A=
+obj-$(CONFIG_OAKNET) +=3D crc32.o=0A=
+obj-$(CONFIG_NE2K_PCI) +=3D crc32.o=0A=
+obj-$(CONFIG_STNIC) +=3D crc32.o=0A=
+obj-$(CONFIG_WD80x3) +=3D crc32.o=0A=
+obj-$(CONFIG_EL2) +=3D crc32.o=0A=
+obj-$(CONFIG_NE2000) +=3D crc32.o=0A=
+obj-$(CONFIG_NE2_MCA) +=3D crc32.o=0A=
+obj-$(CONFIG_HPLAN) +=3D crc32.o=0A=
+obj-$(CONFIG_HPLAN_PLUS) +=3D crc32.o=0A=
+obj-$(CONFIG_ULTRA) +=3D crc32.o=0A=
+obj-$(CONFIG_ULTRAMCA) +=3D crc32.o=0A=
+obj-$(CONFIG_ULTRA32) +=3D crc32.o=0A=
+obj-$(CONFIG_E2100) +=3D crc32.o=0A=
+obj-$(CONFIG_ES3210) +=3D crc32.o=0A=
+obj-$(CONFIG_LNE390) +=3D crc32.o=0A=
+obj-$(CONFIG_NE3210) +=3D crc32.o=0A=
+obj-$(CONFIG_AC3200) +=3D crc32.o=0A=
+obj-$(CONFIG_HYDRA) +=3D crc32.o=0A=
+=0A=
+# drivers/net/pcmcia=0A=
+obj-$(CONFIG_PCMCIA_FMVJ18X) +=3D crc32.o=0A=
+obj-$(CONFIG_PCMCIA_SMC91C92) +=3D crc32.o=0A=
+obj-$(CONFIG_PCMCIA_XIRTULIP) +=3D crc32.o=0A=
+=0A=
+# drivers/net/tulip=0A=
+obj-$(CONFIG_TULIP) +=3D crc32.o=0A=
+=0A=
diff -Naurp linux-10/drivers/usb/Makefile.lib =
linux-20/drivers/usb/Makefile.lib=0A=
--- linux-10/drivers/usb/Makefile.lib 1969-12-31 19:00:00.000000000 =
-0500=0A=
+++ linux-20/drivers/usb/Makefile.lib 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -0,0 +1,3 @@=0A=
+obj-$(CONFIG_USB_USBNET) +=3D crc32.o=0A=
+obj-$(CONFIG_USB_CATC) +=3D crc32.o=0A=
+=0A=
diff -Naurp linux-10/fs/jffs2/crc32.c linux-20/fs/jffs2/crc32.c=0A=
--- linux-10/fs/jffs2/crc32.c 2001-09-14 17:04:07.000000000 -0400=0A=
+++ linux-20/fs/jffs2/crc32.c 1969-12-31 19:00:00.000000000 -0500=0A=
@@ -1,97 +0,0 @@=0A=
-/*=0A=
- * COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or=0A=
- * code or tables extracted from it, as desired without =
restriction.=0A=
- *=0A=
- * First, the polynomial itself and its table of feedback terms. =
The=0A=
- * polynomial is=0A=
- * =
X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0=0A=
- *=0A=
- * Note that we take it "backwards" and put the highest-order term =
in=0A=
- * the lowest-order bit. The X^32 term is "implied"; the LSB is =
the=0A=
- * X^31 term, etc. The X^0 term (usually shown as "+1") results =
in=0A=
- * the MSB being 1=0A=
- *=0A=
- * Note that the usual hardware shift register implementation, =
which=0A=
- * is what we're using (we're merely optimizing it by doing =
eight-bit=0A=
- * chunks at a time) shifts bits into the lowest-order term. In =
our=0A=
- * implementation, that means shifting towards the right. Why do =
we=0A=
- * do it this way? Because the calculated CRC must be transmitted =
in=0A=
- * order from highest-order term to lowest-order term. UARTs =
transmit=0A=
- * characters in order from LSB to MSB. By storing the CRC this =
way=0A=
- * we hand it to the UART in the order low-byte to high-byte; the =
UART=0A=
- * sends each low-bit to hight-bit; and the result is transmission =
bit=0A=
- * by bit from highest- to lowest-order term without requiring any =
bit=0A=
- * shuffling on our part. Reception works similarly=0A=
- *=0A=
- * The feedback terms table consists of 256, 32-bit entries. =
Notes=0A=
- *=0A=
- * The table can be generated at runtime if desired; code to do =
so=0A=
- * is shown later. It might not be obvious, but the feedback=0A=
- * terms simply represent the results of eight shift/xor opera=0A=
- * tions for all combinations of data and CRC register values=0A=
- *=0A=
- * The values must be right-shifted by eight bits by the =
"updcrc=0A=
- * logic; the shift must be unsigned (bring in zeroes). On =
some=0A=
- * hardware you could probably optimize the shift in assembler =
by=0A=
- * using byte-swap instructions=0A=
- * polynomial $edb88320=0A=
- */=0A=
-=0A=
-/* $Id: crc32.c,v 1.3 2001/02/07 16:45:32 dwmw2 Exp $ */=0A=
-=0A=
-#include "crc32.h"=0A=
-=0A=
-const __u32 crc32_table[256] =3D {=0A=
- 0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,=0A=
- 0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,=0A=
- 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,=0A=
- 0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,=0A=
- 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,=0A=
- 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,=0A=
- 0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,=0A=
- 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,=0A=
- 0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,=0A=
- 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,=0A=
- 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,=0A=
- 0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,=0A=
- 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,=0A=
- 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,=0A=
- 0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,=0A=
- 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,=0A=
- 0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,=0A=
- 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,=0A=
- 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,=0A=
- 0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,=0A=
- 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,=0A=
- 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,=0A=
- 0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,=0A=
- 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,=0A=
- 0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,=0A=
- 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,=0A=
- 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,=0A=
- 0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,=0A=
- 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,=0A=
- 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,=0A=
- 0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,=0A=
- 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,=0A=
- 0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,=0A=
- 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,=0A=
- 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,=0A=
- 0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,=0A=
- 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,=0A=
- 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,=0A=
- 0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,=0A=
- 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,=0A=
- 0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,=0A=
- 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,=0A=
- 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,=0A=
- 0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,=0A=
- 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,=0A=
- 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,=0A=
- 0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,=0A=
- 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,=0A=
- 0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,=0A=
- 0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,=0A=
- 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,=0A=
- 0x2d02ef8dL=0A=
-};=0A=
diff -Naurp linux-10/fs/jffs2/crc32.h linux-20/fs/jffs2/crc32.h=0A=
--- linux-10/fs/jffs2/crc32.h 2001-09-14 17:04:07.000000000 -0400=0A=
+++ linux-20/fs/jffs2/crc32.h 1969-12-31 19:00:00.000000000 -0500=0A=
@@ -1,21 +0,0 @@=0A=
-#ifndef CRC32_H=0A=
-#define CRC32_H=0A=
-=0A=
-/* $Id: crc32.h,v 1.3 2001/02/26 14:44:37 dwmw2 Exp $ */=0A=
-=0A=
-#include <linux/types.h>=0A=
-=0A=
-extern const __u32 crc32_table[256];=0A=
-=0A=
-/* Return a 32-bit CRC of the contents of the buffer. */=0A=
-=0A=
-static inline __u32 =0A=
-crc32(__u32 val, const void *ss, int len)=0A=
-{=0A=
- const unsigned char *s =3D ss;=0A=
- while (--len >=3D 0)=0A=
- val =3D crc32_table[(val ^ *s++) & 0xff] ^ (val >> =
8);=0A=
- return val;=0A=
-}=0A=
-=0A=
-#endif=0A=
diff -Naurp linux-10/fs/jffs2/dir.c linux-20/fs/jffs2/dir.c=0A=
--- linux-10/fs/jffs2/dir.c 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/jffs2/dir.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -43,7 +43,7 @@=0A=
#include <linux/jffs2_fs_i.h>=0A=
#include <linux/jffs2_fs_sb.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
static int jffs2_readdir (struct file *, void *, filldir_t);=0A=
=0A=
diff -Naurp linux-10/fs/jffs2/erase.c linux-20/fs/jffs2/erase.c=0A=
--- linux-10/fs/jffs2/erase.c 2002-08-02 20:39:45.000000000 -0400=0A=
+++ linux-20/fs/jffs2/erase.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -40,7 +40,7 @@=0A=
#include <linux/jffs2.h>=0A=
#include <linux/interrupt.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
struct erase_priv_struct {=0A=
struct jffs2_eraseblock *jeb;=0A=
diff -Naurp linux-10/fs/jffs2/file.c linux-20/fs/jffs2/file.c=0A=
--- linux-10/fs/jffs2/file.c 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/jffs2/file.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -42,7 +42,7 @@=0A=
#include <linux/pagemap.h>=0A=
#include <linux/jffs2.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
extern int generic_file_open(struct inode *, struct file *) =
__attribute__((weak));=0A=
extern loff_t generic_file_llseek(struct file *file, loff_t offset, =
int origin) __attribute__((weak));=0A=
diff -Naurp linux-10/fs/jffs2/gc.c linux-20/fs/jffs2/gc.c=0A=
--- linux-10/fs/jffs2/gc.c 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/jffs2/gc.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -43,7 +43,7 @@=0A=
#include <linux/interrupt.h>=0A=
#include <linux/pagemap.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, =
struct jffs2_eraseblock *jeb, =0A=
struct inode *inode, struct jffs2_full_dnode *fd);=0A=
diff -Naurp linux-10/fs/jffs2/Makefile linux-20/fs/jffs2/Makefile=0A=
--- linux-10/fs/jffs2/Makefile 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/jffs2/Makefile 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -12,7 +12,7 @@=0A=
=0A=
COMPR_OBJS :=3D compr.o compr_rubin.o compr_rtime.o pushpull.o \=0A=
compr_zlib.o=0A=
-JFFS2_OBJS :=3D crc32.o dir.o file.o ioctl.o nodelist.o malloc.o \=0A=
+JFFS2_OBJS :=3D dir.o file.o ioctl.o nodelist.o malloc.o \=0A=
read.o nodemgmt.o readinode.o super.o write.o scan.o gc.o \=0A=
symlink.o build.o erase.o background.o=0A=
=0A=
diff -Naurp linux-10/fs/jffs2/read.c linux-20/fs/jffs2/read.c=0A=
--- linux-10/fs/jffs2/read.c 2002-08-02 20:39:45.000000000 -0400=0A=
+++ linux-20/fs/jffs2/read.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -40,7 +40,7 @@=0A=
#include <linux/jffs2.h>=0A=
#include <linux/mtd/mtd.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_full_dnode =
*fd, unsigned char *buf, int ofs, int len)=0A=
{=0A=
diff -Naurp linux-10/fs/jffs2/readinode.c =
linux-20/fs/jffs2/readinode.c=0A=
--- linux-10/fs/jffs2/readinode.c 2002-11-28 18:53:15.000000000 =
-0500=0A=
+++ linux-20/fs/jffs2/readinode.c 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -44,7 +44,7 @@=0A=
#include <linux/mtd/mtd.h>=0A=
#include <linux/jffs2.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
=0A=
D1(void jffs2_print_frag_list(struct jffs2_inode_info *f)=0A=
diff -Naurp linux-10/fs/jffs2/scan.c linux-20/fs/jffs2/scan.c=0A=
--- linux-10/fs/jffs2/scan.c 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/jffs2/scan.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -40,7 +40,7 @@=0A=
#include <linux/mtd/mtd.h>=0A=
#include <linux/pagemap.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
=0A=
#define DIRTY_SPACE(x) do { typeof(x) _x =3D (x); \=0A=
diff -Naurp linux-10/fs/jffs2/write.c linux-20/fs/jffs2/write.c=0A=
--- linux-10/fs/jffs2/write.c 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/jffs2/write.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -40,7 +40,7 @@=0A=
#include <linux/jffs2.h>=0A=
#include <linux/mtd/mtd.h>=0A=
#include "nodelist.h"=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
/* jffs2_new_inode: allocate a new inode and inocache, add it to the =
hash,=0A=
fill in the raw_inode while you're at it. */=0A=
diff -Naurp linux-10/fs/Makefile.lib linux-20/fs/Makefile.lib=0A=
--- linux-10/fs/Makefile.lib 1969-12-31 19:00:00.000000000 -0500=0A=
+++ linux-20/fs/Makefile.lib 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -0,0 +1,2 @@=0A=
+obj-$(CONFIG_JFFS2_FS) +=3D crc32.o=0A=
+obj-$(CONFIG_EFI_PARTITION) +=3D crc32.o=0A=
diff -Naurp linux-10/fs/partitions/efi.c =
linux-20/fs/partitions/efi.c=0A=
--- linux-10/fs/partitions/efi.c 2002-11-28 18:53:15.000000000 -0500=0A=
+++ linux-20/fs/partitions/efi.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -99,6 +99,7 @@=0A=
#include <linux/slab.h>=0A=
#include <linux/smp_lock.h>=0A=
#include <linux/init.h>=0A=
+#include <linux/crc32.h>=0A=
#include <asm/system.h>=0A=
#include <asm/byteorder.h>=0A=
#include "check.h"=0A=
@@ -139,72 +140,6 @@ force_gpt_fn(char *str)=0A=
__setup("gpt", force_gpt_fn);=0A=
=0A=
=0A=
-/*=0A=
- * There are multiple 16-bit CRC polynomials in common use, but this =
is=0A=
- * *the* standard CRC-32 polynomial, first popularized by Ethernet.=0A=
- * =
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0=0A=
- */=0A=
-#define CRCPOLY_LE 0xedb88320=0A=
-/* How many bits at a time to use. Requires a table of 4<<CRC_xx_BITS =
bytes. */=0A=
-/* For less performance-sensitive, use 4 */=0A=
-#define CRC_LE_BITS 8=0A=
-static u32 *crc32table_le;=0A=
-=0A=
-/**=0A=
- * crc32init_le() - allocate and initialize LE table data=0A=
- *=0A=
- * crc is the crc of the byte i; other entries are filled in based on =
the=0A=
- * fact that crctable[i^j] =3D crctable[i] ^ crctable[j].=0A=
- *=0A=
- */=0A=
-static int __init crc32init_le(void)=0A=
-{=0A=
- unsigned i, j;=0A=
- u32 crc =3D 1;=0A=
-=0A=
- crc32table_le =3D=0A=
- kmalloc((1 << CRC_LE_BITS) * sizeof(u32), GFP_KERNEL);=0A=
- if (!crc32table_le)=0A=
- return 1;=0A=
- crc32table_le[0] =3D 0;=0A=
-=0A=
- for (i =3D 1 << (CRC_LE_BITS - 1); i; i >>=3D 1) {=0A=
- crc =3D (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);=0A=
- for (j =3D 0; j < 1 << CRC_LE_BITS; j +=3D 2 * i)=0A=
- crc32table_le[i + j] =3D crc ^ crc32table_le[j];=0A=
- }=0A=
- return 0;=0A=
-}=0A=
-=0A=
-/**=0A=
- * crc32cleanup_le(): free LE table data=0A=
- */=0A=
-static void __exit crc32cleanup_le(void)=0A=
-{=0A=
- if (crc32table_le) kfree(crc32table_le);=0A=
- crc32table_le =3D NULL;=0A=
-}=0A=
-=0A=
-__initcall(crc32init_le);=0A=
-__exitcall(crc32cleanup_le);=0A=
-=0A=
-/**=0A=
- * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II =
CRC32=0A=
- * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 =
for=0A=
- * other uses, or the previous crc32 value if computing =
incrementally.=0A=
- * @p - pointer to buffer over which CRC is run=0A=
- * @len - length of buffer @p=0A=
- * =0A=
- */=0A=
-static u32 crc32_le(u32 crc, unsigned char const *p, size_t len)=0A=
-{=0A=
- while (len--) {=0A=
- crc =3D (crc >> 8) ^ crc32table_le[(crc ^ *p++) & 255];=0A=
- }=0A=
- return crc;=0A=
-}=0A=
-=0A=
-=0A=
/**=0A=
* efi_crc32() - EFI version of crc32 function=0A=
* @buf: buffer to calculate crc32 of=0A=
@@ -220,7 +155,7 @@ static u32 crc32_le(u32 crc, unsigned ch=0A=
static inline u32=0A=
efi_crc32(const void *buf, unsigned long len)=0A=
{=0A=
- return (crc32_le(~0L, buf, len) ^ ~0L);=0A=
+ return (crc32(~0L, buf, len) ^ ~0L);=0A=
}=0A=
=0A=
/**=0A=
diff -Naurp linux-10/include/linux/crc32.h =
linux-20/include/linux/crc32.h=0A=
--- linux-10/include/linux/crc32.h 2002-08-02 20:39:45.000000000 =
-0400=0A=
+++ linux-20/include/linux/crc32.h 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -1,49 +1,27 @@=0A=
/*=0A=
- * crc32.h for early Linux 2.4.19pre kernel inclusion=0A=
- * This defines ether_crc_le() and ether_crc() as inline functions=0A=
- * This is slated to change to using the library crc32 functions=0A=
- * as kernel 2.5.2 included at some future date.=0A=
+ * crc32.h=0A=
+ * See linux/lib/crc32.c for license and changes =0A=
*/=0A=
#ifndef _LINUX_CRC32_H=0A=
#define _LINUX_CRC32_H=0A=
=0A=
#include <linux/types.h>=0A=
=0A=
-/* The little-endian AUTODIN II ethernet CRC calculation.=0A=
- N.B. Do not use for bulk data, use a table-based routine =
instead.=0A=
- This is common code and should be moved to net/core/crc.c */=0A=
-static unsigned const ethernet_polynomial_le =3D 0xedb88320U;=0A=
-static inline unsigned ether_crc_le(int length, unsigned char =
*data)=0A=
-{=0A=
- unsigned int crc =3D 0xffffffff; /* Initial value. */=0A=
- while(--length >=3D 0) {=0A=
- unsigned char current_octet =3D *data++;=0A=
- int bit;=0A=
- for (bit =3D 8; --bit >=3D 0; current_octet >>=3D 1) {=0A=
- if ((crc ^ current_octet) & 1) {=0A=
- crc >>=3D 1;=0A=
- crc ^=3D ethernet_polynomial_le;=0A=
- } else=0A=
- crc >>=3D 1;=0A=
- }=0A=
- }=0A=
- return crc;=0A=
-}=0A=
+extern u32 crc32_le(u32 crc, unsigned char const *p, size_t len);=0A=
+extern u32 crc32_be(u32 crc, unsigned char const *p, size_t len);=0A=
+extern u32 bitreverse(u32 in);=0A=
=0A=
-static unsigned const ethernet_polynomial =3D 0x04c11db7U;=0A=
-static inline u32 ether_crc(int length, unsigned char *data)=0A=
-{=0A=
- int crc =3D -1;=0A=
- while (--length >=3D 0) {=0A=
- unsigned char current_octet =3D *data++;=0A=
- int bit;=0A=
- for (bit =3D 0; bit < 8; bit++, current_octet >>=3D 1) {=0A=
- crc =3D (crc << 1) ^=0A=
- ((crc < 0) ^ (current_octet & 1) ?=0A=
- ethernet_polynomial : 0);=0A=
- }=0A=
- }=0A=
- return crc;=0A=
-}=0A=
+#define crc32(seed, data, length) crc32_le(seed, (unsigned char const =
*)data, length)=0A=
=0A=
+/*=0A=
+ * Helpers for hash table generation of ethernet nics:=0A=
+ *=0A=
+ * Ethernet sends the least significant bit of a byte first, thus =
crc32_le=0A=
+ * is used. The output of crc32_le is bit reversed [most significant =
bit=0A=
+ * is in bit nr 0], thus it must be reversed before use. Except for=0A=
+ * nics that bit swap the result internally...=0A=
+ */=0A=
+#define ether_crc(length, data) bitreverse(crc32_le(~0, data, =
length))=0A=
+#define ether_crc_le(length, data) crc32_le(~0, data, length)=0A=
+ =0A=
#endif /* _LINUX_CRC32_H */=0A=
diff -Naurp linux-10/kernel/ksyms.c linux-20/kernel/ksyms.c=0A=
--- linux-10/kernel/ksyms.c 2004-10-16 12:50:57.000000000 -0400=0A=
+++ linux-20/kernel/ksyms.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -49,6 +49,7 @@=0A=
#include <linux/completion.h>=0A=
#include <linux/seq_file.h>=0A=
#include <linux/dnotify.h>=0A=
+#include <linux/crc32.h>=0A=
#include <linux/firmware.h>=0A=
#include <asm/checksum.h>=0A=
#include <linux/unistd.h>=0A=
@@ -655,6 +656,13 @@ EXPORT_SYMBOL(get_write_access);=0A=
EXPORT_SYMBOL(strnicmp);=0A=
EXPORT_SYMBOL(strspn);=0A=
EXPORT_SYMBOL(strsep);=0A=
+=0A=
+#ifdef CONFIG_CRC32=0A=
+EXPORT_SYMBOL(crc32_le);=0A=
+EXPORT_SYMBOL(crc32_be);=0A=
+EXPORT_SYMBOL(bitreverse);=0A=
+#endif=0A=
+=0A=
#if defined(CONFIG_QSORT) && ! defined(CONFIG_QSORT_MODULE)=0A=
EXPORT_SYMBOL(qsort);=0A=
#endif=0A=
diff -Naurp linux-10/lib/Config.in linux-20/lib/Config.in=0A=
--- linux-10/lib/Config.in 2004-10-16 12:50:57.000000000 -0400=0A=
+++ linux-20/lib/Config.in 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -4,7 +4,7 @@=0A=
mainmenu_option next_comment=0A=
comment 'Library routines'=0A=
=0A=
-#tristate 'CRC32 functions' CONFIG_CRC32=0A=
+tristate 'CRC32 functions' CONFIG_CRC32=0A=
=0A=
#=0A=
# Do we need the compression support?=0A=
diff -Naurp linux-10/lib/crc32.c linux-20/lib/crc32.c=0A=
--- linux-10/lib/crc32.c 1969-12-31 19:00:00.000000000 -0500=0A=
+++ linux-20/lib/crc32.c 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -0,0 +1,539 @@=0A=
+/* =0A=
+ * Oct 15, 2000 Matt Domsch <[email protected]>=0A=
+ * Nicer crc32 functions/docs submitted by [email protected]. =
Thanks!=0A=
+ *=0A=
+ * Oct 12, 2000 Matt Domsch <[email protected]>=0A=
+ * Same crc32 function was used in 5 other places in the kernel.=0A=
+ * I made one version, and deleted the others.=0A=
+ * There are various incantations of crc32(). Some use a seed of 0 or =
~0.=0A=
+ * Some xor at the end with ~0. The generic crc32() function takes=0A=
+ * seed as an argument, and doesn't xor at the end. Then =
individual=0A=
+ * users can do whatever they need.=0A=
+ * drivers/net/smc9194.c uses seed ~0, doesn't xor with ~0.=0A=
+ * fs/jffs2 uses seed 0, doesn't xor with ~0.=0A=
+ * fs/partitions/efi.c uses seed ~0, xor's with ~0.=0A=
+ * =0A=
+ */=0A=
+=0A=
+#include <linux/config.h>=0A=
+#include <linux/crc32.h>=0A=
+#include <linux/kernel.h>=0A=
+#include <linux/module.h>=0A=
+#include <linux/types.h>=0A=
+#include <linux/slab.h>=0A=
+#include <linux/init.h>=0A=
+#include <asm/atomic.h>=0A=
+#include "crc32defs.h"=0A=
+#if CRC_LE_BITS =3D=3D 8=0A=
+#define tole(x) __constant_cpu_to_le32(x)=0A=
+#define tobe(x) __constant_cpu_to_be32(x)=0A=
+#else=0A=
+#define tole(x) (x)=0A=
+#define tobe(x) (x)=0A=
+#endif=0A=
+#include "crc32table.h"=0A=
+=0A=
+#if __GNUC__ >=3D 3 /* 2.x has "attribute", but only 3.0 has "pure =
*/=0A=
+#define attribute(x) __attribute__(x)=0A=
+#else=0A=
+#define attribute(x)=0A=
+#endif=0A=
+=0A=
+/*=0A=
+ * This code is in the public domain; copyright abandoned.=0A=
+ * Liability for non-performance of this code is limited to the =
amount=0A=
+ * you paid for it. Since it is distributed for free, your refund =
will=0A=
+ * be very very small. If it breaks, you get to keep both pieces.=0A=
+ *=0A=
+ * The version included in the kernel is covered by the GPL. =0A=
+ *=0A=
+ * This program is distributed in the hope that it will be useful,=0A=
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of=0A=
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A=
+ * GNU General Public License for more details.=0A=
+ */=0A=
+=0A=
+MODULE_AUTHOR("Matt Domsch <[email protected]>");=0A=
+MODULE_DESCRIPTION("Ethernet CRC32 calculations");=0A=
+MODULE_LICENSE("GPL and additional rights");=0A=
+=0A=
+#if CRC_LE_BITS =3D=3D 1=0A=
+/*=0A=
+ * In fact, the table-based code will work in this case, but it can =
be=0A=
+ * simplified by inlining the table in ?: form.=0A=
+ */=0A=
+=0A=
+/**=0A=
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II =
CRC32=0A=
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 =
for=0A=
+ * other uses, or the previous crc32 value if computing =
incrementally.=0A=
+ * @p - pointer to buffer over which CRC is run=0A=
+ * @len - length of buffer @p=0A=
+ * =0A=
+ */=0A=
+u32 attribute((pure)) crc32_le(u32 crc, unsigned char const *p, size_t =
len)=0A=
+{=0A=
+ int i;=0A=
+ while (len--) {=0A=
+ crc ^=3D *p++;=0A=
+ for (i =3D 0; i < 8; i++)=0A=
+ crc =3D (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);=0A=
+ }=0A=
+ return crc;=0A=
+}=0A=
+#else /* Table-based approach */=0A=
+=0A=
+/**=0A=
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II =
CRC32=0A=
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 =
for=0A=
+ * other uses, or the previous crc32 value if computing =
incrementally.=0A=
+ * @p - pointer to buffer over which CRC is run=0A=
+ * @len - length of buffer @p=0A=
+ * =0A=
+ */=0A=
+u32 attribute((pure)) crc32_le(u32 crc, unsigned char const *p, size_t =
len)=0A=
+{=0A=
+# if CRC_LE_BITS =3D=3D 8=0A=
+ const u32 *b =3D(u32 *)p;=0A=
+ const u32 *tab =3D crc32table_le;=0A=
+=0A=
+# ifdef __LITTLE_ENDIAN=0A=
+# define DO_CRC(x) crc =3D tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)=0A=
+# else=0A=
+# define DO_CRC(x) crc =3D tab[ ((crc >> 24) ^ (x)) & 255] ^ =
(crc<<8)=0A=
+# endif=0A=
+=0A=
+ crc =3D __cpu_to_le32(crc);=0A=
+ /* Align it */=0A=
+ if(unlikely(((long)b)&3 && len)){=0A=
+ do {=0A=
+ DO_CRC(*((u8 *)b)++);=0A=
+ } while ((--len) && ((long)b)&3 );=0A=
+ }=0A=
+ if(likely(len >=3D 4)){=0A=
+ /* load data 32 bits wide, xor data 32 bits wide. */=0A=
+ size_t save_len =3D len & 3;=0A=
+ len =3D len >> 2;=0A=
+ --b; /* use pre increment below(*++b) for speed */=0A=
+ do {=0A=
+ crc ^=3D *++b;=0A=
+ DO_CRC(0);=0A=
+ DO_CRC(0);=0A=
+ DO_CRC(0);=0A=
+ DO_CRC(0);=0A=
+ } while (--len);=0A=
+ b++; /* point to next byte(s) */=0A=
+ len =3D save_len;=0A=
+ }=0A=
+ /* And the last few bytes */=0A=
+ if(len){=0A=
+ do {=0A=
+ DO_CRC(*((u8 *)b)++);=0A=
+ } while (--len);=0A=
+ }=0A=
+=0A=
+ return __le32_to_cpu(crc);=0A=
+#undef ENDIAN_SHIFT=0A=
+#undef DO_CRC=0A=
+=0A=
+# elif CRC_LE_BITS =3D=3D 4=0A=
+ while (len--) {=0A=
+ crc ^=3D *p++;=0A=
+ crc =3D (crc >> 4) ^ crc32table_le[crc & 15];=0A=
+ crc =3D (crc >> 4) ^ crc32table_le[crc & 15];=0A=
+ }=0A=
+ return crc;=0A=
+# elif CRC_LE_BITS =3D=3D 2=0A=
+ while (len--) {=0A=
+ crc ^=3D *p++;=0A=
+ crc =3D (crc >> 2) ^ crc32table_le[crc & 3];=0A=
+ crc =3D (crc >> 2) ^ crc32table_le[crc & 3];=0A=
+ crc =3D (crc >> 2) ^ crc32table_le[crc & 3];=0A=
+ crc =3D (crc >> 2) ^ crc32table_le[crc & 3];=0A=
+ }=0A=
+ return crc;=0A=
+# endif=0A=
+}=0A=
+#endif=0A=
+=0A=
+#if CRC_BE_BITS =3D=3D 1=0A=
+/*=0A=
+ * In fact, the table-based code will work in this case, but it can =
be=0A=
+ * simplified by inlining the table in ?: form.=0A=
+ */=0A=
+=0A=
+/**=0A=
+ * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II =
CRC32=0A=
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 =
for=0A=
+ * other uses, or the previous crc32 value if computing =
incrementally.=0A=
+ * @p - pointer to buffer over which CRC is run=0A=
+ * @len - length of buffer @p=0A=
+ * =0A=
+ */=0A=
+u32 attribute((pure)) crc32_be(u32 crc, unsigned char const *p, size_t =
len)=0A=
+{=0A=
+ int i;=0A=
+ while (len--) {=0A=
+ crc ^=3D *p++ << 24;=0A=
+ for (i =3D 0; i < 8; i++)=0A=
+ crc =3D=0A=
+ (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE :=0A=
+ 0);=0A=
+ }=0A=
+ return crc;=0A=
+}=0A=
+=0A=
+#else /* Table-based approach */=0A=
+/**=0A=
+ * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II =
CRC32=0A=
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 =
for=0A=
+ * other uses, or the previous crc32 value if computing =
incrementally.=0A=
+ * @p - pointer to buffer over which CRC is run=0A=
+ * @len - length of buffer @p=0A=
+ * =0A=
+ */=0A=
+u32 attribute((pure)) crc32_be(u32 crc, unsigned char const *p, size_t =
len)=0A=
+{=0A=
+# if CRC_BE_BITS =3D=3D 8=0A=
+ const u32 *b =3D(u32 *)p;=0A=
+ const u32 *tab =3D crc32table_be;=0A=
+=0A=
+# ifdef __LITTLE_ENDIAN=0A=
+# define DO_CRC(x) crc =3D tab[ (crc ^ (x)) & 255 ] ^ (crc>>8)=0A=
+# else=0A=
+# define DO_CRC(x) crc =3D tab[ ((crc >> 24) ^ (x)) & 255] ^ =
(crc<<8)=0A=
+# endif=0A=
+=0A=
+ crc =3D __cpu_to_be32(crc);=0A=
+ /* Align it */=0A=
+ if(unlikely(((long)b)&3 && len)){=0A=
+ do {=0A=
+ DO_CRC(*((u8 *)b)++);=0A=
+ } while ((--len) && ((long)b)&3 );=0A=
+ }=0A=
+ if(likely(len >=3D 4)){=0A=
+ /* load data 32 bits wide, xor data 32 bits wide. */=0A=
+ size_t save_len =3D len & 3;=0A=
+ len =3D len >> 2;=0A=
+ --b; /* use pre increment below(*++b) for speed */=0A=
+ do {=0A=
+ crc ^=3D *++b;=0A=
+ DO_CRC(0);=0A=
+ DO_CRC(0);=0A=
+ DO_CRC(0);=0A=
+ DO_CRC(0);=0A=
+ } while (--len);=0A=
+ b++; /* point to next byte(s) */=0A=
+ len =3D save_len;=0A=
+ }=0A=
+ /* And the last few bytes */=0A=
+ if(len){=0A=
+ do {=0A=
+ DO_CRC(*((u8 *)b)++);=0A=
+ } while (--len);=0A=
+ }=0A=
+ return __be32_to_cpu(crc);=0A=
+#undef ENDIAN_SHIFT=0A=
+#undef DO_CRC=0A=
+=0A=
+# elif CRC_BE_BITS =3D=3D 4=0A=
+ while (len--) {=0A=
+ crc ^=3D *p++ << 24;=0A=
+ crc =3D (crc << 4) ^ crc32table_be[crc >> 28];=0A=
+ crc =3D (crc << 4) ^ crc32table_be[crc >> 28];=0A=
+ }=0A=
+ return crc;=0A=
+# elif CRC_BE_BITS =3D=3D 2=0A=
+ while (len--) {=0A=
+ crc ^=3D *p++ << 24;=0A=
+ crc =3D (crc << 2) ^ crc32table_be[crc >> 30];=0A=
+ crc =3D (crc << 2) ^ crc32table_be[crc >> 30];=0A=
+ crc =3D (crc << 2) ^ crc32table_be[crc >> 30];=0A=
+ crc =3D (crc << 2) ^ crc32table_be[crc >> 30];=0A=
+ }=0A=
+ return crc;=0A=
+# endif=0A=
+}=0A=
+#endif=0A=
+=0A=
+u32 bitreverse(u32 x)=0A=
+{=0A=
+ x =3D (x >> 16) | (x << 16);=0A=
+ x =3D (x >> 8 & 0x00ff00ff) | (x << 8 & 0xff00ff00);=0A=
+ x =3D (x >> 4 & 0x0f0f0f0f) | (x << 4 & 0xf0f0f0f0);=0A=
+ x =3D (x >> 2 & 0x33333333) | (x << 2 & 0xcccccccc);=0A=
+ x =3D (x >> 1 & 0x55555555) | (x << 1 & 0xaaaaaaaa);=0A=
+ return x;=0A=
+}=0A=
+=0A=
+#if !defined(CONFIG_CRC32) /* These are exported from kernel/ksyms.c =
in the non-module=0A=
+ case, to ensure that this file is pulled in from lib/lib.a =
*/=0A=
+EXPORT_SYMBOL(crc32_le);=0A=
+EXPORT_SYMBOL(crc32_be);=0A=
+EXPORT_SYMBOL(bitreverse);=0A=
+#endif=0A=
+=0A=
+/*=0A=
+ * A brief CRC tutorial.=0A=
+ *=0A=
+ * A CRC is a long-division remainder. You add the CRC to the =
message,=0A=
+ * and the whole thing (message+CRC) is a multiple of the given=0A=
+ * CRC polynomial. To check the CRC, you can either check that the=0A=
+ * CRC matches the recomputed value, *or* you can check that the=0A=
+ * remainder computed on the message+CRC is 0. This latter =
approach=0A=
+ * is used by a lot of hardware implementations, and is why so many=0A=
+ * protocols put the end-of-frame flag after the CRC.=0A=
+ *=0A=
+ * It's actually the same long division you learned in school, except =
that=0A=
+ * - We're working in binary, so the digits are only 0 and 1, and=0A=
+ * - When dividing polynomials, there are no carries. Rather than add =
and=0A=
+ * subtract, we just xor. Thus, we tend to get a bit sloppy =
about=0A=
+ * the difference between adding and subtracting.=0A=
+ *=0A=
+ * A 32-bit CRC polynomial is actually 33 bits long. But since =
it's=0A=
+ * 33 bits long, bit 32 is always going to be set, so usually the =
CRC=0A=
+ * is written in hex with the most significant bit omitted. (If =
you're=0A=
+ * familiar with the IEEE 754 floating-point format, it's the same =
idea.)=0A=
+ *=0A=
+ * Note that a CRC is computed over a string of *bits*, so you have=0A=
+ * to decide on the endianness of the bits within each byte. To =
get=0A=
+ * the best error-detecting properties, this should correspond to =
the=0A=
+ * order they're actually sent. For example, standard RS-232 serial =
is=0A=
+ * little-endian; the most significant bit (sometimes used for =
parity)=0A=
+ * is sent last. And when appending a CRC word to a message, you =
should=0A=
+ * do it in the right order, matching the endianness.=0A=
+ *=0A=
+ * Just like with ordinary division, the remainder is always smaller =
than=0A=
+ * the divisor (the CRC polynomial) you're dividing by. Each step of =
the=0A=
+ * division, you take one more digit (bit) of the dividend and append =
it=0A=
+ * to the current remainder. Then you figure out the appropriate =
multiple=0A=
+ * of the divisor to subtract to being the remainder back into =
range.=0A=
+ * In binary, it's easy - it has to be either 0 or 1, and to make =
the=0A=
+ * XOR cancel, it's just a copy of bit 32 of the remainder.=0A=
+ *=0A=
+ * When computing a CRC, we don't care about the quotient, so we =
can=0A=
+ * throw the quotient bit away, but subtract the appropriate multiple =
of=0A=
+ * the polynomial from the remainder and we're back to where we =
started,=0A=
+ * ready to process the next bit.=0A=
+ *=0A=
+ * A big-endian CRC written this way would be coded like:=0A=
+ * for (i =3D 0; i < input_bits; i++) {=0A=
+ * multiple =3D remainder & 0x80000000 ? CRCPOLY : 0;=0A=
+ * remainder =3D (remainder << 1 | next_input_bit()) ^ multiple;=0A=
+ * }=0A=
+ * Notice how, to get at bit 32 of the shifted remainder, we look=0A=
+ * at bit 31 of the remainder *before* shifting it.=0A=
+ *=0A=
+ * But also notice how the next_input_bit() bits we're shifting =
into=0A=
+ * the remainder don't actually affect any decision-making until=0A=
+ * 32 bits later. Thus, the first 32 cycles of this are pretty =
boring.=0A=
+ * Also, to add the CRC to a message, we need a 32-bit-long hole for =
it at=0A=
+ * the end, so we have to add 32 extra cycles shifting in zeros at =
the=0A=
+ * end of every message,=0A=
+ *=0A=
+ * So the standard trick is to rearrage merging in the =
next_input_bit()=0A=
+ * until the moment it's needed. Then the first 32 cycles can be =
precomputed,=0A=
+ * and merging in the final 32 zero bits to make room for the CRC can =
be=0A=
+ * skipped entirely.=0A=
+ * This changes the code to:=0A=
+ * for (i =3D 0; i < input_bits; i++) {=0A=
+ * remainder ^=3D next_input_bit() << 31;=0A=
+ * multiple =3D (remainder & 0x80000000) ? CRCPOLY : 0;=0A=
+ * remainder =3D (remainder << 1) ^ multiple;=0A=
+ * }=0A=
+ * With this optimization, the little-endian code is simpler:=0A=
+ * for (i =3D 0; i < input_bits; i++) {=0A=
+ * remainder ^=3D next_input_bit();=0A=
+ * multiple =3D (remainder & 1) ? CRCPOLY : 0;=0A=
+ * remainder =3D (remainder >> 1) ^ multiple;=0A=
+ * }=0A=
+ *=0A=
+ * Note that the other details of endianness have been hidden in =
CRCPOLY=0A=
+ * (which must be bit-reversed) and next_input_bit().=0A=
+ *=0A=
+ * However, as long as next_input_bit is returning the bits in a =
sensible=0A=
+ * order, we can actually do the merging 8 or more bits at a time =
rather=0A=
+ * than one bit at a time:=0A=
+ * for (i =3D 0; i < input_bytes; i++) {=0A=
+ * remainder ^=3D next_input_byte() << 24;=0A=
+ * for (j =3D 0; j < 8; j++) {=0A=
+ * multiple =3D (remainder & 0x80000000) ? CRCPOLY : 0;=0A=
+ * remainder =3D (remainder << 1) ^ multiple;=0A=
+ * }=0A=
+ * }=0A=
+ * Or in little-endian:=0A=
+ * for (i =3D 0; i < input_bytes; i++) {=0A=
+ * remainder ^=3D next_input_byte();=0A=
+ * for (j =3D 0; j < 8; j++) {=0A=
+ * multiple =3D (remainder & 1) ? CRCPOLY : 0;=0A=
+ * remainder =3D (remainder << 1) ^ multiple;=0A=
+ * }=0A=
+ * }=0A=
+ * If the input is a multiple of 32 bits, you can even XOR in a =
32-bit=0A=
+ * word at a time and increase the inner loop count to 32.=0A=
+ *=0A=
+ * You can also mix and match the two loop styles, for example doing =
the=0A=
+ * bulk of a message byte-at-a-time and adding bit-at-a-time =
processing=0A=
+ * for any fractional bytes at the end.=0A=
+ *=0A=
+ * The only remaining optimization is to the byte-at-a-time table =
method.=0A=
+ * Here, rather than just shifting one bit of the remainder to =
decide=0A=
+ * in the correct multiple to subtract, we can shift a byte at a =
time.=0A=
+ * This produces a 40-bit (rather than a 33-bit) intermediate =
remainder,=0A=
+ * but again the multiple of the polynomial to subtract depends only =
on=0A=
+ * the high bits, the high 8 bits in this case. =0A=
+ *=0A=
+ * The multile we need in that case is the low 32 bits of a 40-bit=0A=
+ * value whose high 8 bits are given, and which is a multiple of =
the=0A=
+ * generator polynomial. This is simply the CRC-32 of the given=0A=
+ * one-byte message.=0A=
+ *=0A=
+ * Two more details: normally, appending zero bits to a message =
which=0A=
+ * is already a multiple of a polynomial produces a larger multiple of =
that=0A=
+ * polynomial. To enable a CRC to detect this condition, it's common =
to=0A=
+ * invert the CRC before appending it. This makes the remainder of =
the=0A=
+ * message+crc come out not as zero, but some fixed non-zero value.=0A=
+ *=0A=
+ * The same problem applies to zero bits prepended to the message, =
and=0A=
+ * a similar solution is used. Instead of starting with a remainder =
of=0A=
+ * 0, an initial remainder of all ones is used. As long as you =
start=0A=
+ * the same way on decoding, it doesn't make a difference.=0A=
+ */=0A=
+=0A=
+#if UNITTEST=0A=
+=0A=
+#include <stdlib.h>=0A=
+#include <stdio.h>=0A=
+=0A=
+#if 0 /*Not used at present */=0A=
+static void=0A=
+buf_dump(char const *prefix, unsigned char const *buf, size_t len)=0A=
+{=0A=
+ fputs(prefix, stdout);=0A=
+ while (len--)=0A=
+ printf(" %02x", *buf++);=0A=
+ putchar('\n');=0A=
+=0A=
+}=0A=
+#endif=0A=
+=0A=
+static void bytereverse(unsigned char *buf, size_t len)=0A=
+{=0A=
+ while (len--) {=0A=
+ unsigned char x =3D *buf;=0A=
+ x =3D (x >> 4) | (x << 4);=0A=
+ x =3D (x >> 2 & 0x33) | (x << 2 & 0xcc);=0A=
+ x =3D (x >> 1 & 0x55) | (x << 1 & 0xaa);=0A=
+ *buf++ =3D x;=0A=
+ }=0A=
+}=0A=
+=0A=
+static void random_garbage(unsigned char *buf, size_t len)=0A=
+{=0A=
+ while (len--)=0A=
+ *buf++ =3D (unsigned char) random();=0A=
+}=0A=
+=0A=
+#if 0 /* Not used at present */=0A=
+static void store_le(u32 x, unsigned char *buf)=0A=
+{=0A=
+ buf[0] =3D (unsigned char) x;=0A=
+ buf[1] =3D (unsigned char) (x >> 8);=0A=
+ buf[2] =3D (unsigned char) (x >> 16);=0A=
+ buf[3] =3D (unsigned char) (x >> 24);=0A=
+}=0A=
+#endif=0A=
+=0A=
+static void store_be(u32 x, unsigned char *buf)=0A=
+{=0A=
+ buf[0] =3D (unsigned char) (x >> 24);=0A=
+ buf[1] =3D (unsigned char) (x >> 16);=0A=
+ buf[2] =3D (unsigned char) (x >> 8);=0A=
+ buf[3] =3D (unsigned char) x;=0A=
+}=0A=
+=0A=
+/*=0A=
+ * This checks that CRC(buf + CRC(buf)) =3D 0, and that=0A=
+ * CRC commutes with bit-reversal. This has the side effect=0A=
+ * of bytewise bit-reversing the input buffer, and returns=0A=
+ * the CRC of the reversed buffer.=0A=
+ */=0A=
+static u32 test_step(u32 init, unsigned char *buf, size_t len)=0A=
+{=0A=
+ u32 crc1, crc2;=0A=
+ size_t i;=0A=
+=0A=
+ crc1 =3D crc32_be(init, buf, len);=0A=
+ store_be(crc1, buf + len);=0A=
+ crc2 =3D crc32_be(init, buf, len + 4);=0A=
+ if (crc2)=0A=
+ printf("\nCRC cancellation fail: 0x%08x should be 0\n",=0A=
+ crc2);=0A=
+=0A=
+ for (i =3D 0; i <=3D len + 4; i++) {=0A=
+ crc2 =3D crc32_be(init, buf, i);=0A=
+ crc2 =3D crc32_be(crc2, buf + i, len + 4 - i);=0A=
+ if (crc2)=0A=
+ printf("\nCRC split fail: 0x%08x\n", crc2);=0A=
+ }=0A=
+=0A=
+ /* Now swap it around for the other test */=0A=
+=0A=
+ bytereverse(buf, len + 4);=0A=
+ init =3D bitreverse(init);=0A=
+ crc2 =3D bitreverse(crc1);=0A=
+ if (crc1 !=3D bitreverse(crc2))=0A=
+ printf("\nBit reversal fail: 0x%08x -> %0x08x -> 0x%08x\n",=0A=
+ crc1, crc2, bitreverse(crc2));=0A=
+ crc1 =3D crc32_le(init, buf, len);=0A=
+ if (crc1 !=3D crc2)=0A=
+ printf("\nCRC endianness fail: 0x%08x !=3D 0x%08x\n", crc1,=0A=
+ crc2);=0A=
+ crc2 =3D crc32_le(init, buf, len + 4);=0A=
+ if (crc2)=0A=
+ printf("\nCRC cancellation fail: 0x%08x should be 0\n",=0A=
+ crc2);=0A=
+=0A=
+ for (i =3D 0; i <=3D len + 4; i++) {=0A=
+ crc2 =3D crc32_le(init, buf, i);=0A=
+ crc2 =3D crc32_le(crc2, buf + i, len + 4 - i);=0A=
+ if (crc2)=0A=
+ printf("\nCRC split fail: 0x%08x\n", crc2);=0A=
+ }=0A=
+=0A=
+ return crc1;=0A=
+}=0A=
+=0A=
+#define SIZE 64=0A=
+#define INIT1 0=0A=
+#define INIT2 0=0A=
+=0A=
+int main(void)=0A=
+{=0A=
+ unsigned char buf1[SIZE + 4];=0A=
+ unsigned char buf2[SIZE + 4];=0A=
+ unsigned char buf3[SIZE + 4];=0A=
+ int i, j;=0A=
+ u32 crc1, crc2, crc3;=0A=
+=0A=
+ for (i =3D 0; i <=3D SIZE; i++) {=0A=
+ printf("\rTesting length %d...", i);=0A=
+ fflush(stdout);=0A=
+ random_garbage(buf1, i);=0A=
+ random_garbage(buf2, i);=0A=
+ for (j =3D 0; j < i; j++)=0A=
+ buf3[j] =3D buf1[j] ^ buf2[j];=0A=
+=0A=
+ crc1 =3D test_step(INIT1, buf1, i);=0A=
+ crc2 =3D test_step(INIT2, buf2, i);=0A=
+ /* Now check that CRC(buf1 ^ buf2) =3D CRC(buf1) ^ CRC(buf2) */=0A=
+ crc3 =3D test_step(INIT1 ^ INIT2, buf3, i);=0A=
+ if (crc3 !=3D (crc1 ^ crc2))=0A=
+ printf("CRC XOR fail: 0x%08x !=3D 0x%08x ^ 0x%08x\n",=0A=
+ crc3, crc1, crc2);=0A=
+ }=0A=
+ printf("\nAll test complete. No failures expected.\n");=0A=
+ return 0;=0A=
+}=0A=
+=0A=
+#endif /* UNITTEST */=0A=
diff -Naurp linux-10/lib/crc32defs.h linux-20/lib/crc32defs.h=0A=
--- linux-10/lib/crc32defs.h 1969-12-31 19:00:00.000000000 -0500=0A=
+++ linux-20/lib/crc32defs.h 2004-10-16 13:00:34.000000000 -0400=0A=
@@ -0,0 +1,32 @@=0A=
+/*=0A=
+ * There are multiple 16-bit CRC polynomials in common use, but this =
is=0A=
+ * *the* standard CRC-32 polynomial, first popularized by Ethernet.=0A=
+ * =
x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0=0A=
+ */=0A=
+#define CRCPOLY_LE 0xedb88320=0A=
+#define CRCPOLY_BE 0x04c11db7=0A=
+=0A=
+/* How many bits at a time to use. Requires a table of 4<<CRC_xx_BITS =
bytes. */=0A=
+/* For less performance-sensitive, use 4 */=0A=
+#ifndef CRC_LE_BITS =0A=
+# define CRC_LE_BITS 8=0A=
+#endif=0A=
+#ifndef CRC_BE_BITS=0A=
+# define CRC_BE_BITS 8=0A=
+#endif=0A=
+=0A=
+/*=0A=
+ * Little-endian CRC computation. Used with serial bit streams =
sent=0A=
+ * lsbit-first. Be sure to use cpu_to_le32() to append the computed =
CRC.=0A=
+ */=0A=
+#if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & =
CRC_LE_BITS-1=0A=
+# error CRC_LE_BITS must be a power of 2 between 1 and 8=0A=
+#endif=0A=
+=0A=
+/*=0A=
+ * Big-endian CRC computation. Used with serial bit streams sent=0A=
+ * msbit-first. Be sure to use cpu_to_be32() to append the computed =
CRC.=0A=
+ */=0A=
+#if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & =
CRC_BE_BITS-1=0A=
+# error CRC_BE_BITS must be a power of 2 between 1 and 8=0A=
+#endif=0A=
diff -Naurp linux-10/lib/gen_crc32table.c =
linux-20/lib/gen_crc32table.c=0A=
--- linux-10/lib/gen_crc32table.c 1969-12-31 19:00:00.000000000 =
-0500=0A=
+++ linux-20/lib/gen_crc32table.c 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -0,0 +1,82 @@=0A=
+#include <stdio.h>=0A=
+#include "crc32defs.h"=0A=
+#include <sys/types.h>=0A=
+=0A=
+#define ENTRIES_PER_LINE 4=0A=
+=0A=
+#define LE_TABLE_SIZE (1 << CRC_LE_BITS)=0A=
+#define BE_TABLE_SIZE (1 << CRC_BE_BITS)=0A=
+=0A=
+static u_int32_t crc32table_le[LE_TABLE_SIZE];=0A=
+static u_int32_t crc32table_be[BE_TABLE_SIZE];=0A=
+=0A=
+/**=0A=
+ * crc32init_le() - allocate and initialize LE table data=0A=
+ *=0A=
+ * crc is the crc of the byte i; other entries are filled in based on =
the=0A=
+ * fact that crctable[i^j] =3D crctable[i] ^ crctable[j].=0A=
+ *=0A=
+ */=0A=
+static void crc32init_le(void)=0A=
+{=0A=
+ unsigned i, j;=0A=
+ u_int32_t crc =3D 1;=0A=
+=0A=
+ crc32table_le[0] =3D 0;=0A=
+=0A=
+ for (i =3D 1 << (CRC_LE_BITS - 1); i; i >>=3D 1) {=0A=
+ crc =3D (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);=0A=
+ for (j =3D 0; j < LE_TABLE_SIZE; j +=3D 2 * i)=0A=
+ crc32table_le[i + j] =3D crc ^ crc32table_le[j];=0A=
+ }=0A=
+}=0A=
+=0A=
+/**=0A=
+ * crc32init_be() - allocate and initialize BE table data=0A=
+ */=0A=
+static void crc32init_be(void)=0A=
+{=0A=
+ unsigned i, j;=0A=
+ u_int32_t crc =3D 0x80000000;=0A=
+=0A=
+ crc32table_be[0] =3D 0;=0A=
+=0A=
+ for (i =3D 1; i < BE_TABLE_SIZE; i <<=3D 1) {=0A=
+ crc =3D (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);=0A=
+ for (j =3D 0; j < i; j++)=0A=
+ crc32table_be[i + j] =3D crc ^ crc32table_be[j];=0A=
+ }=0A=
+}=0A=
+=0A=
+static void output_table(u_int32_t table[], int len, char *trans)=0A=
+{=0A=
+ int i;=0A=
+=0A=
+ for (i =3D 0; i < len - 1; i++) {=0A=
+ if (i % ENTRIES_PER_LINE =3D=3D 0)=0A=
+ printf("\n");=0A=
+ printf("%s(0x%8.8xL), ", trans, table[i]);=0A=
+ }=0A=
+ printf("%s(0x%8.8xL)\n", trans, table[len - 1]);=0A=
+}=0A=
+=0A=
+int main(int argc, char** argv)=0A=
+{=0A=
+ printf("/* this file is generated - do not edit */\n\n");=0A=
+=0A=
+ if (CRC_LE_BITS > 1) {=0A=
+ crc32init_le();=0A=
+ printf("static const u32 crc32table_le[] =3D {");=0A=
+ output_table(crc32table_le, LE_TABLE_SIZE, "tole");=0A=
+ printf("};\n");=0A=
+ }=0A=
+=0A=
+ if (CRC_BE_BITS > 1) {=0A=
+ crc32init_be();=0A=
+ printf("static const u32 crc32table_be[] =3D {");=0A=
+ output_table(crc32table_be, BE_TABLE_SIZE, "tobe");=0A=
+ printf("};\n");=0A=
+ }=0A=
+=0A=
+ return 0;=0A=
+}=0A=
diff -Naurp linux-10/lib/Makefile linux-20/lib/Makefile=0A=
--- linux-10/lib/Makefile 2004-10-16 12:50:57.000000000 -0400=0A=
+++ linux-20/lib/Makefile 2004-10-16 13:01:34.000000000 -0400=0A=
@@ -9,7 +9,7 @@=0A=
L_TARGET :=3D lib.a=0A=
=0A=
export-objs :=3D cmdline.o dec_and_lock.o rwsem-spinlock.o rwsem.o =
\=0A=
- rbtree.o qsort.o firmware_class.o=0A=
+ rbtree.o crc32.o qsort.o firmware_class.o=0A=
=0A=
obj-y :=3D errno.o ctype.o string.o vsprintf.o brlock.o cmdline.o \=0A=
bust_spinlocks.o rbtree.o dump_stack.o propolice.o=0A=
@@ -23,9 +23,16 @@ ifneq ($(CONFIG_HAVE_DEC_LOCK),y) =0A=
obj-y +=3D dec_and_lock.o=0A=
endif=0A=
=0A=
+obj-$(CONFIG_CRC32) +=3D crc32.o=0A=
+=0A=
subdir-$(CONFIG_ZLIB_INFLATE) +=3D zlib_inflate=0A=
subdir-$(CONFIG_ZLIB_DEFLATE) +=3D zlib_deflate=0A=
=0A=
+include $(TOPDIR)/drivers/net/Makefile.lib=0A=
+include $(TOPDIR)/drivers/usb/Makefile.lib=0A=
+include $(TOPDIR)/fs/Makefile.lib=0A=
+include $(TOPDIR)/net/bluetooth/bnep/Makefile.lib=0A=
+=0A=
include $(TOPDIR)/drivers/bluetooth/Makefile.lib=0A=
=0A=
# Include the subdirs, if necessary.=0A=
@@ -36,3 +43,11 @@ ifeq ($(CONFIG_TCP_RFC2385),y)=0A=
endif=0A=
=0A=
include $(TOPDIR)/Rules.make=0A=
+=0A=
+crc32.o: crc32table.h=0A=
+=0A=
+gen_crc32table: gen_crc32table.c=0A=
+ $(HOSTCC) $(HOSTCCFLAGS) -o $@ $<=0A=
+=0A=
+crc32table.h: gen_crc32table=0A=
+ ./$< > $@=0A=
diff -Naurp linux-10/net/bluetooth/bnep/bnep.h =
linux-20/net/bluetooth/bnep/bnep.h=0A=
--- linux-10/net/bluetooth/bnep/bnep.h 2004-10-16 12:50:59.000000000 =
-0400=0A=
+++ linux-20/net/bluetooth/bnep/bnep.h 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -26,7 +26,7 @@=0A=
#include <linux/types.h>=0A=
#include <net/bluetooth/bluetooth.h>=0A=
=0A=
-#include "crc32.h"=0A=
+#include <linux/crc32.h>=0A=
=0A=
// Limits=0A=
#define BNEP_MAX_PROTO_FILTERS 5=0A=
@@ -179,7 +179,7 @@ int bnep_sock_cleanup(void);=0A=
=0A=
static inline int bnep_mc_hash(__u8 *addr)=0A=
{=0A=
- return (bnep_crc32(~0, addr, ETH_ALEN) >> 26);=0A=
+ return (crc32_be(~0, addr, ETH_ALEN) >> 26);=0A=
}=0A=
=0A=
#endif=0A=
diff -Naurp linux-10/net/bluetooth/bnep/core.c =
linux-20/net/bluetooth/bnep/core.c=0A=
--- linux-10/net/bluetooth/bnep/core.c 2004-10-16 12:50:59.000000000 =
-0400=0A=
+++ linux-20/net/bluetooth/bnep/core.c 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -692,7 +692,6 @@ static int __init bnep_init_module(void)=0A=
{=0A=
l2cap_load();=0A=
=0A=
- bnep_crc32_init();=0A=
bnep_sock_init();=0A=
=0A=
BT_INFO("BlueZ BNEP ver %s", VERSION);=0A=
@@ -707,7 +706,6 @@ static int __init bnep_init_module(void)=0A=
static void __exit bnep_cleanup_module(void)=0A=
{=0A=
bnep_sock_cleanup();=0A=
- bnep_crc32_cleanup();=0A=
}=0A=
=0A=
module_init(bnep_init_module);=0A=
diff -Naurp linux-10/net/bluetooth/bnep/crc32.c =
linux-20/net/bluetooth/bnep/crc32.c=0A=
--- linux-10/net/bluetooth/bnep/crc32.c 2002-11-28 18:53:15.000000000 =
-0500=0A=
+++ linux-20/net/bluetooth/bnep/crc32.c 1969-12-31 19:00:00.000000000 =
-0500=0A=
@@ -1,59 +0,0 @@=0A=
-/* =0A=
- * Based on linux-2.5/lib/crc32 by Matt Domsch =
<[email protected]>=0A=
- *=0A=
- * FIXME: Remove in 2.5 =0A=
- */=0A=
-=0A=
-#include <linux/kernel.h>=0A=
-#include <linux/module.h>=0A=
-#include <linux/types.h>=0A=
-#include <linux/slab.h>=0A=
-#include <linux/init.h>=0A=
-#include <asm/atomic.h>=0A=
-=0A=
-#include "crc32.h"=0A=
-=0A=
-#define CRCPOLY_BE 0x04c11db7=0A=
-#define CRC_BE_BITS 8=0A=
-=0A=
-static u32 *bnep_crc32_table;=0A=
-=0A=
-/*=0A=
- * This code is in the public domain; copyright abandoned.=0A=
- * Liability for non-performance of this code is limited to the =
amount=0A=
- * you paid for it. Since it is distributed for free, your refund =
will=0A=
- * be very very small. If it breaks, you get to keep both pieces.=0A=
- */=0A=
-u32 bnep_crc32(u32 crc, unsigned char const *p, size_t len)=0A=
-{=0A=
- while (len--)=0A=
- crc =3D (crc << 8) ^ bnep_crc32_table[(crc >> 24) ^ *p++];=0A=
- =0A=
- return crc;=0A=
-}=0A=
-=0A=
-int __init bnep_crc32_init(void)=0A=
-{=0A=
- unsigned i, j;=0A=
- u32 crc =3D 0x80000000;=0A=
-=0A=
- bnep_crc32_table =3D kmalloc((1 << CRC_BE_BITS) * sizeof(u32), =
GFP_KERNEL);=0A=
- if (!bnep_crc32_table)=0A=
- return -ENOMEM;=0A=
-=0A=
- bnep_crc32_table[0] =3D 0;=0A=
-=0A=
- for (i =3D 1; i < 1 << CRC_BE_BITS; i <<=3D 1) {=0A=
- crc =3D (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);=0A=
- for (j =3D 0; j < i; j++)=0A=
- bnep_crc32_table[i + j] =3D crc ^ bnep_crc32_table[j];=0A=
- }=0A=
- return 0;=0A=
-}=0A=
-=0A=
-void __exit bnep_crc32_cleanup(void)=0A=
-{=0A=
- if (bnep_crc32_table)=0A=
- kfree(bnep_crc32_table);=0A=
- bnep_crc32_table =3D NULL;=0A=
-}=0A=
diff -Naurp linux-10/net/bluetooth/bnep/crc32.h =
linux-20/net/bluetooth/bnep/crc32.h=0A=
--- linux-10/net/bluetooth/bnep/crc32.h 2002-11-28 18:53:15.000000000 =
-0500=0A=
+++ linux-20/net/bluetooth/bnep/crc32.h 1969-12-31 19:00:00.000000000 =
-0500=0A=
@@ -1,10 +0,0 @@=0A=
-/*=0A=
- * crc32.h=0A=
- * See crc32.c for license and changes=0A=
- *=0A=
- * FIXME: Remove in 2.5=0A=
- */=0A=
-=0A=
-int bnep_crc32_init(void);=0A=
-void bnep_crc32_cleanup(void);=0A=
-u32 bnep_crc32(u32 crc, unsigned char const *p, size_t len);=0A=
diff -Naurp linux-10/net/bluetooth/bnep/Makefile =
linux-20/net/bluetooth/bnep/Makefile=0A=
--- linux-10/net/bluetooth/bnep/Makefile 2004-10-16 12:50:59.000000000 =
-0400=0A=
+++ linux-20/net/bluetooth/bnep/Makefile 2004-10-16 13:00:34.000000000 =
-0400=0A=
@@ -4,7 +4,7 @@=0A=
=0A=
O_TARGET :=3D bnep.o=0A=
=0A=
-obj-y :=3D core.o sock.o netdev.o crc32.o=0A=
+obj-y :=3D core.o sock.o netdev.o=0A=
obj-m +=3D $(O_TARGET)=0A=
=0A=
include $(TOPDIR)/Rules.make=0A=
diff -Naurp linux-10/net/bluetooth/bnep/Makefile.lib =
linux-20/net/bluetooth/bnep/Makefile.lib=0A=
--- linux-10/net/bluetooth/bnep/Makefile.lib 1969-12-31 =
19:00:00.000000000 -0500=0A=
+++ linux-20/net/bluetooth/bnep/Makefile.lib 2004-10-16 =
13:00:34.000000000 -0400=0A=
@@ -0,0 +1 @@=0A=
+obj-$(CONFIG_BLUEZ_BNEP) +=3D crc32.o=0A=
------_=_NextPart_000_01C4BB8B.2347E8E0--
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
WOLK - Working Overloaded Linux Kernel
[email protected]
https://lists.sourceforge.net/lists/listinfo/wolk-devel