[PATCH] Use kernel crc32 for BlueZ BNEP

From: Marcel Holtmann (marcel@holtmann.org)
Date: Sun Oct 06 2002 - 06:30:45 EST


You can import this changeset into BK by piping this whole message to:
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================

ChangeSet@1.755, 2002-10-06 13:06:09+02:00, marcel@holtmann.org
  Use kernel crc32 for BlueZ BNEP

 b/lib/Makefile | 1
 b/net/bluetooth/bnep/Makefile | 2 -
 b/net/bluetooth/bnep/Makefile.lib | 1
 b/net/bluetooth/bnep/bnep.h | 5 +--
 b/net/bluetooth/bnep/core.c | 4 --
 net/bluetooth/bnep/crc32.c | 59 --------------------------------------
 net/bluetooth/bnep/crc32.h | 10 ------
 7 files changed, 5 insertions(+), 77 deletions(-)

diff -Nru a/lib/Makefile b/lib/Makefile
--- a/lib/Makefile Sun Oct 6 13:11:11 2002
+++ b/lib/Makefile Sun Oct 6 13:11:11 2002
@@ -29,5 +29,6 @@
 include $(TOPDIR)/drivers/net/Makefile.lib
 include $(TOPDIR)/drivers/usb/class/Makefile.lib
 include $(TOPDIR)/fs/Makefile.lib
+include $(TOPDIR)/net/bluetooth/bnep/Makefile.lib
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/bluetooth/bnep/Makefile b/net/bluetooth/bnep/Makefile
--- a/net/bluetooth/bnep/Makefile Sun Oct 6 13:11:11 2002
+++ b/net/bluetooth/bnep/Makefile Sun Oct 6 13:11:11 2002
@@ -4,7 +4,7 @@
 
 O_TARGET := bnep.o
 
-obj-y := core.o sock.o netdev.o crc32.o
+obj-y := core.o sock.o netdev.o
 obj-m += $(O_TARGET)
 
 include $(TOPDIR)/Rules.make
diff -Nru a/net/bluetooth/bnep/Makefile.lib b/net/bluetooth/bnep/Makefile.lib
--- /dev/null Wed Dec 31 16:00:00 1969
+++ b/net/bluetooth/bnep/Makefile.lib Sun Oct 6 13:11:11 2002
@@ -0,0 +1 @@
+obj-$(CONFIG_BLUEZ_BNEP) += crc32.o
diff -Nru a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
--- a/net/bluetooth/bnep/bnep.h Sun Oct 6 13:11:11 2002
+++ b/net/bluetooth/bnep/bnep.h Sun Oct 6 13:11:11 2002
@@ -24,10 +24,9 @@
 #define _BNEP_H
 
 #include <linux/types.h>
+#include <linux/crc32.h>
 #include <net/bluetooth/bluetooth.h>
 
-#include "crc32.h"
-
 // Limits
 #define BNEP_MAX_PROTO_FILTERS 5
 #define BNEP_MAX_MULTICAST_FILTERS 20
@@ -179,7 +178,7 @@
 
 static inline int bnep_mc_hash(__u8 *addr)
 {
- return (bnep_crc32(~0, addr, ETH_ALEN) >> 26);
+ return (crc32_be(~0, addr, ETH_ALEN) >> 26);
 }
 
 #endif
diff -Nru a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
--- a/net/bluetooth/bnep/core.c Sun Oct 6 13:11:11 2002
+++ b/net/bluetooth/bnep/core.c Sun Oct 6 13:11:11 2002
@@ -685,16 +685,12 @@
 
         bnep_sock_init();
 
- bnep_crc32_init();
-
         return 0;
 }
 
 static void __exit bnep_cleanup_module(void)
 {
         bnep_sock_cleanup();
-
- bnep_crc32_cleanup();
 }
 
 module_init(bnep_init_module);
diff -Nru a/net/bluetooth/bnep/crc32.c b/net/bluetooth/bnep/crc32.c
--- a/net/bluetooth/bnep/crc32.c Sun Oct 6 13:11:11 2002
+++ /dev/null Wed Dec 31 16:00:00 1969
@@ -1,59 +0,0 @@
-/*
- * Based on linux-2.5/lib/crc32 by Matt Domsch <Matt_Domsch@dell.com>
- *
- * FIXME: Remove in 2.5
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/init.h>
-#include <asm/atomic.h>
-
-#include "crc32.h"
-
-#define CRCPOLY_BE 0x04c11db7
-#define CRC_BE_BITS 8
-
-static u32 *bnep_crc32_table;
-
-/*
- * This code is in the public domain; copyright abandoned.
- * Liability for non-performance of this code is limited to the amount
- * you paid for it. Since it is distributed for free, your refund will
- * be very very small. If it breaks, you get to keep both pieces.
- */
-u32 bnep_crc32(u32 crc, unsigned char const *p, size_t len)
-{
- while (len--)
- crc = (crc << 8) ^ bnep_crc32_table[(crc >> 24) ^ *p++];
-
- return crc;
-}
-
-int __init bnep_crc32_init(void)
-{
- unsigned i, j;
- u32 crc = 0x80000000;
-
- bnep_crc32_table = kmalloc((1 << CRC_BE_BITS) * sizeof(u32), GFP_KERNEL);
- if (!bnep_crc32_table)
- return -ENOMEM;
-
- bnep_crc32_table[0] = 0;
-
- for (i = 1; i < 1 << CRC_BE_BITS; i <<= 1) {
- crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
- for (j = 0; j < i; j++)
- bnep_crc32_table[i + j] = crc ^ bnep_crc32_table[j];
- }
- return 0;
-}
-
-void __exit bnep_crc32_cleanup(void)
-{
- if (bnep_crc32_table)
- kfree(bnep_crc32_table);
- bnep_crc32_table = NULL;
-}
diff -Nru a/net/bluetooth/bnep/crc32.h b/net/bluetooth/bnep/crc32.h
--- a/net/bluetooth/bnep/crc32.h Sun Oct 6 13:11:11 2002
+++ /dev/null Wed Dec 31 16:00:00 1969
@@ -1,10 +0,0 @@
-/*
- * crc32.h
- * See crc32.c for license and changes
- *
- * FIXME: Remove in 2.5
- */
-
-int bnep_crc32_init(void);
-void bnep_crc32_cleanup(void);
-u32 bnep_crc32(u32 crc, unsigned char const *p, size_t len);

===================================================================

This BitKeeper patch contains the following changesets:
+
## Wrapped with gzip_uu ##

begin 664 bkpatch12876
M'XL(`%`:H#T``]6874_;2!2&KS._8B1Z`:*QY]L?NT$4`BTJ"X@MJU5OD#T>
MDQ#'1HY#:67QVW=LDRPD`=MA$=J`,#'FS9GW.3[GC#?@Q42E;F?LI5)%8`-^
M22:9VQDD43;VXMA(TBM]\CQ)]$ESD(R5.?N3Z0^SD5(W*C7]:*I^=8G!@;[V
MS,OD`-ZJ=.)VL$'G9[*?-\KMG!]\OCC^=`Y`KP?W!UY\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NG3)L98WU%/6%P"XM5*<-=
MC&HZ-GN_E,%$ITPU'=6G3+7R=0J%L.TB*80C]*$`VW+3U1QWF^W@*R1)K@4=
M\A3X.XYH!?!^Z>3*J?5A#<544&Y7%UBWI+'.W%7'?'GKVI)YPTWU*R2+32NQ
MT/^+^:"8M,M-?QOFRS369/[X$4#]\[3VSQV`-[H9[P;#*Y4\H^!H]SC7$/7>
ME-H5/<R>UFCB4OH.<WJS&EVT<]W6R^<E"PP?KW:=3DZQ;LZS1OYA\]OI6?_H
??*MV[S9_>"H'2HXFTW%/.A9FNI&#?P#S4[-0N14`````
`
end
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Oct 07 2002 - 22:00:53 EST