diff options
author | Juuso Oikarinen <juuso.oikarinen@nokia.com> | 2009-10-08 14:56:32 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-10-27 16:47:53 -0400 |
commit | 1fba49741dc50d13d2fe6cf04f5a547e6c5c81f6 (patch) | |
tree | 1d7909c9350478512c599f950116b0552a7c33f1 /drivers/net/wireless/wl12xx/wl1271_boot.c | |
parent | c87dec9f189b884df215756e285b9281cf065206 (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>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_boot.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_boot.c | 16 |
1 files changed, 12 insertions, 4 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 | ||