wl12xx: 1281/1283 support - Loading FW & NVS

Take care of FW & NVS with the auto-detection between wl127x and
wl128x.

[Moved some common code outside if statements and added notes about
NVS structure assumptions; Fixed a bug when checking the nvs size: if
the size was incorrect, the local nvs variable was set to NULL, it
should be wl->nvs instead. -- Luca]

[Merged with potential buffer overflow fix -- Luca]

Signed-off-by: Shahar Levi <shahar_levi@ti.com>
Reviewed-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: Luciano Coelho <coelho@ti.com>
This commit is contained in:
Shahar Levi
2011-03-06 16:32:10 +02:00
committed by Luciano Coelho
parent 49d750ca14
commit bc765bf3b9
7 changed files with 86 additions and 42 deletions

View File

@ -189,7 +189,12 @@ static int wl1271_fetch_firmware(struct wl1271 *wl)
const struct firmware *fw;
int ret;
ret = request_firmware(&fw, WL1271_FW_NAME, wl1271_wl_to_dev(wl));
if (wl->chip.id == CHIP_ID_1283_PG20)
ret = request_firmware(&fw, WL128X_FW_NAME,
wl1271_wl_to_dev(wl));
else
ret = request_firmware(&fw, WL1271_FW_NAME,
wl1271_wl_to_dev(wl));
if (ret < 0) {
wl1271_error("could not get firmware: %d", ret);
@ -234,7 +239,7 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
return ret;
}
wl->nvs = kmemdup(fw->data, sizeof(struct wl1271_nvs_file), GFP_KERNEL);
wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL);
if (!wl->nvs) {
wl1271_error("could not allocate memory for the nvs file");