Commit a1bed4d5 authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

Merge

parents b8ba2a4d e05f7d70
......@@ -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
......@@ -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
obj-$(CONFIG_BT_BNEP) += crc32.o
......@@ -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
......@@ -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);
......
/*
* 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;
}
/*
* 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);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment