aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2x00firmware.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00firmware.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00firmware.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00firmware.c b/drivers/net/wireless/rt2x00/rt2x00firmware.c
index 0a475e4e2442..b971bc6e7ee2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00firmware.c
+++ b/drivers/net/wireless/rt2x00/rt2x00firmware.c
@@ -1,5 +1,5 @@
1/* 1/*
2 Copyright (C) 2004 - 2007 rt2x00 SourceForge Project 2 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com> 3 <http://rt2x00.serialmonkey.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -23,7 +23,6 @@
23 Abstract: rt2x00 firmware loading routines. 23 Abstract: rt2x00 firmware loading routines.
24 */ 24 */
25 25
26#include <linux/crc-itu-t.h>
27#include <linux/kernel.h> 26#include <linux/kernel.h>
28#include <linux/module.h> 27#include <linux/module.h>
29 28
@@ -37,7 +36,6 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
37 char *fw_name; 36 char *fw_name;
38 int retval; 37 int retval;
39 u16 crc; 38 u16 crc;
40 u16 tmp;
41 39
42 /* 40 /*
43 * Read correct firmware from harddisk. 41 * Read correct firmware from harddisk.
@@ -63,18 +61,9 @@ 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 * Validate the firmware using 16 bit CRC.
68 * The last 2 bytes of the firmware are the CRC
69 * so substract those 2 bytes from the CRC checksum,
70 * and set those 2 bytes to 0 when calculating CRC.
71 */
72 tmp = 0;
73 crc = crc_itu_t(0, fw->data, fw->size - 2);
74 crc = crc_itu_t(crc, (u8 *)&tmp, 2);
75
76 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])) {
77 ERROR(rt2x00dev, "Firmware CRC error.\n"); 66 ERROR(rt2x00dev, "Firmware checksum error.\n");
78 retval = -ENOENT; 67 retval = -ENOENT;
79 goto exit; 68 goto exit;
80 } 69 }
@@ -96,6 +85,9 @@ int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
96{ 85{
97 int retval; 86 int retval;
98 87
88 if (!test_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags))
89 return 0;
90
99 if (!rt2x00dev->fw) { 91 if (!rt2x00dev->fw) {
100 retval = rt2x00lib_request_firmware(rt2x00dev); 92 retval = rt2x00lib_request_firmware(rt2x00dev);
101 if (retval) 93 if (retval)
@@ -116,4 +108,3 @@ void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)
116 release_firmware(rt2x00dev->fw); 108 release_firmware(rt2x00dev->fw);
117 rt2x00dev->fw = NULL; 109 rt2x00dev->fw = NULL;
118} 110}
119