2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the
17 Free Software Foundation, Inc.,
18 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Abstract: rt2x00 firmware loading routines.
26 #include <linux/kernel.h>
27 #include <linux/module.h>
30 #include "rt2x00lib.h"
32 static int rt2x00lib_request_firmware(struct rt2x00_dev
*rt2x00dev
)
34 struct device
*device
= wiphy_dev(rt2x00dev
->hw
->wiphy
);
35 const struct firmware
*fw
;
40 * Read correct firmware from harddisk.
42 fw_name
= rt2x00dev
->ops
->lib
->get_firmware_name(rt2x00dev
);
45 "Invalid firmware filename.\n"
46 "Please file bug report to %s.\n", DRV_PROJECT
);
50 INFO(rt2x00dev
, "Loading firmware file '%s'.\n", fw_name
);
52 retval
= request_firmware(&fw
, fw_name
, device
);
54 ERROR(rt2x00dev
, "Failed to request Firmware.\n");
58 if (!fw
|| !fw
->size
|| !fw
->data
) {
59 ERROR(rt2x00dev
, "Failed to read Firmware.\n");
63 INFO(rt2x00dev
, "Firmware detected - version: %d.%d.\n",
64 fw
->data
[fw
->size
- 4], fw
->data
[fw
->size
- 3]);
66 retval
= rt2x00dev
->ops
->lib
->check_firmware(rt2x00dev
, fw
->data
, fw
->size
);
71 ERROR(rt2x00dev
, "Firmware checksum error.\n");
75 "Invalid firmware file length (len=%zu)\n", fw
->size
);
79 "Current firmware does not support detected chipset.\n");
93 int rt2x00lib_load_firmware(struct rt2x00_dev
*rt2x00dev
)
97 if (!test_bit(DRIVER_REQUIRE_FIRMWARE
, &rt2x00dev
->flags
))
100 if (!rt2x00dev
->fw
) {
101 retval
= rt2x00lib_request_firmware(rt2x00dev
);
107 * Send firmware to the device.
109 retval
= rt2x00dev
->ops
->lib
->load_firmware(rt2x00dev
,
111 rt2x00dev
->fw
->size
);
114 * When the firmware is uploaded to the hardware the LED
115 * association status might have been triggered, for correct
116 * LED handling it should now be reset.
118 rt2x00leds_led_assoc(rt2x00dev
, false);
123 void rt2x00lib_free_firmware(struct rt2x00_dev
*rt2x00dev
)
125 release_firmware(rt2x00dev
->fw
);
126 rt2x00dev
->fw
= NULL
;