rt2x00: Fix access permissions on debugfs files
[safe/jmp/linux-2.6] / drivers / net / wireless / rt2x00 / rt2x00firmware.c
index 442ff80..bab05a5 100644 (file)
@@ -23,7 +23,6 @@
        Abstract: rt2x00 firmware loading routines.
  */
 
-#include <linux/crc-itu-t.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 
@@ -37,7 +36,6 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
        char *fw_name;
        int retval;
        u16 crc;
-       u16 tmp;
 
        /*
         * Read correct firmware from harddisk.
@@ -63,18 +61,9 @@ static int rt2x00lib_request_firmware(struct rt2x00_dev *rt2x00dev)
                return -ENOENT;
        }
 
-       /*
-        * Validate the firmware using 16 bit CRC.
-        * The last 2 bytes of the firmware are the CRC
-        * so substract those 2 bytes from the CRC checksum,
-        * and set those 2 bytes to 0 when calculating CRC.
-        */
-       tmp = 0;
-       crc = crc_itu_t(0, fw->data, fw->size - 2);
-       crc = crc_itu_t(crc, (u8 *)&tmp, 2);
-
+       crc = rt2x00dev->ops->lib->get_firmware_crc(fw->data, fw->size);
        if (crc != (fw->data[fw->size - 2] << 8 | fw->data[fw->size - 1])) {
-               ERROR(rt2x00dev, "Firmware CRC error.\n");
+               ERROR(rt2x00dev, "Firmware checksum error.\n");
                retval = -ENOENT;
                goto exit;
        }
@@ -96,6 +85,9 @@ int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
 {
        int retval;
 
+       if (!test_bit(DRIVER_REQUIRE_FIRMWARE, &rt2x00dev->flags))
+               return 0;
+
        if (!rt2x00dev->fw) {
                retval = rt2x00lib_request_firmware(rt2x00dev);
                if (retval)
@@ -108,6 +100,14 @@ int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
        retval = rt2x00dev->ops->lib->load_firmware(rt2x00dev,
                                                    rt2x00dev->fw->data,
                                                    rt2x00dev->fw->size);
+
+       /*
+        * When the firmware is uploaded to the hardware the LED
+        * association status might have been triggered, for correct
+        * LED handling it should now be reset.
+        */
+       rt2x00leds_led_assoc(rt2x00dev, false);
+
        return retval;
 }
 
@@ -116,4 +116,3 @@ void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)
        release_firmware(rt2x00dev->fw);
        rt2x00dev->fw = NULL;
 }
-