aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuuso Oikarinen <juuso.oikarinen@nokia.com>2009-10-08 14:56:32 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-10-27 16:47:53 -0400
commit1fba49741dc50d13d2fe6cf04f5a547e6c5c81f6 (patch)
tree1d7909c9350478512c599f950116b0552a7c33f1
parentc87dec9f189b884df215756e285b9281cf065206 (diff)
wl1271: Use vmalloc to allocate memory for firmware
Use vmalloc to allocate memory for the firmware image, and use a smaller linear buffer for the actual transfer of the firmware to the chipset. This patch is an adaptation of a similar patch for wl1251 by Kalle Valo. Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Reviewed-by: Luciano Coelho <luciano.coelho@nokia.com> Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_boot.c16
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c5
2 files changed, 15 insertions, 6 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_boot.c b/drivers/net/wireless/wl12xx/wl1271_boot.c
index 8228ef474a7e..7640313c45c1 100644
--- a/drivers/net/wireless/wl12xx/wl1271_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1271_boot.c
@@ -94,7 +94,7 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,
94 size_t fw_data_len, u32 dest) 94 size_t fw_data_len, u32 dest)
95{ 95{
96 int addr, chunk_num, partition_limit; 96 int addr, chunk_num, partition_limit;
97 u8 *p; 97 u8 *p, *chunk;
98 98
99 /* whal_FwCtrl_LoadFwImageSm() */ 99 /* whal_FwCtrl_LoadFwImageSm() */
100 100
@@ -103,12 +103,17 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,
103 wl1271_debug(DEBUG_BOOT, "fw_data_len %zd chunk_size %d", 103 wl1271_debug(DEBUG_BOOT, "fw_data_len %zd chunk_size %d",
104 fw_data_len, CHUNK_SIZE); 104 fw_data_len, CHUNK_SIZE);
105 105
106
107 if ((fw_data_len % 4) != 0) { 106 if ((fw_data_len % 4) != 0) {
108 wl1271_error("firmware length not multiple of four"); 107 wl1271_error("firmware length not multiple of four");
109 return -EIO; 108 return -EIO;
110 } 109 }
111 110
111 chunk = kmalloc(CHUNK_SIZE, GFP_KERNEL);
112 if (!buf) {
113 wl1271_error("allocation for firmware upload chunk failed");
114 return -ENOMEM;
115 }
116
112 wl1271_set_partition(wl, dest, 117 wl1271_set_partition(wl, dest,
113 part_table[PART_DOWN].mem.size, 118 part_table[PART_DOWN].mem.size,
114 part_table[PART_DOWN].reg.start, 119 part_table[PART_DOWN].reg.start,
@@ -137,9 +142,10 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,
137 /* 10.3 upload the chunk */ 142 /* 10.3 upload the chunk */
138 addr = dest + chunk_num * CHUNK_SIZE; 143 addr = dest + chunk_num * CHUNK_SIZE;
139 p = buf + chunk_num * CHUNK_SIZE; 144 p = buf + chunk_num * CHUNK_SIZE;
145 memcpy(chunk, p, CHUNK_SIZE);
140 wl1271_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", 146 wl1271_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x",
141 p, addr); 147 p, addr);
142 wl1271_spi_mem_write(wl, addr, p, CHUNK_SIZE); 148 wl1271_spi_mem_write(wl, addr, chunk, CHUNK_SIZE);
143 149
144 chunk_num++; 150 chunk_num++;
145 } 151 }
@@ -147,10 +153,12 @@ static int wl1271_boot_upload_firmware_chunk(struct wl1271 *wl, void *buf,
147 /* 10.4 upload the last chunk */ 153 /* 10.4 upload the last chunk */
148 addr = dest + chunk_num * CHUNK_SIZE; 154 addr = dest + chunk_num * CHUNK_SIZE;
149 p = buf + chunk_num * CHUNK_SIZE; 155 p = buf + chunk_num * CHUNK_SIZE;
156 memcpy(chunk, p, fw_data_len % CHUNK_SIZE);
150 wl1271_debug(DEBUG_BOOT, "uploading fw last chunk (%zd B) 0x%p to 0x%x", 157 wl1271_debug(DEBUG_BOOT, "uploading fw last chunk (%zd B) 0x%p to 0x%x",
151 fw_data_len % CHUNK_SIZE, p, addr); 158 fw_data_len % CHUNK_SIZE, p, addr);
152 wl1271_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE); 159 wl1271_spi_mem_write(wl, addr, chunk, fw_data_len % CHUNK_SIZE);
153 160
161 kfree(chunk);
154 return 0; 162 return 0;
155} 163}
156 164
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 09fe9686977a..d22de23f0bce 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -30,6 +30,7 @@
30#include <linux/spi/spi.h> 30#include <linux/spi/spi.h>
31#include <linux/crc32.h> 31#include <linux/crc32.h>
32#include <linux/etherdevice.h> 32#include <linux/etherdevice.h>
33#include <linux/vmalloc.h>
33#include <linux/spi/wl12xx.h> 34#include <linux/spi/wl12xx.h>
34 35
35#include "wl1271.h" 36#include "wl1271.h"
@@ -231,7 +232,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl)
231 } 232 }
232 233
233 wl->fw_len = fw->size; 234 wl->fw_len = fw->size;
234 wl->fw = kmalloc(wl->fw_len, GFP_KERNEL); 235 wl->fw = vmalloc(wl->fw_len);
235 236
236 if (!wl->fw) { 237 if (!wl->fw) {
237 wl1271_error("could not allocate memory for the firmware"); 238 wl1271_error("could not allocate memory for the firmware");
@@ -1484,7 +1485,7 @@ static int __devexit wl1271_remove(struct spi_device *spi)
1484 platform_device_unregister(&wl1271_device); 1485 platform_device_unregister(&wl1271_device);
1485 free_irq(wl->irq, wl); 1486 free_irq(wl->irq, wl);
1486 kfree(wl->target_mem_map); 1487 kfree(wl->target_mem_map);
1487 kfree(wl->fw); 1488 vfree(wl->fw);
1488 wl->fw = NULL; 1489 wl->fw = NULL;
1489 kfree(wl->nvs); 1490 kfree(wl->nvs);
1490 wl->nvs = NULL; 1491 wl->nvs = NULL;