aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/spectrum_cs.c
diff options
context:
space:
mode:
authorDavid Kilroy <kilroyd@gmail.com>2008-08-21 18:27:52 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-22 19:28:05 -0400
commite23341809b7b60981d14a368155cd1f0724fb8d5 (patch)
tree0d035f354eec28816b1fcf813b9f5ed665d3d827 /drivers/net/wireless/spectrum_cs.c
parentf482eb797a391a098046a934f55af8bd785a4494 (diff)
orinoco: Make firmware download logic more generic
Ensure PDA read is terminated. Prevent invalid programming blocks from causing reads outside the firmware image Turn off aux stuff when finished. Option to program in limited block sizes (controlled by macro). Option to read PDA from EEPROM. Signed-off-by: David Kilroy <kilroyd@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/spectrum_cs.c')
-rw-r--r--drivers/net/wireless/spectrum_cs.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index 579873d0e8c9..2fb00183cd71 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -166,11 +166,12 @@ spectrum_reset(struct pcmcia_device *link, int idle)
166 */ 166 */
167static int 167static int
168spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link, 168spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
169 const unsigned char *image, int secondary) 169 const unsigned char *image, const unsigned char *end,
170 int secondary)
170{ 171{
171 int ret; 172 int ret;
172 const unsigned char *ptr; 173 const unsigned char *ptr;
173 const struct dblock *first_block; 174 const unsigned char *first_block;
174 175
175 /* Plug Data Area (PDA) */ 176 /* Plug Data Area (PDA) */
176 __le16 pda[PDA_WORDS]; 177 __le16 pda[PDA_WORDS];
@@ -178,11 +179,11 @@ spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
178 /* Binary block begins after the 0x1A marker */ 179 /* Binary block begins after the 0x1A marker */
179 ptr = image; 180 ptr = image;
180 while (*ptr++ != TEXT_END); 181 while (*ptr++ != TEXT_END);
181 first_block = (const struct dblock *) ptr; 182 first_block = ptr;
182 183
183 /* Read the PDA */ 184 /* Read the PDA from EEPROM */
184 if (secondary) { 185 if (secondary) {
185 ret = spectrum_read_pda(hw, pda, sizeof(pda)); 186 ret = hermes_read_pda(hw, pda, PDA_ADDR, sizeof(pda), 1);
186 if (ret) 187 if (ret)
187 return ret; 188 return ret;
188 } 189 }
@@ -193,13 +194,15 @@ spectrum_dl_image(hermes_t *hw, struct pcmcia_device *link,
193 return ret; 194 return ret;
194 195
195 /* Program the adapter with new firmware */ 196 /* Program the adapter with new firmware */
196 ret = spectrum_load_blocks(hw, first_block); 197 ret = hermes_program(hw, first_block, end);
197 if (ret) 198 if (ret)
198 return ret; 199 return ret;
199 200
200 /* Write the PDA to the adapter */ 201 /* Write the PDA to the adapter */
201 if (secondary) { 202 if (secondary) {
202 ret = spectrum_apply_pda(hw, first_block, pda); 203 size_t len = hermes_blocks_length(first_block);
204 ptr = first_block + len;
205 ret = hermes_apply_pda(hw, ptr, pda);
203 if (ret) 206 if (ret)
204 return ret; 207 return ret;
205 } 208 }
@@ -242,7 +245,8 @@ spectrum_dl_firmware(hermes_t *hw, struct pcmcia_device *link)
242 } 245 }
243 246
244 /* Load primary firmware */ 247 /* Load primary firmware */
245 ret = spectrum_dl_image(hw, link, fw_entry->data, 0); 248 ret = spectrum_dl_image(hw, link, fw_entry->data,
249 fw_entry->data + fw_entry->size, 0);
246 release_firmware(fw_entry); 250 release_firmware(fw_entry);
247 if (ret) { 251 if (ret) {
248 printk(KERN_ERR PFX "Primary firmware download failed\n"); 252 printk(KERN_ERR PFX "Primary firmware download failed\n");
@@ -257,7 +261,8 @@ spectrum_dl_firmware(hermes_t *hw, struct pcmcia_device *link)
257 } 261 }
258 262
259 /* Load secondary firmware */ 263 /* Load secondary firmware */
260 ret = spectrum_dl_image(hw, link, fw_entry->data, 1); 264 ret = spectrum_dl_image(hw, link, fw_entry->data,
265 fw_entry->data + fw_entry->size, 1);
261 release_firmware(fw_entry); 266 release_firmware(fw_entry);
262 if (ret) { 267 if (ret) {
263 printk(KERN_ERR PFX "Secondary firmware download failed\n"); 268 printk(KERN_ERR PFX "Secondary firmware download failed\n");