Commit 2bfc5cb5 authored by Andrey Borzenkov's avatar Andrey Borzenkov Committed by John W. Linville

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: default avatarAndrey Borzenkov <arvidjaar@mail.ru>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent afece1c6
...@@ -70,6 +70,19 @@ static const char *validate_fw(const struct orinoco_fw_header *hdr, size_t len) ...@@ -70,6 +70,19 @@ static const char *validate_fw(const struct orinoco_fw_header *hdr, size_t len)
return NULL; return NULL;
} }
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
static inline const struct firmware *
orinoco_cached_fw_get(struct orinoco_private *priv, bool primary)
{
if (primary)
return priv->cached_pri_fw;
else
return priv->cached_fw;
}
#else
#define orinoco_cached_fw_get(priv, primary) (NULL)
#endif
/* Download either STA or AP firmware into the card. */ /* Download either STA or AP firmware into the card. */
static int static int
orinoco_dl_firmware(struct orinoco_private *priv, orinoco_dl_firmware(struct orinoco_private *priv,
...@@ -107,7 +120,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, ...@@ -107,7 +120,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
if (err) if (err)
goto free; goto free;
if (!priv->cached_fw) { if (!orinoco_cached_fw_get(priv, false)) {
err = request_firmware(&fw_entry, firmware, priv->dev); err = request_firmware(&fw_entry, firmware, priv->dev);
if (err) { if (err) {
...@@ -117,7 +130,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, ...@@ -117,7 +130,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
goto free; goto free;
} }
} else } else
fw_entry = priv->cached_fw; fw_entry = orinoco_cached_fw_get(priv, false);
hdr = (const struct orinoco_fw_header *) fw_entry->data; hdr = (const struct orinoco_fw_header *) fw_entry->data;
...@@ -170,7 +183,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, ...@@ -170,7 +183,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
abort: abort:
/* If we requested the firmware, release it. */ /* If we requested the firmware, release it. */
if (!priv->cached_fw) if (!orinoco_cached_fw_get(priv, false))
release_firmware(fw_entry); release_firmware(fw_entry);
free: free:
...@@ -273,20 +286,20 @@ symbol_dl_firmware(struct orinoco_private *priv, ...@@ -273,20 +286,20 @@ symbol_dl_firmware(struct orinoco_private *priv,
int ret; int ret;
const struct firmware *fw_entry; const struct firmware *fw_entry;
if (!priv->cached_pri_fw) { if (!orinoco_cached_fw_get(priv, true)) {
if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) { if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) {
printk(KERN_ERR "%s: Cannot find firmware: %s\n", printk(KERN_ERR "%s: Cannot find firmware: %s\n",
dev->name, fw->pri_fw); dev->name, fw->pri_fw);
return -ENOENT; return -ENOENT;
} }
} else } else
fw_entry = priv->cached_pri_fw; fw_entry = orinoco_cached_fw_get(priv, true);
/* Load primary firmware */ /* Load primary firmware */
ret = symbol_dl_image(priv, fw, fw_entry->data, ret = symbol_dl_image(priv, fw, fw_entry->data,
fw_entry->data + fw_entry->size, 0); fw_entry->data + fw_entry->size, 0);
if (!priv->cached_pri_fw) if (!orinoco_cached_fw_get(priv, true))
release_firmware(fw_entry); release_firmware(fw_entry);
if (ret) { if (ret) {
printk(KERN_ERR "%s: Primary firmware download failed\n", printk(KERN_ERR "%s: Primary firmware download failed\n",
...@@ -294,19 +307,19 @@ symbol_dl_firmware(struct orinoco_private *priv, ...@@ -294,19 +307,19 @@ symbol_dl_firmware(struct orinoco_private *priv,
return ret; return ret;
} }
if (!priv->cached_fw) { if (!orinoco_cached_fw_get(priv, false)) {
if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) { if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) {
printk(KERN_ERR "%s: Cannot find firmware: %s\n", printk(KERN_ERR "%s: Cannot find firmware: %s\n",
dev->name, fw->sta_fw); dev->name, fw->sta_fw);
return -ENOENT; return -ENOENT;
} }
} else } else
fw_entry = priv->cached_fw; fw_entry = orinoco_cached_fw_get(priv, false);
/* Load secondary firmware */ /* Load secondary firmware */
ret = symbol_dl_image(priv, fw, fw_entry->data, ret = symbol_dl_image(priv, fw, fw_entry->data,
fw_entry->data + fw_entry->size, 1); fw_entry->data + fw_entry->size, 1);
if (!priv->cached_fw) if (!orinoco_cached_fw_get(priv, false))
release_firmware(fw_entry); release_firmware(fw_entry);
if (ret) { if (ret) {
printk(KERN_ERR "%s: Secondary firmware download failed\n", printk(KERN_ERR "%s: Secondary firmware download failed\n",
...@@ -340,9 +353,9 @@ int orinoco_download(struct orinoco_private *priv) ...@@ -340,9 +353,9 @@ int orinoco_download(struct orinoco_private *priv)
return err; return err;
} }
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
void orinoco_cache_fw(struct orinoco_private *priv, int ap) void orinoco_cache_fw(struct orinoco_private *priv, int ap)
{ {
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
const struct firmware *fw_entry = NULL; const struct firmware *fw_entry = NULL;
const char *pri_fw; const char *pri_fw;
const char *fw; const char *fw;
...@@ -362,12 +375,10 @@ void orinoco_cache_fw(struct orinoco_private *priv, int ap) ...@@ -362,12 +375,10 @@ void orinoco_cache_fw(struct orinoco_private *priv, int ap)
if (request_firmware(&fw_entry, fw, priv->dev) == 0) if (request_firmware(&fw_entry, fw, priv->dev) == 0)
priv->cached_fw = fw_entry; priv->cached_fw = fw_entry;
} }
#endif
} }
void orinoco_uncache_fw(struct orinoco_private *priv) void orinoco_uncache_fw(struct orinoco_private *priv)
{ {
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
if (priv->cached_pri_fw) if (priv->cached_pri_fw)
release_firmware(priv->cached_pri_fw); release_firmware(priv->cached_pri_fw);
if (priv->cached_fw) if (priv->cached_fw)
...@@ -375,5 +386,5 @@ void orinoco_uncache_fw(struct orinoco_private *priv) ...@@ -375,5 +386,5 @@ void orinoco_uncache_fw(struct orinoco_private *priv)
priv->cached_pri_fw = NULL; priv->cached_pri_fw = NULL;
priv->cached_fw = NULL; priv->cached_fw = NULL;
#endif
} }
#endif
...@@ -10,7 +10,12 @@ struct orinoco_private; ...@@ -10,7 +10,12 @@ struct orinoco_private;
int orinoco_download(struct orinoco_private *priv); int orinoco_download(struct orinoco_private *priv);
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
void orinoco_cache_fw(struct orinoco_private *priv, int ap); void orinoco_cache_fw(struct orinoco_private *priv, int ap);
void orinoco_uncache_fw(struct orinoco_private *priv); void orinoco_uncache_fw(struct orinoco_private *priv);
#else
#define orinoco_cache_fw(priv, ap) do { } while(0)
#define orinoco_uncache_fw(priv) do { } while (0)
#endif
#endif /* _ORINOCO_FW_H_ */ #endif /* _ORINOCO_FW_H_ */
...@@ -2580,8 +2580,10 @@ struct net_device ...@@ -2580,8 +2580,10 @@ struct net_device
netif_carrier_off(dev); netif_carrier_off(dev);
priv->last_linkstatus = 0xffff; priv->last_linkstatus = 0xffff;
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
priv->cached_pri_fw = NULL; priv->cached_pri_fw = NULL;
priv->cached_fw = NULL; priv->cached_fw = NULL;
#endif
/* Register PM notifiers */ /* Register PM notifiers */
orinoco_register_pm_notifier(priv); orinoco_register_pm_notifier(priv);
......
...@@ -159,9 +159,11 @@ struct orinoco_private { ...@@ -159,9 +159,11 @@ struct orinoco_private {
unsigned int tkip_cm_active:1; unsigned int tkip_cm_active:1;
unsigned int key_mgmt:3; unsigned int key_mgmt:3;
#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
/* Cached in memory firmware to use during ->resume. */ /* Cached in memory firmware to use during ->resume. */
const struct firmware *cached_pri_fw; const struct firmware *cached_pri_fw;
const struct firmware *cached_fw; const struct firmware *cached_fw;
#endif
struct notifier_block pm_notifier; struct notifier_block pm_notifier;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment