summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/iwlwifi/iwl-shared.h
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2011-08-25 23:10:37 -0700
committerJohn W. Linville <linville@tuxdriver.com>2011-08-29 15:25:30 -0400
commitcac988a682d45d07276fef1cc1e035ef86d39849 (patch)
treec9c1b2ec69bd19676e7040755cc4b1ea5db8b231 /drivers/net/wireless/iwlwifi/iwl-shared.h
parent48f20d354e729afcfb29ff41aca7583ebb94613d (diff)
downloadlwn-cac988a682d45d07276fef1cc1e035ef86d39849.tar.gz
lwn-cac988a682d45d07276fef1cc1e035ef86d39849.zip
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>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-shared.h')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-shared.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h
index 5d48d059fcd8..32744a72a6ac 100644
--- a/drivers/net/wireless/iwlwifi/iwl-shared.h
+++ b/drivers/net/wireless/iwlwifi/iwl-shared.h
@@ -64,6 +64,7 @@
#define __iwl_shared_h__
struct iwl_cfg;
+struct iwl_bus;
struct iwl_priv;
extern struct iwl_mod_params iwlagn_mod_params;
@@ -89,6 +90,21 @@ struct iwl_mod_params {
int wanted_ucode_alternative;
};
+/**
+ * struct iwl_shared - shared fields for all the layers of the driver
+ *
+ * @bus: pointer to the bus layer data
+ * @priv: pointer to the upper layer data
+ */
+struct iwl_shared {
+ struct iwl_bus *bus;
+ struct iwl_priv *priv;
+};
+
+/*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */
+#define priv(_m) ((_m)->shrd->priv)
+#define bus(_m) ((_m)->shrd->bus)
+
#ifdef CONFIG_PM
int iwl_suspend(struct iwl_priv *priv);
int iwl_resume(struct iwl_priv *priv);