aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig4
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h3
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00firmware.c34
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c28
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c28
5 files changed, 50 insertions, 47 deletions
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index d5240aa06233..4709c11da419 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -27,8 +27,6 @@ config RT2X00_LIB_USB
27config RT2X00_LIB_FIRMWARE 27config RT2X00_LIB_FIRMWARE
28 boolean 28 boolean
29 depends on RT2X00_LIB 29 depends on RT2X00_LIB
30 select CRC_CCITT
31 select CRC_ITU_T
32 select FW_LOADER 30 select FW_LOADER
33 31
34config RT2X00_LIB_RFKILL 32config RT2X00_LIB_RFKILL
@@ -102,6 +100,7 @@ config RT61PCI
102 depends on PCI 100 depends on PCI
103 select RT2X00_LIB_PCI 101 select RT2X00_LIB_PCI
104 select RT2X00_LIB_FIRMWARE 102 select RT2X00_LIB_FIRMWARE
103 select CRC_ITU_T
105 select EEPROM_93CX6 104 select EEPROM_93CX6
106 ---help--- 105 ---help---
107 This is an experimental driver for the Ralink rt61 wireless chip. 106 This is an experimental driver for the Ralink rt61 wireless chip.
@@ -145,6 +144,7 @@ config RT73USB
145 depends on USB 144 depends on USB
146 select RT2X00_LIB_USB 145 select RT2X00_LIB_USB
147 select RT2X00_LIB_FIRMWARE 146 select RT2X00_LIB_FIRMWARE
147 select CRC_ITU_T
148 ---help--- 148 ---help---
149 This is an experimental driver for the Ralink rt73 wireless chip. 149 This is an experimental driver for the Ralink rt73 wireless chip.
150 150
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index fd65fccbdae7..8718ad3dcc00 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -495,6 +495,7 @@ struct rt2x00lib_ops {
495 */ 495 */
496 int (*probe_hw) (struct rt2x00_dev *rt2x00dev); 496 int (*probe_hw) (struct rt2x00_dev *rt2x00dev);
497 char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev); 497 char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev);
498 u16 (*get_firmware_crc) (void *data, const size_t len);
498 int (*load_firmware) (struct rt2x00_dev *rt2x00dev, void *data, 499 int (*load_firmware) (struct rt2x00_dev *rt2x00dev, void *data,
499 const size_t len); 500 const size_t len);
500 501
@@ -613,8 +614,6 @@ enum rt2x00_flags {
613 */ 614 */
614 DRIVER_SUPPORT_MIXED_INTERFACES, 615 DRIVER_SUPPORT_MIXED_INTERFACES,
615 DRIVER_REQUIRE_FIRMWARE, 616 DRIVER_REQUIRE_FIRMWARE,
616 DRIVER_REQUIRE_FIRMWARE_CRC_ITU_T,
617 DRIVER_REQUIRE_FIRMWARE_CCITT,
618 DRIVER_REQUIRE_BEACON_GUARD, 617 DRIVER_REQUIRE_BEACON_GUARD,
619 DRIVER_REQUIRE_ATIM_QUEUE, 618 DRIVER_REQUIRE_ATIM_QUEUE,
620 619
diff --git a/drivers/net/wireless/rt2x00/rt2x00firmware.c b/drivers/net/wireless/rt2x00/rt2x00firmware.c
index 4f9fe56f4f2e..b971bc6e7ee2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00firmware.c
+++ b/drivers/net/wireless/rt2x00/rt2x00firmware.c
@@ -23,8 +23,6 @@
23 Abstract: rt2x00 firmware loading routines. 23 Abstract: rt2x00 firmware loading routines.
24 */ 24 */
25 25
26#include <linux/crc-ccitt.h>
27#include <linux/crc-itu-t.h>
28#include <linux/kernel.h> 26#include <linux/kernel.h>
29#include <linux/module.h> 27#include <linux/module.h>
30 28
@@ -63,36 +61,7 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
63 return -ENOENT; 61 return -ENOENT;
64 } 62 }
65 63
66 /* 64 crc = rt2x00dev->ops->lib->get_firmware_crc(fw->data, fw->size);
67 * Perform crc validation on the firmware.
68 * The last 2 bytes in the firmware array are the crc checksum itself,
69 * this means that we should never pass those 2 bytes to the crc
70 * algorithm.
71 */
72 if (test_bit(DRIVER_REQUIRE_FIRMWARE_CRC_ITU_T, &rt2x00dev->flags)) {
73 /*
74 * Use the crc itu-t algorithm.
75 * Use 0 for the last 2 bytes to complete the checksum.
76 */
77 crc = crc_itu_t(0, fw->data, fw->size - 2);
78 crc = crc_itu_t_byte(crc, 0);
79 crc = crc_itu_t_byte(crc, 0);
80 } else if (test_bit(DRIVER_REQUIRE_FIRMWARE_CCITT, &rt2x00dev->flags)) {
81 /*
82 * Use the crc ccitt algorithm.
83 * This will return the same value as the legacy driver which
84 * used bit ordering reversion on the both the firmware bytes
85 * before input input as well as on the final output.
86 * Obviously using crc ccitt directly is much more efficient.
87 */
88 crc = crc_ccitt(~0, fw->data, fw->size - 2);
89 } else {
90 ERROR(rt2x00dev, "No checksum algorithm selected "
91 "for firmware validation.\n");
92 retval = -ENOENT;
93 goto exit;
94 }
95
96 if (crc != (fw->data[fw->size - 2] << 8 | fw->data[fw->size - 1])) { 65 if (crc != (fw->data[fw->size - 2] << 8 | fw->data[fw->size - 1])) {
97 ERROR(rt2x00dev, "Firmware checksum error.\n"); 66 ERROR(rt2x00dev, "Firmware checksum error.\n");
98 retval = -ENOENT; 67 retval = -ENOENT;
@@ -139,4 +108,3 @@ void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)
139 release_firmware(rt2x00dev->fw); 108 release_firmware(rt2x00dev->fw);
140 rt2x00dev->fw = NULL; 109 rt2x00dev->fw = NULL;
141} 110}
142
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 13b918db1850..23b3e163b9ba 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -24,6 +24,7 @@
24 Supported chipsets: RT2561, RT2561s, RT2661. 24 Supported chipsets: RT2561, RT2561s, RT2661.
25 */ 25 */
26 26
27#include <linux/crc-itu-t.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
29#include <linux/init.h> 30#include <linux/init.h>
@@ -856,7 +857,7 @@ dynamic_cca_tune:
856} 857}
857 858
858/* 859/*
859 * Firmware name function. 860 * Firmware functions
860 */ 861 */
861static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev) 862static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
862{ 863{
@@ -880,9 +881,23 @@ static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
880 return fw_name; 881 return fw_name;
881} 882}
882 883
883/* 884static u16 rt61pci_get_firmware_crc(void *data, const size_t len)
884 * Initialization functions. 885{
885 */ 886 u16 crc;
887
888 /*
889 * Use the crc itu-t algorithm.
890 * The last 2 bytes in the firmware array are the crc checksum itself,
891 * this means that we should never pass those 2 bytes to the crc
892 * algorithm.
893 */
894 crc = crc_itu_t(0, data, len - 2);
895 crc = crc_itu_t_byte(crc, 0);
896 crc = crc_itu_t_byte(crc, 0);
897
898 return crc;
899}
900
886static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev, void *data, 901static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
887 const size_t len) 902 const size_t len)
888{ 903{
@@ -963,6 +978,9 @@ static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
963 return 0; 978 return 0;
964} 979}
965 980
981/*
982 * Initialization functions.
983 */
966static void rt61pci_init_rxentry(struct rt2x00_dev *rt2x00dev, 984static void rt61pci_init_rxentry(struct rt2x00_dev *rt2x00dev,
967 struct queue_entry *entry) 985 struct queue_entry *entry)
968{ 986{
@@ -2257,7 +2275,6 @@ static int rt61pci_probe_hw(struct rt2x00_dev *rt2x00dev)
2257 * This device requires firmware. 2275 * This device requires firmware.
2258 */ 2276 */
2259 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags); 2277 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
2260 __set_bit(DRIVER_REQUIRE_FIRMWARE_CRC_ITU_T, &rt2x00dev->flags);
2261 2278
2262 /* 2279 /*
2263 * Set the rssi offset. 2280 * Set the rssi offset.
@@ -2457,6 +2474,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2457 .irq_handler = rt61pci_interrupt, 2474 .irq_handler = rt61pci_interrupt,
2458 .probe_hw = rt61pci_probe_hw, 2475 .probe_hw = rt61pci_probe_hw,
2459 .get_firmware_name = rt61pci_get_firmware_name, 2476 .get_firmware_name = rt61pci_get_firmware_name,
2477 .get_firmware_crc = rt61pci_get_firmware_crc,
2460 .load_firmware = rt61pci_load_firmware, 2478 .load_firmware = rt61pci_load_firmware,
2461 .initialize = rt2x00pci_initialize, 2479 .initialize = rt2x00pci_initialize,
2462 .uninitialize = rt2x00pci_uninitialize, 2480 .uninitialize = rt2x00pci_uninitialize,
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index 82dd4ced4005..72c2827ee57c 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -24,6 +24,7 @@
24 Supported chipsets: rt2571W & rt2671. 24 Supported chipsets: rt2571W & rt2671.
25 */ 25 */
26 26
27#include <linux/crc-itu-t.h>
27#include <linux/delay.h> 28#include <linux/delay.h>
28#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
29#include <linux/init.h> 30#include <linux/init.h>
@@ -817,16 +818,30 @@ dynamic_cca_tune:
817} 818}
818 819
819/* 820/*
820 * Firmware name function. 821 * Firmware functions
821 */ 822 */
822static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev) 823static char *rt73usb_get_firmware_name(struct rt2x00_dev *rt2x00dev)
823{ 824{
824 return FIRMWARE_RT2571; 825 return FIRMWARE_RT2571;
825} 826}
826 827
827/* 828static u16 rt73usb_get_firmware_crc(void *data, const size_t len)
828 * Initialization functions. 829{
829 */ 830 u16 crc;
831
832 /*
833 * Use the crc itu-t algorithm.
834 * The last 2 bytes in the firmware array are the crc checksum itself,
835 * this means that we should never pass those 2 bytes to the crc
836 * algorithm.
837 */
838 crc = crc_itu_t(0, data, len - 2);
839 crc = crc_itu_t_byte(crc, 0);
840 crc = crc_itu_t_byte(crc, 0);
841
842 return crc;
843}
844
830static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, void *data, 845static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
831 const size_t len) 846 const size_t len)
832{ 847{
@@ -896,6 +911,9 @@ static int rt73usb_load_firmware(struct rt2x00_dev *rt2x00dev, void *data,
896 return 0; 911 return 0;
897} 912}
898 913
914/*
915 * Initialization functions.
916 */
899static int rt73usb_init_registers(struct rt2x00_dev *rt2x00dev) 917static int rt73usb_init_registers(struct rt2x00_dev *rt2x00dev)
900{ 918{
901 u32 reg; 919 u32 reg;
@@ -1852,7 +1870,6 @@ static int rt73usb_probe_hw(struct rt2x00_dev *rt2x00dev)
1852 * This device requires firmware. 1870 * This device requires firmware.
1853 */ 1871 */
1854 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags); 1872 __set_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags);
1855 __set_bit(DRIVER_REQUIRE_FIRMWARE_CRC_ITU_T, &rt2x00dev->flags);
1856 1873
1857 /* 1874 /*
1858 * Set the rssi offset. 1875 * Set the rssi offset.
@@ -2061,6 +2078,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = {
2061static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { 2078static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
2062 .probe_hw = rt73usb_probe_hw, 2079 .probe_hw = rt73usb_probe_hw,
2063 .get_firmware_name = rt73usb_get_firmware_name, 2080 .get_firmware_name = rt73usb_get_firmware_name,
2081 .get_firmware_crc = rt73usb_get_firmware_crc,
2064 .load_firmware = rt73usb_load_firmware, 2082 .load_firmware = rt73usb_load_firmware,
2065 .initialize = rt2x00usb_initialize, 2083 .initialize = rt2x00usb_initialize,
2066 .uninitialize = rt2x00usb_uninitialize, 2084 .uninitialize = rt2x00usb_uninitialize,