summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-bus.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-bus.h
parent48f20d354e729afcfb29ff41aca7583ebb94613d (diff)
downloadtalos-op-linux-cac988a682d45d07276fef1cc1e035ef86d39849.tar.gz
talos-op-linux-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-bus.h')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-bus.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-bus.h b/drivers/net/wireless/iwlwifi/iwl-bus.h
index f3ee1c0c004c..a69800485c5c 100644
--- a/drivers/net/wireless/iwlwifi/iwl-bus.h
+++ b/drivers/net/wireless/iwlwifi/iwl-bus.h
@@ -63,13 +63,14 @@
#ifndef __iwl_pci_h__
#define __iwl_pci_h__
+struct iwl_shared;
struct iwl_bus;
/**
* struct iwl_bus_ops - bus specific operations
* @get_pm_support: must returns true if the bus can go to sleep
* @apm_config: will be called during the config of the APM configuration
- * @set_drv_data: set the drv_data pointer to the bus layer
+ * @set_drv_data: set the shared data pointer to the bus layer
* @get_hw_id: prints the hw_id in the provided buffer
* @write8: write a byte to register at offset ofs
* @write32: write a dword to register at offset ofs
@@ -78,7 +79,7 @@ struct iwl_bus;
struct iwl_bus_ops {
bool (*get_pm_support)(struct iwl_bus *bus);
void (*apm_config)(struct iwl_bus *bus);
- void (*set_drv_data)(struct iwl_bus *bus, void *drv_data);
+ void (*set_drv_data)(struct iwl_bus *bus, struct iwl_shared *shrd);
void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len);
void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
@@ -87,9 +88,9 @@ struct iwl_bus_ops {
struct iwl_bus {
/* Common data to all buses */
- void *drv_data; /* driver's context */
struct device *dev;
struct iwl_bus_ops *ops;
+ struct iwl_shared *shrd;
unsigned int irq;
@@ -108,9 +109,10 @@ static inline void bus_apm_config(struct iwl_bus *bus)
bus->ops->apm_config(bus);
}
-static inline void bus_set_drv_data(struct iwl_bus *bus, void *drv_data)
+static inline void bus_set_drv_data(struct iwl_bus *bus,
+ struct iwl_shared *shrd)
{
- bus->ops->set_drv_data(bus, drv_data);
+ bus->ops->set_drv_data(bus, shrd);
}
static inline void bus_get_hw_id(struct iwl_bus *bus, char buf[], int buf_len)
OpenPOWER on IntegriCloud