diff options
Diffstat (limited to 'drivers/net/wireless/orinoco/fw.c')
-rw-r--r-- | drivers/net/wireless/orinoco/fw.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/drivers/net/wireless/orinoco/fw.c b/drivers/net/wireless/orinoco/fw.c index e7abb45d6753..1084b43e04bc 100644 --- a/drivers/net/wireless/orinoco/fw.c +++ b/drivers/net/wireless/orinoco/fw.c | |||
@@ -70,6 +70,19 @@ static const char *validate_fw(const struct orinoco_fw_header *hdr, size_t len) | |||
70 | return NULL; | 70 | return NULL; |
71 | } | 71 | } |
72 | 72 | ||
73 | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) | ||
74 | static inline const struct firmware * | ||
75 | orinoco_cached_fw_get(struct orinoco_private *priv, bool primary) | ||
76 | { | ||
77 | if (primary) | ||
78 | return priv->cached_pri_fw; | ||
79 | else | ||
80 | return priv->cached_fw; | ||
81 | } | ||
82 | #else | ||
83 | #define orinoco_cached_fw_get(priv, primary) (NULL) | ||
84 | #endif | ||
85 | |||
73 | /* Download either STA or AP firmware into the card. */ | 86 | /* Download either STA or AP firmware into the card. */ |
74 | static int | 87 | static int |
75 | orinoco_dl_firmware(struct orinoco_private *priv, | 88 | orinoco_dl_firmware(struct orinoco_private *priv, |
@@ -107,7 +120,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
107 | if (err) | 120 | if (err) |
108 | goto free; | 121 | goto free; |
109 | 122 | ||
110 | if (!priv->cached_fw) { | 123 | if (!orinoco_cached_fw_get(priv, false)) { |
111 | err = request_firmware(&fw_entry, firmware, priv->dev); | 124 | err = request_firmware(&fw_entry, firmware, priv->dev); |
112 | 125 | ||
113 | if (err) { | 126 | if (err) { |
@@ -117,7 +130,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
117 | goto free; | 130 | goto free; |
118 | } | 131 | } |
119 | } else | 132 | } else |
120 | fw_entry = priv->cached_fw; | 133 | fw_entry = orinoco_cached_fw_get(priv, false); |
121 | 134 | ||
122 | hdr = (const struct orinoco_fw_header *) fw_entry->data; | 135 | hdr = (const struct orinoco_fw_header *) fw_entry->data; |
123 | 136 | ||
@@ -170,7 +183,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
170 | 183 | ||
171 | abort: | 184 | abort: |
172 | /* If we requested the firmware, release it. */ | 185 | /* If we requested the firmware, release it. */ |
173 | if (!priv->cached_fw) | 186 | if (!orinoco_cached_fw_get(priv, false)) |
174 | release_firmware(fw_entry); | 187 | release_firmware(fw_entry); |
175 | 188 | ||
176 | free: | 189 | free: |
@@ -273,20 +286,20 @@ symbol_dl_firmware(struct orinoco_private *priv, | |||
273 | int ret; | 286 | int ret; |
274 | const struct firmware *fw_entry; | 287 | const struct firmware *fw_entry; |
275 | 288 | ||
276 | if (!priv->cached_pri_fw) { | 289 | if (!orinoco_cached_fw_get(priv, true)) { |
277 | if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) { | 290 | if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) { |
278 | printk(KERN_ERR "%s: Cannot find firmware: %s\n", | 291 | printk(KERN_ERR "%s: Cannot find firmware: %s\n", |
279 | dev->name, fw->pri_fw); | 292 | dev->name, fw->pri_fw); |
280 | return -ENOENT; | 293 | return -ENOENT; |
281 | } | 294 | } |
282 | } else | 295 | } else |
283 | fw_entry = priv->cached_pri_fw; | 296 | fw_entry = orinoco_cached_fw_get(priv, true); |
284 | 297 | ||
285 | /* Load primary firmware */ | 298 | /* Load primary firmware */ |
286 | ret = symbol_dl_image(priv, fw, fw_entry->data, | 299 | ret = symbol_dl_image(priv, fw, fw_entry->data, |
287 | fw_entry->data + fw_entry->size, 0); | 300 | fw_entry->data + fw_entry->size, 0); |
288 | 301 | ||
289 | if (!priv->cached_pri_fw) | 302 | if (!orinoco_cached_fw_get(priv, true)) |
290 | release_firmware(fw_entry); | 303 | release_firmware(fw_entry); |
291 | if (ret) { | 304 | if (ret) { |
292 | printk(KERN_ERR "%s: Primary firmware download failed\n", | 305 | printk(KERN_ERR "%s: Primary firmware download failed\n", |
@@ -294,19 +307,19 @@ symbol_dl_firmware(struct orinoco_private *priv, | |||
294 | return ret; | 307 | return ret; |
295 | } | 308 | } |
296 | 309 | ||
297 | if (!priv->cached_fw) { | 310 | if (!orinoco_cached_fw_get(priv, false)) { |
298 | if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) { | 311 | if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) { |
299 | printk(KERN_ERR "%s: Cannot find firmware: %s\n", | 312 | printk(KERN_ERR "%s: Cannot find firmware: %s\n", |
300 | dev->name, fw->sta_fw); | 313 | dev->name, fw->sta_fw); |
301 | return -ENOENT; | 314 | return -ENOENT; |
302 | } | 315 | } |
303 | } else | 316 | } else |
304 | fw_entry = priv->cached_fw; | 317 | fw_entry = orinoco_cached_fw_get(priv, false); |
305 | 318 | ||
306 | /* Load secondary firmware */ | 319 | /* Load secondary firmware */ |
307 | ret = symbol_dl_image(priv, fw, fw_entry->data, | 320 | ret = symbol_dl_image(priv, fw, fw_entry->data, |
308 | fw_entry->data + fw_entry->size, 1); | 321 | fw_entry->data + fw_entry->size, 1); |
309 | if (!priv->cached_fw) | 322 | if (!orinoco_cached_fw_get(priv, false)) |
310 | release_firmware(fw_entry); | 323 | release_firmware(fw_entry); |
311 | if (ret) { | 324 | if (ret) { |
312 | printk(KERN_ERR "%s: Secondary firmware download failed\n", | 325 | printk(KERN_ERR "%s: Secondary firmware download failed\n", |
@@ -340,9 +353,9 @@ int orinoco_download(struct orinoco_private *priv) | |||
340 | return err; | 353 | return err; |
341 | } | 354 | } |
342 | 355 | ||
356 | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) | ||
343 | void orinoco_cache_fw(struct orinoco_private *priv, int ap) | 357 | void orinoco_cache_fw(struct orinoco_private *priv, int ap) |
344 | { | 358 | { |
345 | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) | ||
346 | const struct firmware *fw_entry = NULL; | 359 | const struct firmware *fw_entry = NULL; |
347 | const char *pri_fw; | 360 | const char *pri_fw; |
348 | const char *fw; | 361 | const char *fw; |
@@ -362,12 +375,10 @@ void orinoco_cache_fw(struct orinoco_private *priv, int ap) | |||
362 | if (request_firmware(&fw_entry, fw, priv->dev) == 0) | 375 | if (request_firmware(&fw_entry, fw, priv->dev) == 0) |
363 | priv->cached_fw = fw_entry; | 376 | priv->cached_fw = fw_entry; |
364 | } | 377 | } |
365 | #endif | ||
366 | } | 378 | } |
367 | 379 | ||
368 | void orinoco_uncache_fw(struct orinoco_private *priv) | 380 | void orinoco_uncache_fw(struct orinoco_private *priv) |
369 | { | 381 | { |
370 | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) | ||
371 | if (priv->cached_pri_fw) | 382 | if (priv->cached_pri_fw) |
372 | release_firmware(priv->cached_pri_fw); | 383 | release_firmware(priv->cached_pri_fw); |
373 | if (priv->cached_fw) | 384 | if (priv->cached_fw) |
@@ -375,5 +386,5 @@ void orinoco_uncache_fw(struct orinoco_private *priv) | |||
375 | 386 | ||
376 | priv->cached_pri_fw = NULL; | 387 | priv->cached_pri_fw = NULL; |
377 | priv->cached_fw = NULL; | 388 | priv->cached_fw = NULL; |
378 | #endif | ||
379 | } | 389 | } |
390 | #endif | ||