rt{2860,2870,3070}sta: Use existing CCITT CRC implementation on firmware rather than adding an equivalent variant of ITU-T CRC

svn path=/dists/trunk/linux-2.6/; revision=14180
This commit is contained in:
Ben Hutchings 2009-08-23 21:27:45 +00:00
parent bcedb02859
commit 35c59f81d8
4 changed files with 9 additions and 90 deletions

2
debian/changelog vendored
View File

@ -64,6 +64,8 @@ linux-2.6 (2.6.31~rc7-1~experimental.1) UNRELEASED; urgency=low
* qla1280: Release spinlock when requesting firmware (closes: #543244)
* r128: Add test for initialisation to all ioctls that require it
(closes: #541630)
* rt{2860,2870,3070}sta: Use existing CCITT CRC implementation on
firmware rather than adding an equivalent variant of ITU-T CRC
[ Martin Michlmayr ]
* [armel/orion5x, armel/kirkwood] Set GPIO_SYSFS=y since these

View File

@ -20,7 +20,7 @@ index 9fb130d..d75a87a 100644
tristate "Ralink 2860 wireless support"
- depends on BROKEN
depends on PCI && X86 && WLAN_80211
+ select CRC_ITU_T
+ select CRC_CCITT
+ select FW_LOADER
---help---
This is an experimental driver for the Ralink 2860 wireless chip.
@ -45,7 +45,7 @@ index 004f530..f34011c 100644
-#include "../../rt3070/firmware.h"
-#endif
+#include <linux/firmware.h>
+#include <linux/crc-itu-t.h>
+#include <linux/crc-ccitt.h>
UCHAR BIT8[] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
ULONG BIT32[] = {0x00000001, 0x00000002, 0x00000004, 0x00000008,
@ -135,7 +135,7 @@ index 004f530..f34011c 100644
#endif
@@ -3314,45 +3255,67 @@ NDIS_STATUS NICLoadFirmware(
@@ -3314,45 +3255,65 @@ NDIS_STATUS NICLoadFirmware(
IN PRTMP_ADAPTER pAd)
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
@ -217,10 +217,8 @@ index 004f530..f34011c 100644
+ }
+
+ /* is the internal CRC correct? */
+ if (crc_itu_t_bitreversed(0xffff, fw->data, fw->size - 2) !=
+ (bitrev8(fw->data[fw->size - 2]) << 8 |
+ bitrev8(fw->data[fw->size - 1]))) {
+ /* CRC fail */
+ if (crc_ccitt(0xffff, fw->data, fw->size - 2) !=
+ (fw->data[fw->size - 2] | (fw->data[fw->size - 1] << 8))) {
+ dev_err(dev, "firmware file %s failed internal CRC\n", name);
+ goto fail;
+ }
@ -256,7 +254,7 @@ index cd4f0b6..59d533d 100644
tristate "Ralink 2870 wireless support"
- depends on BROKEN
depends on USB && X86 && WLAN_80211
+ select CRC_ITU_T
+ select CRC_CCITT
+ select FW_LOADER
---help---
This is an experimental driver for the Ralink 2870 wireless chip.
@ -270,7 +268,7 @@ index e414305..7242d5e 100644
tristate "Ralink 3070 wireless support"
- depends on BROKEN
depends on USB && X86 && WLAN_80211
+ select CRC_ITU_T
+ select CRC_CCITT
+ select FW_LOADER
---help---
This is an experimental driver for the Ralink 3070 wireless chip.

View File

@ -1,79 +0,0 @@
From c450dd0d27ff5cd7b83084e381e0cc808db2554e Mon Sep 17 00:00:00 2001
From: Darren Salt <linux@youmustbejoking.demon.co.uk>
Date: Sat, 11 Apr 2009 15:40:04 +0100
Subject: [PATCH] crc-itu-t: add bit-reversed calculation
Signed-off-by: Darren Salt <linux@youmustbejoking.demon.co.uk>
---
include/linux/crc-itu-t.h | 10 ++++++++++
lib/crc-itu-t.c | 18 ++++++++++++++++++
2 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/include/linux/crc-itu-t.h b/include/linux/crc-itu-t.h
index 84920f3..7b2b7ba 100644
--- a/include/linux/crc-itu-t.h
+++ b/include/linux/crc-itu-t.h
@@ -6,6 +6,9 @@
* Poly 0x0x1021 (x^16 + x^12 + x^15 + 1)
* Init 0
*
+ * The bit-reversed buffer variants may be non-standard, but some firmware
+ * loaders require them.
+ *
* This source code is licensed under the GNU General Public License,
* Version 2. See the file COPYING for more details.
*/
@@ -14,15 +17,22 @@
#define CRC_ITU_T_H
#include <linux/types.h>
+#include <linux/bitrev.h>
extern u16 const crc_itu_t_table[256];
extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len);
+extern u16 crc_itu_t_bitreversed(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];
}
+static inline u16 crc_itu_t_bitreversed_byte(u16 crc, const u8 data)
+{
+ return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ bitrev8(data)) & 0xff];
+}
+
#endif /* CRC_ITU_T_H */
diff --git a/lib/crc-itu-t.c b/lib/crc-itu-t.c
index a63472b..886981e 100644
--- a/lib/crc-itu-t.c
+++ b/lib/crc-itu-t.c
@@ -64,6 +64,23 @@ u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len)
}
EXPORT_SYMBOL(crc_itu_t);
+/**
+ * crc_itu_t_bitreversed - Compute the CRC-ITU-T for a bit-reversed data buffer
+ *
+ * @crc: previous CRC value
+ * @buffer: data pointer
+ * @len: number of bytes in the buffer
+ *
+ * Returns the updated CRC value
+ */
+u16 crc_itu_t_bitreversed(u16 crc, const u8 *buffer, size_t len)
+{
+ while (len--)
+ crc = crc_itu_t_bitreversed_byte(crc, *buffer++);
+ return crc;
+}
+EXPORT_SYMBOL(crc_itu_t_bitreversed);
+
MODULE_DESCRIPTION("CRC ITU-T V.41 calculations");
MODULE_LICENSE("GPL");
--
1.5.6.5

View File

@ -12,8 +12,6 @@
# Enable this for next rc
#+ features/all/drivers-infiniband-hw-ipath-iba7220-use-request_firmware.patch
+ features/all/drivers-net-cxgb3-request_firmware.patch
# rt2860sta and rt2870sta need ITU-T CRC on bit-reversed data
+ features/all/lib-crcitut-bit-reversed.patch
+ features/all/drivers-staging-rt28x0sta-request_firmware.patch
+ features/all/export-unionfs-symbols.patch
+ features/all/sound-pci-cs46xx-request_firmware.patch