summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2002-10-17 16:21:34 +0200
committerMarcel Holtmann <marcel@holtmann.org>2002-10-17 16:21:34 +0200
commite05f7d70dd5691900fe4075e107573cae58bcf02 (patch)
treed4cb9c3564e981ff5dd1658c4437b74ec56701a9
parent9beb225e0f1616a6cea6b0086a9ff94a09965c6c (diff)
Use kernel crc32 for BlueZ BNEP
This patch modifies the BlueZ BNEP layer to use the CRC32 code from the lib/ directory.
-rw-r--r--lib/Makefile1
-rw-r--r--net/bluetooth/bnep/Makefile2
-rw-r--r--net/bluetooth/bnep/Makefile.lib1
-rw-r--r--net/bluetooth/bnep/bnep.h5
-rw-r--r--net/bluetooth/bnep/core.c4
-rw-r--r--net/bluetooth/bnep/crc32.c59
-rw-r--r--net/bluetooth/bnep/crc32.h10
7 files changed, 5 insertions, 77 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 6589280083dd..9bbb27efb10a 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -29,5 +29,6 @@ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
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 --git a/net/bluetooth/bnep/Makefile b/net/bluetooth/bnep/Makefile
index f424217b0d1e..d05c5e3c5c71 100644
--- a/net/bluetooth/bnep/Makefile
+++ b/net/bluetooth/bnep/Makefile
@@ -4,6 +4,6 @@
obj-$(CONFIG_BT_BNEP) += bnep.o
-bnep-objs := core.o sock.o netdev.o crc32.o
+bnep-objs := core.o sock.o netdev.o
include $(TOPDIR)/Rules.make
diff --git a/net/bluetooth/bnep/Makefile.lib b/net/bluetooth/bnep/Makefile.lib
new file mode 100644
index 000000000000..e184a5799819
--- /dev/null
+++ b/net/bluetooth/bnep/Makefile.lib
@@ -0,0 +1 @@
+obj-$(CONFIG_BT_BNEP) += crc32.o
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index 1394ff3db0b1..22f6bad82e49 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -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 @@ int bnep_sock_cleanup(void);
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 --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index fb9fae8c9710..759d6c3b98fc 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -712,16 +712,12 @@ static int __init bnep_init_module(void)
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 --git a/net/bluetooth/bnep/crc32.c b/net/bluetooth/bnep/crc32.c
deleted file mode 100644
index 897d8dd30c4e..000000000000
--- a/net/bluetooth/bnep/crc32.c
+++ /dev/null
@@ -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 --git a/net/bluetooth/bnep/crc32.h b/net/bluetooth/bnep/crc32.h
deleted file mode 100644
index d979b4581305..000000000000
--- a/net/bluetooth/bnep/crc32.h
+++ /dev/null
@@ -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);