iwlagn: introduce struct iwl-shared - known by all layers

This struct will hold pointers to all the layers, so that every layer will find
the pointers it needs when calling another layer.

Note that the drv_data set to struct device is now a pointer to
struct iwl_shared.
This solves of bug that I introduced in

	iwlagn: simplify the bus architecture

Bug description:

sysfs gets the the driver data from struct device. Till the aforementioned
patch, dev_get_drvdata would return iwl_priv. After the patch, dev_get_drvdata
return iwl_bus which is buggy since the sysfs handlers rely on this value, and
sysfs handlers need iwl_priv.

Now, dev_get_drvdata return iwl-shared. Since we have pointers to all the
layers in iwl_shared, every layer will be able to get the pointer it needs:
bus layer will gets iwl_bus from the PCI suspend callbacks, and the sysfs
handlers will get the iwl_priv they need.

In order to keep good encapsulation, we need to avoid to dereference iwl_priv
from a different layer. This is why instead of including iwl-dev.h from
iwl-shared.h, I added a forward declaration to iwl_priv. Moreover we keep type
safety while providing encapsulation.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index cb8a9f9..39e7bdb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -473,14 +473,15 @@
 static ssize_t show_debug_level(struct device *d,
 				struct device_attribute *attr, char *buf)
 {
-	struct iwl_priv *priv = dev_get_drvdata(d);
-	return sprintf(buf, "0x%08X\n", iwl_get_debug_level(priv));
+	struct iwl_shared *shrd = dev_get_drvdata(d);
+	return sprintf(buf, "0x%08X\n", iwl_get_debug_level(shrd->priv));
 }
 static ssize_t store_debug_level(struct device *d,
 				struct device_attribute *attr,
 				 const char *buf, size_t count)
 {
-	struct iwl_priv *priv = dev_get_drvdata(d);
+	struct iwl_shared *shrd = dev_get_drvdata(d);
+	struct iwl_priv *priv = shrd->priv;
 	unsigned long val;
 	int ret;
 
@@ -506,7 +507,8 @@
 static ssize_t show_temperature(struct device *d,
 				struct device_attribute *attr, char *buf)
 {
-	struct iwl_priv *priv = dev_get_drvdata(d);
+	struct iwl_shared *shrd = dev_get_drvdata(d);
+	struct iwl_priv *priv = shrd->priv;
 
 	if (!iwl_is_alive(priv))
 		return -EAGAIN;
@@ -3603,7 +3605,10 @@
 
 	priv = hw->priv;
 	priv->bus = bus;
-	bus_set_drv_data(priv->bus, priv);
+	priv->shrd = &priv->_shrd;
+	priv->shrd->bus = bus;
+	priv->shrd->priv = priv;
+	bus_set_drv_data(priv->bus, priv->shrd);
 
 	/* At this point both hw and priv are allocated. */