Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

orinoco: firmware: consistently compile out fw cache support if not requested

Currently part of support for FW caching is unconditionally compiled
in even if it is never used. Consistently remove caching support if
not requested by user.

Signed-off-by: Andrey Borzenkov <arvidjaar@mail.ru>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Andrey Borzenkov and committed by
John W. Linville
2bfc5cb5 afece1c6

+33 -13
+24 -13
drivers/net/wireless/orinoco/fw.c
··· 70 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 86 /* Download either STA or AP firmware into the card. */ 74 87 static int 75 88 orinoco_dl_firmware(struct orinoco_private *priv, ··· 120 107 if (err) 121 108 goto free; 122 109 123 - if (!priv->cached_fw) { 110 + if (!orinoco_cached_fw_get(priv, false)) { 124 111 err = request_firmware(&fw_entry, firmware, priv->dev); 125 112 126 113 if (err) { ··· 130 117 goto free; 131 118 } 132 119 } else 133 - fw_entry = priv->cached_fw; 120 + fw_entry = orinoco_cached_fw_get(priv, false); 134 121 135 122 hdr = (const struct orinoco_fw_header *) fw_entry->data; 136 123 ··· 183 170 184 171 abort: 185 172 /* If we requested the firmware, release it. */ 186 - if (!priv->cached_fw) 173 + if (!orinoco_cached_fw_get(priv, false)) 187 174 release_firmware(fw_entry); 188 175 189 176 free: ··· 286 273 int ret; 287 274 const struct firmware *fw_entry; 288 275 289 - if (!priv->cached_pri_fw) { 276 + if (!orinoco_cached_fw_get(priv, true)) { 290 277 if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) { 291 278 printk(KERN_ERR "%s: Cannot find firmware: %s\n", 292 279 dev->name, fw->pri_fw); 293 280 return -ENOENT; 294 281 } 295 282 } else 296 - fw_entry = priv->cached_pri_fw; 283 + fw_entry = orinoco_cached_fw_get(priv, true); 297 284 298 285 /* Load primary firmware */ 299 286 ret = symbol_dl_image(priv, fw, fw_entry->data, 300 287 fw_entry->data + fw_entry->size, 0); 301 288 302 - if (!priv->cached_pri_fw) 289 + if (!orinoco_cached_fw_get(priv, true)) 303 290 release_firmware(fw_entry); 304 291 if (ret) { 305 292 printk(KERN_ERR "%s: Primary firmware download failed\n", ··· 307 294 return ret; 308 295 } 309 296 310 - if (!priv->cached_fw) { 297 + if (!orinoco_cached_fw_get(priv, false)) { 311 298 if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) { 312 299 printk(KERN_ERR "%s: Cannot find firmware: %s\n", 313 300 dev->name, fw->sta_fw); 314 301 return -ENOENT; 315 302 } 316 303 } else 317 - fw_entry = priv->cached_fw; 304 + fw_entry = orinoco_cached_fw_get(priv, false); 318 305 319 306 /* Load secondary firmware */ 320 307 ret = symbol_dl_image(priv, fw, fw_entry->data, 321 308 fw_entry->data + fw_entry->size, 1); 322 - if (!priv->cached_fw) 309 + if (!orinoco_cached_fw_get(priv, false)) 323 310 release_firmware(fw_entry); 324 311 if (ret) { 325 312 printk(KERN_ERR "%s: Secondary firmware download failed\n", ··· 353 340 return err; 354 341 } 355 342 343 + #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 356 344 void orinoco_cache_fw(struct orinoco_private *priv, int ap) 357 345 { 358 - #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 359 346 const struct firmware *fw_entry = NULL; 360 347 const char *pri_fw; 361 348 const char *fw; ··· 375 362 if (request_firmware(&fw_entry, fw, priv->dev) == 0) 376 363 priv->cached_fw = fw_entry; 377 364 } 378 - #endif 379 365 } 380 366 381 367 void orinoco_uncache_fw(struct orinoco_private *priv) 382 368 { 383 - #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 384 369 if (priv->cached_pri_fw) 385 370 release_firmware(priv->cached_pri_fw); 386 371 if (priv->cached_fw) ··· 386 375 387 376 priv->cached_pri_fw = NULL; 388 377 priv->cached_fw = NULL; 389 - #endif 390 378 } 379 + #endif
+5
drivers/net/wireless/orinoco/fw.h
··· 10 10 11 11 int orinoco_download(struct orinoco_private *priv); 12 12 13 + #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 13 14 void orinoco_cache_fw(struct orinoco_private *priv, int ap); 14 15 void orinoco_uncache_fw(struct orinoco_private *priv); 16 + #else 17 + #define orinoco_cache_fw(priv, ap) do { } while(0) 18 + #define orinoco_uncache_fw(priv) do { } while (0) 19 + #endif 15 20 16 21 #endif /* _ORINOCO_FW_H_ */
+2
drivers/net/wireless/orinoco/main.c
··· 2580 2580 netif_carrier_off(dev); 2581 2581 priv->last_linkstatus = 0xffff; 2582 2582 2583 + #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 2583 2584 priv->cached_pri_fw = NULL; 2584 2585 priv->cached_fw = NULL; 2586 + #endif 2585 2587 2586 2588 /* Register PM notifiers */ 2587 2589 orinoco_register_pm_notifier(priv);
+2
drivers/net/wireless/orinoco/orinoco.h
··· 159 159 unsigned int tkip_cm_active:1; 160 160 unsigned int key_mgmt:3; 161 161 162 + #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) 162 163 /* Cached in memory firmware to use during ->resume. */ 163 164 const struct firmware *cached_pri_fw; 164 165 const struct firmware *cached_fw; 166 + #endif 165 167 166 168 struct notifier_block pm_notifier; 167 169 };