Skip to contentSkip to conversation

rt2x00: Move CRC into seperate module

PATCH In review Ivo van Doorn 1 participant 1 message Dec 3, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 26/26 rt2x00: Move CRC into seperate module

Move the crc handling of rt61pci and rt73usb into a seperate module. This will create the crc-itu-t module inside the rt2x00 folder.

Signed-off-by Ivo van Doorn <[email protected]>

---

drivers/net/wireless/d80211/rt2x00/Kconfig +10 -0
diff -rNU3 wireless-dev-base/drivers/net/wireless/d80211/rt2x00/Kconfig wireless-dev-crc/drivers/net/wireless/d80211/rt2x00/Kconfig
@@ -40,6 +40,7 @@
 config RT61PCI
 	tristate "Ralink rt61 pci/pcmcia support"
 	depends on RT2X00 && FW_LOADER && PCI
+	select CRC_ITU_T
 	select EEPROM_93CX6
 	---help---
 	This is an experimental driver for the Ralink rt61 wireless chip.
@@ -69,6 +70,7 @@
 config RT73USB
 	tristate "Ralink rt73 usb support"
 	depends on RT2X00 && FW_LOADER && USB
+	select CRC_ITU_T
 	---help---
 	This is an experimental driver for the Ralink rt73 wireless chip.
 
@@ -88,3 +90,11 @@
 	These chipsets are found inside the Ralink wireless cards.
 
 	When compiled as a module, this driver will be called "eeprom_93c6.ko".
+
+config CRC_ITU_T
+	tristate "CRC ITU-T V.41 functions"
+	help
+	  This option is provided for the case where no in-kernel-tree
+	  modules require CRC ITU-T V.41 functions, but a module built outside
+	  the kernel tree does. Such modules that use library CRC ITU-T V.41
+	  functions require M here.
drivers/net/wireless/d80211/rt2x00/Makefile +1 -0
diff -rNU3 wireless-dev-base/drivers/net/wireless/d80211/rt2x00/Makefile wireless-dev-crc/drivers/net/wireless/d80211/rt2x00/Makefile
@@ -3,4 +3,5 @@
 obj-$(CONFIG_RT61PCI)		+= rt61pci.o
 obj-$(CONFIG_RT2500USB)		+= rt2500usb.o
 obj-$(CONFIG_RT73USB)		+= rt73usb.o
+obj-$(CONFIG_CRC_ITU_T)		+= crc-itu-t.o
 obj-$(CONFIG_EEPROM_93CX6)	+= eeprom_93cx6.o
drivers/net/wireless/d80211/rt2x00/crc-itu-t.c +66 -0

66 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/crc-itu-t.h +27 -0
diff -rNU3 wireless-dev-base/drivers/net/wireless/d80211/rt2x00/crc-itu-t.h wireless-dev-crc/drivers/net/wireless/d80211/rt2x00/crc-itu-t.h
@@ -0,0 +1,27 @@
+/*
+ *	crc-itu-t.h - CRC ITU-T V.41 routine
+ *
+ * Implements the standard CRC ITU-T V.41:
+ *   Width 16
+ *   Poly  0x1021 (x^16 + x^12 + x^15 + 1)
+ *   Init  0
+ *
+ * This source code is licensed under the GNU General Public License,
+ * Version 2. See the file COPYING for more details.
+ */
+
+#ifndef CRC_ITU_T_H
+#define CRC_ITU_T_H
+
+#include <linux/types.h>
+
+extern u16 const crc_itu_t_table[256];
+
+extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len);
+
+static inline u16 crc_itu_t_byte(u16 crc, const u8 data)
+{
+	return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ data) & 0xff];
+}
+
+#endif /* CRC_ITU_T_H */
drivers/net/wireless/d80211/rt2x00/rt2x00crc.h +0 -82

82 lines not on this page · raw message

drivers/net/wireless/d80211/rt2x00/rt61pci.c +3 -2
diff -rNU3 wireless-dev-base/drivers/net/wireless/d80211/rt2x00/rt61pci.c wireless-dev-crc/drivers/net/wireless/d80211/rt2x00/rt61pci.c
@@ -55,6 +55,7 @@
 #include "rt2x00pci.h"
 #include "rt2x00crc.h"
 #include "rt61pci.h"
+#include "crc-itu-t.h"
 #include "eeprom_93cx6.h"
 
 /*
@@ -1182,8 +1183,8 @@
 	 * and set those 2 bytes to 0 when calculating CRC.
 	 */
 	reg = 0;
-	crc = rt2x00crc(0, fw->data, fw->size - 2);
-	crc = rt2x00crc(crc, (u8*)&reg, 2);
+	crc = crc_itu_t(0, fw->data, fw->size - 2);
+	crc = crc_itu_t(crc, (u8*)&reg, 2);
 
 	if (crc != (fw->data[fw->size - 2] << 8 | fw->data[fw->size - 1])) {
 		ERROR("Firmware CRC error.\n");
drivers/net/wireless/d80211/rt2x00/rt73usb.c +3 -2
diff -rNU3 wireless-dev-base/drivers/net/wireless/d80211/rt2x00/rt73usb.c wireless-dev-crc/drivers/net/wireless/d80211/rt2x00/rt73usb.c
@@ -52,6 +52,7 @@
 #include "rt2x00usb.h"
 #include "rt2x00crc.h"
 #include "rt73usb.h"
+#include "crc-itu-t.h"
 
 /*
  * Register access.
@@ -1081,8 +1082,8 @@
 	 * and set those 2 bytes to 0 when calculating CRC.
 	 */
 	reg = 0;
-	crc = rt2x00crc(0, fw->data, fw->size - 2);
-	crc = rt2x00crc(crc, (u8*)&reg, 2);
+	crc = crc_itu_t(0, fw->data, fw->size - 2);
+	crc = crc_itu_t(crc, (u8*)&reg, 2);
 
 	if (crc != (fw->data[fw->size - 2] << 8 | fw->data[fw->size - 1])) {
 		ERROR("Firmware CRC error.\n");