Skip to contentSkip to conversation

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

PATCH Superseded Andrey Borzenkov 2 participants 5 messages Feb 15, 2009 – Feb 28, 2009 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

Patch is against wireless-next

 drivers/net/wireless/orinoco/fw.c      |   24 +++++++--------
 drivers/net/wireless/orinoco/fw.h      |   50 +++++++++++++++++++++++++++++---
 drivers/net/wireless/orinoco/main.c    |    8 +++--
 drivers/net/wireless/orinoco/orinoco.h |    2 +
 4 files changed, 62 insertions(+), 22 deletions(-)
drivers/net/wireless/orinoco/fw.c +11 -13
index 7d2292d..842834e 100644
@@ -79,7 +79,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 	if (err)
 		goto free;
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv)) {
 		err = request_firmware(&fw_entry, firmware, priv->dev);
 
 		if (err) {
@@ -89,7 +89,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 			goto free;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv);
 
 	hdr = (const struct orinoco_fw_header *) fw_entry->data;
 
@@ -132,7 +132,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 
 abort:
 	/* If we requested the firmware, release it. */
-	if (!priv->cached_fw)
+	if (!orinoco_cached_fw_get(priv))
 		release_firmware(fw_entry);
 
 free:
@@ -234,20 +234,20 @@ symbol_dl_firmware(struct orinoco_private *priv,
 	int ret;
 	const struct firmware *fw_entry;
 
-	if (!priv->cached_pri_fw) {
+	if (!orinoco_cached_pri_fw_get(priv)) {
 		if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) {
 			printk(KERN_ERR "%s: Cannot find firmware: %s\n",
 			       dev->name, fw->pri_fw);
 			return -ENOENT;
 		}
 	} else
-		fw_entry = priv->cached_pri_fw;
+		fw_entry = orinoco_cached_pri_fw_get(priv);
 
 	/* Load primary firmware */
 	ret = symbol_dl_image(priv, fw, fw_entry->data,
 			      fw_entry->data + fw_entry->size, 0);
 
-	if (!priv->cached_pri_fw)
+	if (!orinoco_cached_pri_fw_get(priv))
 		release_firmware(fw_entry);
 	if (ret) {
 		printk(KERN_ERR "%s: Primary firmware download failed\n",
@@ -255,19 +255,19 @@ symbol_dl_firmware(struct orinoco_private *priv,
 		return ret;
 	}
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv)) {
 		if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) {
 			printk(KERN_ERR "%s: Cannot find firmware: %s\n",
 			       dev->name, fw->sta_fw);
 			return -ENOENT;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv);
 
 	/* Load secondary firmware */
 	ret = symbol_dl_image(priv, fw, fw_entry->data,
 			      fw_entry->data + fw_entry->size, 1);
-	if (!priv->cached_fw)
+	if (!orinoco_cached_fw_get(priv))
 		release_firmware(fw_entry);
 	if (ret) {
 		printk(KERN_ERR "%s: Secondary firmware download failed\n",
@@ -301,9 +301,9 @@ int orinoco_download(struct orinoco_private *priv)
 	return err;
 }
 
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 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 char *pri_fw;
 	const char *fw;
@@ -323,12 +323,10 @@ void orinoco_cache_fw(struct orinoco_private *priv, int ap)
 		if (request_firmware(&fw_entry, fw, priv->dev) == 0)
 			priv->cached_fw = fw_entry;
 	}
-#endif
 }
 
 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)
 		release_firmware(priv->cached_pri_fw);
 	if (priv->cached_fw)
@@ -336,5 +334,5 @@ void orinoco_uncache_fw(struct orinoco_private *priv)
 
 	priv->cached_pri_fw = NULL;
 	priv->cached_fw = NULL;
-#endif
 }
+#endif
drivers/net/wireless/orinoco/fw.h +45 -5

57 lines not on this page · raw message

drivers/net/wireless/orinoco/main.c +4 -4
index f953059..2afab2a 100644
@@ -89,6 +89,8 @@
 #include <linux/ieee80211.h>
 #include <net/iw_handler.h>
 
+#include "orinoco.h"
+
 #include "hermes_rid.h"
 #include "hermes_dld.h"
 #include "hw.h"
@@ -98,8 +100,6 @@
 #include "wext.h"
 #include "main.h"
 
-#include "orinoco.h"
-
 /********************************************************************/
 /* Module information                                               */
 /********************************************************************/
@@ -2580,8 +2580,8 @@ struct net_device
 	netif_carrier_off(dev);
 	priv->last_linkstatus = 0xffff;
 
-	priv->cached_pri_fw = NULL;
-	priv->cached_fw = NULL;
+	orinoco_cached_pri_fw_set(priv, NULL);
+	orinoco_cached_fw_set(priv, NULL);
 
 	/* Register PM notifiers */
 	orinoco_register_pm_notifier(priv);
drivers/net/wireless/orinoco/orinoco.h +2 -0
index f3f94b2..8e5a72c 100644
@@ -159,9 +159,11 @@ struct orinoco_private {
 	unsigned int tkip_cm_active:1;
 	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. */
 	const struct firmware *cached_pri_fw;
 	const struct firmware *cached_fw;
+#endif
 
 	struct notifier_block pm_notifier;
 };
#1 lore raw
Quoted 5 lines · Andrey Borzenkov

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.

I don't see much point, but...

Quoted 14 lines
drivers/net/wireless/orinoco/fw.c +1 -1
index 7d2292d..842834e 100644
@@ -79,7 +79,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 	if (err)
 		goto free;
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv)) {
 		err = request_firmware(&fw_entry, firmware, priv->dev);
 
 		if (err) {

drivers/net/wireless/orinoco/fw.c orinoco_dl_firmware(struct orinoco_private *priv, · line 92

Quoted 5 lines
drivers/net/wireless/orinoco/fw.c +1 -1
@@ -89,7 +89,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 			goto free;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv);

Rather than fiddling with how we access the pointers, I think it would be better to refactor these if..elses into function calls like

fw_entry = orinoco_get_pri_fw(...);

#if CACHING

struct firmware *orinoco_get_pri_fw(...) {
    priv->cached_fw;
}
#else
struct firmware *orinoco_get_pri_fw(...) {
    return request_firmware(..);
}

#endif

drivers/net/wireless/orinoco/fw.h line 10

Quoted 9 lines
drivers/net/wireless/orinoco/fw.h +0 -3
@@ -5,12 +5,52 @@
 #ifndef _ORINOCO_FW_H_
 #define _ORINOCO_FW_H_
 
-/* Forward declations */
-struct orinoco_private;
-

Don't remove the forward declaration, you introduce a dependency of this header on orinoco.h, which is otherwise unnecessary.

Quoted 18 lines
drivers/net/wireless/orinoco/fw.h +14 -2
 int orinoco_download(struct orinoco_private *priv);
 
-void orinoco_cache_fw(struct orinoco_private *priv, int ap);
-void orinoco_uncache_fw(struct orinoco_private *priv);
+#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)
+{
+	return priv->cached_fw;
+}
+
+static inline const struct firmware *
+orinoco_cached_pri_fw_get(struct orinoco_private *priv)
+{
+	return priv->cached_pri_fw;
+}
+
+static inline void

drivers/net/wireless/orinoco/fw.h line 33

Quoted 10 lines
drivers/net/wireless/orinoco/fw.h +10 -0
+orinoco_cached_fw_set(struct orinoco_private *priv, struct firmware *fw)
+{
+	priv->cached_fw = fw;
+}
+
+static inline void
+orinoco_cached_pri_fw_set(struct orinoco_private *priv, struct firmware *fw)
+{
+	priv->cached_pri_fw = fw;
+}

Ick. Only fw.c needs the _get calls so they should not be in the header. Because the _set makes the other half of the pair I would argue they don't want to be there either. I'd suggest adding orinoco_fw_init instead, which cleared both elements.

drivers/net/wireless/orinoco/fw.h line 36

Quoted 2 lines
drivers/net/wireless/orinoco/fw.h +2 -0
+extern void orinoco_cache_fw(struct orinoco_private *priv, int ap);
+extern void orinoco_uncache_fw(struct orinoco_private *priv);

Why do we want to make the extern explicit?

Quoted 14 lines
drivers/net/wireless/orinoco/main.c +2 -0
index f953059..2afab2a 100644
@@ -89,6 +89,8 @@
 #include <linux/ieee80211.h>
 #include <net/iw_handler.h>
 
+#include "orinoco.h"
+
 #include "hermes_rid.h"
 #include "hermes_dld.h"
 #include "hw.h"

drivers/net/wireless/orinoco/main.c line 102

Quoted 5 lines
drivers/net/wireless/orinoco/main.c +0 -2
@@ -98,8 +100,6 @@
 #include "wext.h"
 #include "main.h"
 
-#include "orinoco.h"
-

Suggest you don't move the inclusion forward. I don't know if it's just me, but I always keep the header which declares what the compilation unit exports as the final include. In this case that's orinoco.h.

If you really want to, do it in a separate patch so it isn't hidden away.

Dave.

#2 lore raw
Quoted 9 lines · On 15 of February 2009 20:21:19 Dave wrote:
Quoted 5 lines · Andrey Borzenkov

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.

I don't see much point, but...

It let me catch pm_notifiers errors at the very least :)

May be you are right; so if you NACK this one I won't object. But as long as time was already spent in it ...

Quoted 6 lines

Rather than fiddling with how we access the pointers, I think it would be better to refactor these if..elses into function calls like

fw_entry = orinoco_get_pri_fw(...);

#if CACHING

Quoted 9 lines
struct firmware *orinoco_get_pri_fw(...) {
    priv->cached_fw;
}
#else
struct firmware *orinoco_get_pri_fw(...) {
    return request_firmware(..);
}

#endif

Won't work. We do need to know whether fw is cached or not (to properly release it). And #ifdefs around if() statement are really unreadable.

Quoted 3 lines

Don't remove the forward declaration, you introduce a dependency of this header on orinoco.h, which is otherwise unnecessary.

No more required in this version.

Quoted 5 lines

Ick. Only fw.c needs the _get calls so they should not be in the header. Because the _set makes the other half of the pair I would argue they don't want to be there either. I'd suggest adding orinoco_fw_init instead, which cleared both elements.

I think in this case explicit #ifdef at the point of initialization makes it more clear.

Quoted 1 line

Suggest you don't move the inclusion forward.

Again no more needed in this version.

Let's test kmail again :)

Subject: [PATCH] orinoco: firmware: consistently compile out fw cache support if not requested
From: Andrey Borzenkov <[email protected]>

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.

---

 drivers/net/wireless/orinoco/fw.c      |   37 
+++++++++++++++++++++-----------
 drivers/net/wireless/orinoco/fw.h      |    9 ++++++--
 drivers/net/wireless/orinoco/main.c    |    4 +++
 drivers/net/wireless/orinoco/orinoco.h |    2 ++
 4 files changed, 36 insertions(+), 16 deletions(-)
(quoted diff) +0 -0

b/drivers/net/wireless/orinoco/fw.c
index 7d2292d..9bbc1dd 100644

drivers/net/wireless/orinoco/fw.c +23 -10
@@ -43,6 +43,19 @@ struct orinoco_fw_header {
 	char signature[0];      /* FW signature length headersize-20 */
 } __attribute__ ((packed));
 
+#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. */
 static int
 orinoco_dl_firmware(struct orinoco_private *priv,
@@ -79,7 +92,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 	if (err)
 		goto free;
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv, false)) {
 		err = request_firmware(&fw_entry, firmware, priv->dev);
 
 		if (err) {
@@ -89,7 +102,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 			goto free;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv, false);
 
 	hdr = (const struct orinoco_fw_header *) fw_entry->data;
 
@@ -132,7 +145,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 
 abort:
 	/* If we requested the firmware, release it. */
-	if (!priv->cached_fw)
+	if (!orinoco_cached_fw_get(priv, false))
 		release_firmware(fw_entry);
 
 free:
@@ -234,20 +247,20 @@ symbol_dl_firmware(struct orinoco_private *priv,
 	int ret;
 	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) {
 			printk(KERN_ERR "%s: Cannot find firmware: %s\n",
 			       dev->name, fw->pri_fw);
 			return -ENOENT;
 		}
 	} else
-		fw_entry = priv->cached_pri_fw;
+		fw_entry = orinoco_cached_fw_get(priv, true);
 
 	/* Load primary firmware */
 	ret = symbol_dl_image(priv, fw, fw_entry->data,
 			      fw_entry->data + fw_entry->size, 0);
 
-	if (!priv->cached_pri_fw)
+	if (!orinoco_cached_fw_get(priv, true))
 		release_firmware(fw_entry);
 	if (ret) {
 		printk(KERN_ERR "%s: Primary firmware download failed\n",
@@ -255,19 +268,19 @@ symbol_dl_firmware(struct orinoco_private *priv,
 		return ret;
 	}
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv, false)) {
 		if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) {
 			printk(KERN_ERR "%s: Cannot find firmware: %s\n",
 			       dev->name, fw->sta_fw);
 			return -ENOENT;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv, false);
 
 	/* Load secondary firmware */
 	ret = symbol_dl_image(priv, fw, fw_entry->data,
 			      fw_entry->data + fw_entry->size, 1);
-	if (!priv->cached_fw)
+	if (!orinoco_cached_fw_get(priv, false))
 		release_firmware(fw_entry);
 	if (ret) {
 		printk(KERN_ERR "%s: Secondary firmware download failed\n",
@@ -301,9 +314,9 @@ int orinoco_download(struct orinoco_private *priv)
 	return err;
 }
 
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 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 char *pri_fw;
 	const char *fw;
@@ -323,12 +336,10 @@ void orinoco_cache_fw(struct orinoco_private *priv, 

int ap)
if (request_firmware(&fw_entry, fw, priv->dev) == 0)
priv->cached_fw = fw_entry;
}
-#endif
}

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)
release_firmware(priv->cached_pri_fw);
if (priv->cached_fw)
@@ -336,5 +347,5 @@ void orinoco_uncache_fw(struct orinoco_private *priv)

priv->cached_pri_fw = NULL;
priv->cached_fw = NULL;
-#endif
}
+#endif

(quoted diff) +0 -0

b/drivers/net/wireless/orinoco/fw.h
index 2290f08..49eb9f8 100644

drivers/net/wireless/orinoco/fw.h +7 -2
@@ -10,7 +10,12 @@ struct orinoco_private;
 
 int orinoco_download(struct orinoco_private *priv);
 
-void orinoco_cache_fw(struct orinoco_private *priv, int ap);
-void orinoco_uncache_fw(struct orinoco_private *priv);
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
+extern void orinoco_cache_fw(struct orinoco_private *priv, int ap);
+extern 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_ */
(quoted diff) +0 -0

b/drivers/net/wireless/orinoco/main.c
index f953059..694e74b 100644

drivers/net/wireless/orinoco/main.c +3 -1
@@ -2580,8 +2580,10 @@ struct net_device
 	netif_carrier_off(dev);
 	priv->last_linkstatus = 0xffff;
 
-	priv->cached_pri_fw = NULL;
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 	priv->cached_fw = NULL;
+	priv->cached_pri_fw = NULL;
+#endif
 
 	/* Register PM notifiers */
 	orinoco_register_pm_notifier(priv);
(quoted diff) +0 -0

b/drivers/net/wireless/orinoco/orinoco.h
index f3f94b2..8e5a72c 100644

drivers/net/wireless/orinoco/orinoco.h +2 -0
@@ -159,9 +159,11 @@ struct orinoco_private {
 	unsigned int tkip_cm_active:1;
 	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. */
 	const struct firmware *cached_pri_fw;
 	const struct firmware *cached_fw;
+#endif
 
 	struct notifier_block pm_notifier;
 };
Acked-by
#3 lore raw
Quoted 8 lines · Andrey Borzenkov

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.

drivers/net/wireless/orinoco/fw.h struct orinoco_private; · line 13

Quoted 6 lines
drivers/net/wireless/orinoco/fw.h +3 -2
@@ -10,7 +10,12 @@ struct orinoco_private;
 
-void orinoco_cache_fw(struct orinoco_private *priv, int ap);
-void orinoco_uncache_fw(struct orinoco_private *priv);
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
+extern void orinoco_cache_fw(struct orinoco_private *priv, int ap);
+extern void orinoco_uncache_fw(struct orinoco_private *priv);

Please remove the explicit externs.

drivers/net/wireless/orinoco/main.c struct net_device · line 2584

Quoted 9 lines
drivers/net/wireless/orinoco/main.c +3 -1
@@ -2580,8 +2580,10 @@ struct net_device
 
-	priv->cached_pri_fw = NULL;
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 	priv->cached_fw = NULL;
+	priv->cached_pri_fw = NULL;
+#endif

Please leave the orderring alone.

These just minimize the changes and reduce potential for conflicts during rebases/merges.

#4 lore raw

PATCH v3 1/1 orinoco: firmware: consistently compile out fw cache support if not requested

Quoted 7 lines · On 21 февраля 2009 20:02:32 Dave wrote:
Quoted 4 lines

+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) +extern void orinoco_cache_fw(struct orinoco_private *priv, int ap); +extern void orinoco_uncache_fw(struct orinoco_private *priv);

Please remove the explicit externs.

OK

Quoted 4 lines
Quoted 4 lines
drivers/net/wireless/orinoco/main.c +0 -0
@@ -2580,8 +2580,10 @@ struct net_device
 
Quoted 8 lines

drivers/net/wireless/orinoco/main.c struct net_device · line 2584

Quoted 5 lines
drivers/net/wireless/orinoco/main.c +3 -1
-	priv->cached_pri_fw = NULL;
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) ||
 defined(CONFIG_PM_SLEEP) priv->cached_fw = NULL;
+	priv->cached_pri_fw = NULL;
+#endif

Please leave the orderring alone.

OK

Quoted 4 lines

These just minimize the changes and reduce potential for conflicts during rebases/merges.

Fixed version attached.

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.

---

 drivers/net/wireless/orinoco/fw.c      |   37 +++++++++++++++++++++-----------
 drivers/net/wireless/orinoco/fw.h      |    5 ++++
 drivers/net/wireless/orinoco/main.c    |    2 ++
 drivers/net/wireless/orinoco/orinoco.h |    2 ++
 4 files changed, 33 insertions(+), 13 deletions(-)
drivers/net/wireless/orinoco/fw.c +24 -13
index 7d2292d..9bbc1dd 100644
@@ -43,6 +43,19 @@ struct orinoco_fw_header {
 	char signature[0];      /* FW signature length headersize-20 */
 } __attribute__ ((packed));
 
+#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. */
 static int
 orinoco_dl_firmware(struct orinoco_private *priv,
@@ -79,7 +92,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 	if (err)
 		goto free;
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv, false)) {
 		err = request_firmware(&fw_entry, firmware, priv->dev);
 
 		if (err) {
@@ -89,7 +102,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 			goto free;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv, false);
 
 	hdr = (const struct orinoco_fw_header *) fw_entry->data;
 
@@ -132,7 +145,7 @@ orinoco_dl_firmware(struct orinoco_private *priv,
 
 abort:
 	/* If we requested the firmware, release it. */
-	if (!priv->cached_fw)
+	if (!orinoco_cached_fw_get(priv, false))
 		release_firmware(fw_entry);
 
 free:
@@ -234,20 +247,20 @@ symbol_dl_firmware(struct orinoco_private *priv,
 	int ret;
 	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) {
 			printk(KERN_ERR "%s: Cannot find firmware: %s\n",
 			       dev->name, fw->pri_fw);
 			return -ENOENT;
 		}
 	} else
-		fw_entry = priv->cached_pri_fw;
+		fw_entry = orinoco_cached_fw_get(priv, true);
 
 	/* Load primary firmware */
 	ret = symbol_dl_image(priv, fw, fw_entry->data,
 			      fw_entry->data + fw_entry->size, 0);
 
-	if (!priv->cached_pri_fw)
+	if (!orinoco_cached_fw_get(priv, true))
 		release_firmware(fw_entry);
 	if (ret) {
 		printk(KERN_ERR "%s: Primary firmware download failed\n",
@@ -255,19 +268,19 @@ symbol_dl_firmware(struct orinoco_private *priv,
 		return ret;
 	}
 
-	if (!priv->cached_fw) {
+	if (!orinoco_cached_fw_get(priv, false)) {
 		if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) {
 			printk(KERN_ERR "%s: Cannot find firmware: %s\n",
 			       dev->name, fw->sta_fw);
 			return -ENOENT;
 		}
 	} else
-		fw_entry = priv->cached_fw;
+		fw_entry = orinoco_cached_fw_get(priv, false);
 
 	/* Load secondary firmware */
 	ret = symbol_dl_image(priv, fw, fw_entry->data,
 			      fw_entry->data + fw_entry->size, 1);
-	if (!priv->cached_fw)
+	if (!orinoco_cached_fw_get(priv, false))
 		release_firmware(fw_entry);
 	if (ret) {
 		printk(KERN_ERR "%s: Secondary firmware download failed\n",
@@ -301,9 +314,9 @@ int orinoco_download(struct orinoco_private *priv)
 	return err;
 }
 
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 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 char *pri_fw;
 	const char *fw;
@@ -323,12 +336,10 @@ void orinoco_cache_fw(struct orinoco_private *priv, int ap)
 		if (request_firmware(&fw_entry, fw, priv->dev) == 0)
 			priv->cached_fw = fw_entry;
 	}
-#endif
 }
 
 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)
 		release_firmware(priv->cached_pri_fw);
 	if (priv->cached_fw)
@@ -336,5 +347,5 @@ void orinoco_uncache_fw(struct orinoco_private *priv)
 
 	priv->cached_pri_fw = NULL;
 	priv->cached_fw = NULL;
-#endif
 }
+#endif
drivers/net/wireless/orinoco/fw.h +5 -0
index 2290f08..89fc26d 100644
@@ -10,7 +10,12 @@ struct orinoco_private;
 
 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_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_ */
drivers/net/wireless/orinoco/main.c +2 -0
index f953059..0a0c96a 100644
@@ -2580,8 +2580,10 @@ struct net_device
 	netif_carrier_off(dev);
 	priv->last_linkstatus = 0xffff;
 
+#if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP)
 	priv->cached_pri_fw = NULL;
 	priv->cached_fw = NULL;
+#endif
 
 	/* Register PM notifiers */
 	orinoco_register_pm_notifier(priv);
drivers/net/wireless/orinoco/orinoco.h +2 -0
index f3f94b2..8e5a72c 100644
@@ -159,9 +159,11 @@ struct orinoco_private {
 	unsigned int tkip_cm_active:1;
 	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. */
 	const struct firmware *cached_pri_fw;
 	const struct firmware *cached_fw;
+#endif
 
 	struct notifier_block pm_notifier;
 };