aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2011-07-11 03:48:51 -0400
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2011-07-21 10:29:55 -0400
commitd593411084a56124aa9d80aafa15db8463b2d8f7 (patch)
treecbe550ecb8e7c0a7700e0ed168f1553c25b3d183
parent41c50542669cd7aec45ad708f5120ff8fdaa1194 (diff)
iwlagn: simplify the bus architecture
Call iwl_probe with a ready iwl_bus struct. This means that the bus layer assigns the irq, dev and iwl_bus_ops pointers to iwl_bus before giving it to iwl_probe. The device specific struct is allocated together with the common iwl_bus struct by the bus specific layer. The pointer to the aggregate struct is passed to the upper layer that holds a pointer to iwl_bus instead of an embedded iw_bus. The private data given to the PCI subsystem is now iwl_bus and not iwl_priv. Provide bus_* inliners on the way in order to simplify the syntax. Rename iwl-pci.h -> iwl-bus.h since it is bus agnostic and represent the external of the bus layer. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c31
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-bus.h (renamed from drivers/net/wireless/iwlwifi/iwl-pci.h)73
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debug.h8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h41
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-io.h7
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-led.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-pci.c64
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sv-open.c6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans.c38
14 files changed, 161 insertions, 140 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index d3163d8cf6d8..aee62d0726ab 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -55,7 +55,7 @@
55#include "iwl-sta.h" 55#include "iwl-sta.h"
56#include "iwl-agn-calib.h" 56#include "iwl-agn-calib.h"
57#include "iwl-agn.h" 57#include "iwl-agn.h"
58#include "iwl-pci.h" 58#include "iwl-bus.h"
59#include "iwl-trans.h" 59#include "iwl-trans.h"
60 60
61/****************************************************************************** 61/******************************************************************************
@@ -580,7 +580,7 @@ static struct attribute_group iwl_attribute_group = {
580static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc) 580static void iwl_free_fw_desc(struct iwl_priv *priv, struct fw_desc *desc)
581{ 581{
582 if (desc->v_addr) 582 if (desc->v_addr)
583 dma_free_coherent(priv->bus.dev, desc->len, 583 dma_free_coherent(priv->bus->dev, desc->len,
584 desc->v_addr, desc->p_addr); 584 desc->v_addr, desc->p_addr);
585 desc->v_addr = NULL; 585 desc->v_addr = NULL;
586 desc->len = 0; 586 desc->len = 0;
@@ -606,7 +606,7 @@ static int iwl_alloc_fw_desc(struct iwl_priv *priv, struct fw_desc *desc,
606 return -EINVAL; 606 return -EINVAL;
607 } 607 }
608 608
609 desc->v_addr = dma_alloc_coherent(priv->bus.dev, len, 609 desc->v_addr = dma_alloc_coherent(priv->bus->dev, len,
610 &desc->p_addr, GFP_KERNEL); 610 &desc->p_addr, GFP_KERNEL);
611 if (!desc->v_addr) 611 if (!desc->v_addr)
612 return -ENOMEM; 612 return -ENOMEM;
@@ -660,7 +660,7 @@ static int __must_check iwl_request_firmware(struct iwl_priv *priv, bool first)
660 priv->firmware_name); 660 priv->firmware_name);
661 661
662 return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, 662 return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name,
663 priv->bus.dev, 663 priv->bus->dev,
664 GFP_KERNEL, priv, iwl_ucode_callback); 664 GFP_KERNEL, priv, iwl_ucode_callback);
665} 665}
666 666
@@ -1163,7 +1163,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1163 if (err) 1163 if (err)
1164 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); 1164 IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err);
1165 1165
1166 err = sysfs_create_group(&(priv->bus.dev->kobj), 1166 err = sysfs_create_group(&(priv->bus->dev->kobj),
1167 &iwl_attribute_group); 1167 &iwl_attribute_group);
1168 if (err) { 1168 if (err) {
1169 IWL_ERR(priv, "failed to create sysfs device attributes\n"); 1169 IWL_ERR(priv, "failed to create sysfs device attributes\n");
@@ -1187,7 +1187,7 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context)
1187 iwl_dealloc_ucode(priv); 1187 iwl_dealloc_ucode(priv);
1188 out_unbind: 1188 out_unbind:
1189 complete(&priv->_agn.firmware_loading_complete); 1189 complete(&priv->_agn.firmware_loading_complete);
1190 device_release_driver(priv->bus.dev); 1190 device_release_driver(priv->bus->dev);
1191 release_firmware(ucode_raw); 1191 release_firmware(ucode_raw);
1192} 1192}
1193 1193
@@ -3102,8 +3102,7 @@ static void iwl_init_context(struct iwl_priv *priv)
3102 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2); 3102 BUILD_BUG_ON(NUM_IWL_RXON_CTX != 2);
3103} 3103}
3104 3104
3105int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, 3105int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg)
3106 struct iwl_cfg *cfg)
3107{ 3106{
3108 int err = 0; 3107 int err = 0;
3109 struct iwl_priv *priv; 3108 struct iwl_priv *priv;
@@ -3121,17 +3120,12 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3121 } 3120 }
3122 3121
3123 priv = hw->priv; 3122 priv = hw->priv;
3124 3123 priv->bus = bus;
3125 priv->bus.priv = priv; 3124 bus_set_drv_data(priv->bus, priv);
3126 priv->bus.bus_specific = bus_specific;
3127 priv->bus.ops = bus_ops;
3128 priv->bus.irq = priv->bus.ops->get_irq(&priv->bus);
3129 priv->bus.ops->set_drv_data(&priv->bus, priv);
3130 priv->bus.dev = priv->bus.ops->get_dev(&priv->bus);
3131 3125
3132 /* At this point both hw and priv are allocated. */ 3126 /* At this point both hw and priv are allocated. */
3133 3127
3134 SET_IEEE80211_DEV(hw, priv->bus.dev); 3128 SET_IEEE80211_DEV(hw, priv->bus->dev);
3135 3129
3136 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); 3130 IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n");
3137 priv->cfg = cfg; 3131 priv->cfg = cfg;
@@ -3154,7 +3148,6 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3154 if (iwl_alloc_traffic_mem(priv)) 3148 if (iwl_alloc_traffic_mem(priv))
3155 IWL_ERR(priv, "Not enough memory to generate traffic log\n"); 3149 IWL_ERR(priv, "Not enough memory to generate traffic log\n");
3156 3150
3157
3158 /* these spin locks will be used in apm_ops.init and EEPROM access 3151 /* these spin locks will be used in apm_ops.init and EEPROM access
3159 * we should init now 3152 * we should init now
3160 */ 3153 */
@@ -3289,7 +3282,7 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3289 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); 3282 IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n");
3290 3283
3291 iwl_dbgfs_unregister(priv); 3284 iwl_dbgfs_unregister(priv);
3292 sysfs_remove_group(&priv->bus.dev->kobj, 3285 sysfs_remove_group(&priv->bus->dev->kobj,
3293 &iwl_attribute_group); 3286 &iwl_attribute_group);
3294 3287
3295 /* ieee80211_unregister_hw call wil cause iwl_mac_stop to 3288 /* ieee80211_unregister_hw call wil cause iwl_mac_stop to
@@ -3339,7 +3332,7 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3339 3332
3340 trans_free(&priv->trans); 3333 trans_free(&priv->trans);
3341 3334
3342 priv->bus.ops->set_drv_data(&priv->bus, NULL); 3335 bus_set_drv_data(priv->bus, NULL);
3343 3336
3344 iwl_uninit_drv(priv); 3337 iwl_uninit_drv(priv);
3345 3338
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index 496ab99c424d..78dccde88aaf 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -336,8 +336,7 @@ void iwl_testmode_cleanup(struct iwl_priv *priv)
336} 336}
337#endif 337#endif
338 338
339int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops, 339int iwl_probe(struct iwl_bus *bus, struct iwl_cfg *cfg);
340 struct iwl_cfg *cfg);
341void __devexit iwl_remove(struct iwl_priv * priv); 340void __devexit iwl_remove(struct iwl_priv * priv);
342 341
343#endif /* __iwl_agn_h__ */ 342#endif /* __iwl_agn_h__ */
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.h b/drivers/net/wireless/iwlwifi/iwl-bus.h
index 9396c7c8d6a4..fef62e6c2c88 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.h
+++ b/drivers/net/wireless/iwlwifi/iwl-bus.h
@@ -63,6 +63,79 @@
63#ifndef __iwl_pci_h__ 63#ifndef __iwl_pci_h__
64#define __iwl_pci_h__ 64#define __iwl_pci_h__
65 65
66struct iwl_bus;
67
68/**
69 * struct iwl_bus_ops - bus specific operations
70
71 * @get_pm_support: must returns true if the bus can go to sleep
72 * @apm_config: will be called during the config of the APM configuration
73 * @set_drv_data: set the priv pointer to the bus layer
74 * @get_hw_id: prints the hw_id in the provided buffer
75 * @write8: write a byte to register at offset ofs
76 * @write32: write a dword to register at offset ofs
77 * @wread32: read a dword at register at offset ofs
78 */
79struct iwl_bus_ops {
80 bool (*get_pm_support)(struct iwl_bus *bus);
81 void (*apm_config)(struct iwl_bus *bus);
82 void (*set_drv_data)(struct iwl_bus *bus, void *drv_data);
83 void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len);
84 void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
85 void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
86 u32 (*read32)(struct iwl_bus *bus, u32 ofs);
87};
88
89struct iwl_bus {
90 /* Common data to all buses */
91
92 /*TODO: priv should be void * */
93 struct iwl_priv *priv; /* driver's context */
94 struct device *dev;
95 struct iwl_bus_ops *ops;
96
97 unsigned int irq;
98
99 /* pointer to bus specific struct */
100 /*Ensure that this pointer will always be aligned to sizeof pointer */
101 char bus_specific[0] __attribute__((__aligned__(sizeof(void *))));
102};
103
104static inline bool bus_get_pm_support(struct iwl_bus *bus)
105{
106 return bus->ops->get_pm_support(bus);
107}
108
109static inline void bus_apm_config(struct iwl_bus *bus)
110{
111 bus->ops->apm_config(bus);
112}
113
114static inline void bus_set_drv_data(struct iwl_bus *bus, void *drv_data)
115{
116 bus->ops->set_drv_data(bus, drv_data);
117}
118
119static inline void bus_get_hw_id(struct iwl_bus *bus, char buf[], int buf_len)
120{
121 bus->ops->get_hw_id(bus, buf, buf_len);
122}
123
124static inline void bus_write8(struct iwl_bus *bus, u32 ofs, u8 val)
125{
126 bus->ops->write8(bus, ofs, val);
127}
128
129static inline void bus_write32(struct iwl_bus *bus, u32 ofs, u32 val)
130{
131 bus->ops->write32(bus, ofs, val);
132}
133
134static inline u32 bus_read32(struct iwl_bus *bus, u32 ofs)
135{
136 return bus->ops->read32(bus, ofs);
137}
138
66int __must_check iwl_pci_register_driver(void); 139int __must_check iwl_pci_register_driver(void);
67void iwl_pci_unregister_driver(void); 140void iwl_pci_unregister_driver(void);
68 141
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index a2a95bace84a..3be011137d03 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -211,7 +211,7 @@ int iwlcore_init_geos(struct iwl_priv *priv)
211 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && 211 if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) &&
212 priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) { 212 priv->cfg->sku & EEPROM_SKU_CAP_BAND_52GHZ) {
213 char buf[32]; 213 char buf[32];
214 priv->bus.ops->get_hw_id(&priv->bus, buf, sizeof(buf)); 214 bus_get_hw_id(priv->bus, buf, sizeof(buf));
215 IWL_INFO(priv, "Incorrectly detected BG card as ABG. " 215 IWL_INFO(priv, "Incorrectly detected BG card as ABG. "
216 "Please send your %s to maintainer.\n", buf); 216 "Please send your %s to maintainer.\n", buf);
217 priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ; 217 priv->cfg->sku &= ~EEPROM_SKU_CAP_BAND_52GHZ;
@@ -1012,7 +1012,7 @@ int iwl_apm_init(struct iwl_priv *priv)
1012 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1012 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1013 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); 1013 CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A);
1014 1014
1015 priv->bus.ops->apm_config(&priv->bus); 1015 bus_apm_config(priv->bus);
1016 1016
1017 /* Configure analog phase-lock-loop before activating to D0A */ 1017 /* Configure analog phase-lock-loop before activating to D0A */
1018 if (priv->cfg->base_params->pll_cfg_val) 1018 if (priv->cfg->base_params->pll_cfg_val)
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h
index eb95d1a37487..4529e2ddbbc9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debug.h
+++ b/drivers/net/wireless/iwlwifi/iwl-debug.h
@@ -32,10 +32,10 @@
32struct iwl_priv; 32struct iwl_priv;
33extern u32 iwl_debug_level; 33extern u32 iwl_debug_level;
34 34
35#define IWL_ERR(p, f, a...) dev_err(p->bus.ops->get_dev(&p->bus), f, ## a) 35#define IWL_ERR(p, f, a...) dev_err(p->bus->dev, f, ## a)
36#define IWL_WARN(p, f, a...) dev_warn(p->bus.ops->get_dev(&p->bus), f, ## a) 36#define IWL_WARN(p, f, a...) dev_warn(p->bus->dev, f, ## a)
37#define IWL_INFO(p, f, a...) dev_info(p->bus.ops->get_dev(&p->bus), f, ## a) 37#define IWL_INFO(p, f, a...) dev_info(p->bus->dev, f, ## a)
38#define IWL_CRIT(p, f, a...) dev_crit(p->bus.ops->get_dev(&p->bus), f, ## a) 38#define IWL_CRIT(p, f, a...) dev_crit(p->bus->dev, f, ## a)
39 39
40#define iwl_print_hex_error(priv, p, len) \ 40#define iwl_print_hex_error(priv, p, len) \
41do { \ 41do { \
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index a89b40a585cf..964be5795c50 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -47,6 +47,7 @@
47#include "iwl-power.h" 47#include "iwl-power.h"
48#include "iwl-agn-rs.h" 48#include "iwl-agn-rs.h"
49#include "iwl-agn-tt.h" 49#include "iwl-agn-tt.h"
50#include "iwl-bus.h"
50#include "iwl-trans.h" 51#include "iwl-trans.h"
51 52
52#define DRV_NAME "iwlagn" 53#define DRV_NAME "iwlagn"
@@ -1193,44 +1194,6 @@ struct iwl_testmode_trace {
1193}; 1194};
1194#endif 1195#endif
1195 1196
1196struct iwl_bus;
1197
1198/**
1199 * struct iwl_bus_ops - bus specific operations
1200
1201 * @get_pm_support: must returns true if the bus can go to sleep
1202 * @apm_config: will be called during the config of the APM configuration
1203 * @set_drv_data: set the priv pointer to the bus layer
1204 * @get_dev: returns the device struct
1205 * @get_irq: returns the irq number
1206 * @get_hw_id: prints the hw_id in the provided buffer
1207 * @write8: write a byte to register at offset ofs
1208 * @write32: write a dword to register at offset ofs
1209 * @wread32: read a dword at register at offset ofs
1210 */
1211struct iwl_bus_ops {
1212 bool (*get_pm_support)(struct iwl_bus *bus);
1213 void (*apm_config)(struct iwl_bus *bus);
1214 void (*set_drv_data)(struct iwl_bus *bus, void *priv);
1215 struct device *(*get_dev)(const struct iwl_bus *bus);
1216 unsigned int (*get_irq)(const struct iwl_bus *bus);
1217 void (*get_hw_id)(struct iwl_bus *bus, char buf[], int buf_len);
1218 void (*write8)(struct iwl_bus *bus, u32 ofs, u8 val);
1219 void (*write32)(struct iwl_bus *bus, u32 ofs, u32 val);
1220 u32 (*read32)(struct iwl_bus *bus, u32 ofs);
1221};
1222
1223struct iwl_bus {
1224 /* pointer to bus specific struct */
1225 void *bus_specific;
1226
1227 /* Common data to all buses */
1228 struct iwl_priv *priv; /* driver's context */
1229 struct device *dev;
1230 struct iwl_bus_ops *ops;
1231 unsigned int irq;
1232};
1233
1234/* uCode ownership */ 1197/* uCode ownership */
1235#define IWL_OWNERSHIP_DRIVER 0 1198#define IWL_OWNERSHIP_DRIVER 0
1236#define IWL_OWNERSHIP_TM 1 1199#define IWL_OWNERSHIP_TM 1
@@ -1302,7 +1265,7 @@ struct iwl_priv {
1302 spinlock_t reg_lock; /* protect hw register access */ 1265 spinlock_t reg_lock; /* protect hw register access */
1303 struct mutex mutex; 1266 struct mutex mutex;
1304 1267
1305 struct iwl_bus bus; /* bus specific data */ 1268 struct iwl_bus *bus; /* bus specific data */
1306 struct iwl_trans trans; 1269 struct iwl_trans trans;
1307 1270
1308 /* microcode/device supports multiple contexts */ 1271 /* microcode/device supports multiple contexts */
diff --git a/drivers/net/wireless/iwlwifi/iwl-io.h b/drivers/net/wireless/iwlwifi/iwl-io.h
index c56eae74c3cd..19a093101122 100644
--- a/drivers/net/wireless/iwlwifi/iwl-io.h
+++ b/drivers/net/wireless/iwlwifi/iwl-io.h
@@ -34,22 +34,23 @@
34#include "iwl-dev.h" 34#include "iwl-dev.h"
35#include "iwl-debug.h" 35#include "iwl-debug.h"
36#include "iwl-devtrace.h" 36#include "iwl-devtrace.h"
37#include "iwl-bus.h"
37 38
38static inline void iwl_write8(struct iwl_priv *priv, u32 ofs, u8 val) 39static inline void iwl_write8(struct iwl_priv *priv, u32 ofs, u8 val)
39{ 40{
40 trace_iwlwifi_dev_iowrite8(priv, ofs, val); 41 trace_iwlwifi_dev_iowrite8(priv, ofs, val);
41 priv->bus.ops->write8(&priv->bus, ofs, val); 42 bus_write8(priv->bus, ofs, val);
42} 43}
43 44
44static inline void iwl_write32(struct iwl_priv *priv, u32 ofs, u32 val) 45static inline void iwl_write32(struct iwl_priv *priv, u32 ofs, u32 val)
45{ 46{
46 trace_iwlwifi_dev_iowrite32(priv, ofs, val); 47 trace_iwlwifi_dev_iowrite32(priv, ofs, val);
47 priv->bus.ops->write32(&priv->bus, ofs, val); 48 bus_write32(priv->bus, ofs, val);
48} 49}
49 50
50static inline u32 iwl_read32(struct iwl_priv *priv, u32 ofs) 51static inline u32 iwl_read32(struct iwl_priv *priv, u32 ofs)
51{ 52{
52 u32 val = priv->bus.ops->read32(&priv->bus, ofs); 53 u32 val = bus_read32(priv->bus, ofs);
53 trace_iwlwifi_dev_ioread32(priv, ofs, val); 54 trace_iwlwifi_dev_ioread32(priv, ofs, val);
54 return val; 55 return val;
55} 56}
diff --git a/drivers/net/wireless/iwlwifi/iwl-led.c b/drivers/net/wireless/iwlwifi/iwl-led.c
index 75663c12e99f..a67ae56d5464 100644
--- a/drivers/net/wireless/iwlwifi/iwl-led.c
+++ b/drivers/net/wireless/iwlwifi/iwl-led.c
@@ -203,7 +203,7 @@ void iwl_leds_init(struct iwl_priv *priv)
203 break; 203 break;
204 } 204 }
205 205
206 ret = led_classdev_register(priv->bus.dev, 206 ret = led_classdev_register(priv->bus->dev,
207 &priv->led); 207 &priv->led);
208 if (ret) { 208 if (ret) {
209 kfree(priv->led.name); 209 kfree(priv->led.name);
diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c
index 74911348a2ee..66448895f7ba 100644
--- a/drivers/net/wireless/iwlwifi/iwl-pci.c
+++ b/drivers/net/wireless/iwlwifi/iwl-pci.c
@@ -63,11 +63,10 @@
63#include <linux/pci.h> 63#include <linux/pci.h>
64#include <linux/pci-aspm.h> 64#include <linux/pci-aspm.h>
65 65
66#include "iwl-pci.h" 66#include "iwl-bus.h"
67#include "iwl-agn.h" 67#include "iwl-agn.h"
68#include "iwl-core.h" 68#include "iwl-core.h"
69#include "iwl-io.h" 69#include "iwl-io.h"
70#include "iwl-trans.h"
71 70
72/* PCI registers */ 71/* PCI registers */
73#define PCI_CFG_RETRY_TIMEOUT 0x041 72#define PCI_CFG_RETRY_TIMEOUT 0x041
@@ -132,19 +131,9 @@ static void iwl_pci_apm_config(struct iwl_bus *bus)
132 } 131 }
133} 132}
134 133
135static void iwl_pci_set_drv_data(struct iwl_bus *bus, void *drv_priv) 134static void iwl_pci_set_drv_data(struct iwl_bus *bus, void *drv_data)
136{ 135{
137 pci_set_drvdata(IWL_BUS_GET_PCI_DEV(bus), drv_priv); 136 bus->priv = drv_data;
138}
139
140static struct device *iwl_pci_get_dev(const struct iwl_bus *bus)
141{
142 return &(IWL_BUS_GET_PCI_DEV(bus)->dev);
143}
144
145static unsigned int iwl_pci_get_irq(const struct iwl_bus *bus)
146{
147 return IWL_BUS_GET_PCI_DEV(bus)->irq;
148} 137}
149 138
150static void iwl_pci_get_hw_id(struct iwl_bus *bus, char buf[], 139static void iwl_pci_get_hw_id(struct iwl_bus *bus, char buf[],
@@ -176,8 +165,6 @@ static struct iwl_bus_ops pci_ops = {
176 .get_pm_support = iwl_pci_is_pm_supported, 165 .get_pm_support = iwl_pci_is_pm_supported,
177 .apm_config = iwl_pci_apm_config, 166 .apm_config = iwl_pci_apm_config,
178 .set_drv_data = iwl_pci_set_drv_data, 167 .set_drv_data = iwl_pci_set_drv_data,
179 .get_dev = iwl_pci_get_dev,
180 .get_irq = iwl_pci_get_irq,
181 .get_hw_id = iwl_pci_get_hw_id, 168 .get_hw_id = iwl_pci_get_hw_id,
182 .write8 = iwl_pci_write8, 169 .write8 = iwl_pci_write8,
183 .write32 = iwl_pci_write32, 170 .write32 = iwl_pci_write32,
@@ -383,18 +370,20 @@ MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
383static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) 370static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
384{ 371{
385 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); 372 struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
386 struct iwl_pci_bus *bus; 373 struct iwl_bus *bus;
374 struct iwl_pci_bus *pci_bus;
387 u16 pci_cmd; 375 u16 pci_cmd;
388 int err; 376 int err;
389 377
390 bus = kzalloc(sizeof(*bus), GFP_KERNEL); 378 bus = kzalloc(sizeof(*bus) + sizeof(*pci_bus), GFP_KERNEL);
391 if (!bus) { 379 if (!bus) {
392 pr_err("Couldn't allocate iwl_pci_bus"); 380 pr_err("Couldn't allocate iwl_pci_bus");
393 err = -ENOMEM; 381 err = -ENOMEM;
394 goto out_no_pci; 382 goto out_no_pci;
395 } 383 }
396 384
397 bus->pci_dev = pdev; 385 pci_bus = IWL_BUS_GET_PCI_BUS(bus);
386 pci_bus->pci_dev = pdev;
398 387
399 /* W/A - seems to solve weird behavior. We need to remove this if we 388 /* W/A - seems to solve weird behavior. We need to remove this if we
400 * don't want to stay in L1 all the time. This wastes a lot of power */ 389 * don't want to stay in L1 all the time. This wastes a lot of power */
@@ -429,8 +418,8 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
429 goto out_pci_disable_device; 418 goto out_pci_disable_device;
430 } 419 }
431 420
432 bus->hw_base = pci_iomap(pdev, 0, 0); 421 pci_bus->hw_base = pci_iomap(pdev, 0, 0);
433 if (!bus->hw_base) { 422 if (!pci_bus->hw_base) {
434 pr_err("pci_iomap failed"); 423 pr_err("pci_iomap failed");
435 err = -ENODEV; 424 err = -ENODEV;
436 goto out_pci_release_regions; 425 goto out_pci_release_regions;
@@ -438,7 +427,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
438 427
439 pr_info("pci_resource_len = 0x%08llx\n", 428 pr_info("pci_resource_len = 0x%08llx\n",
440 (unsigned long long) pci_resource_len(pdev, 0)); 429 (unsigned long long) pci_resource_len(pdev, 0));
441 pr_info("pci_resource_base = %p\n", bus->hw_base); 430 pr_info("pci_resource_base = %p\n", pci_bus->hw_base);
442 431
443 pr_info("HW Revision ID = 0x%X\n", pdev->revision); 432 pr_info("HW Revision ID = 0x%X\n", pdev->revision);
444 433
@@ -460,7 +449,13 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
460 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); 449 pci_write_config_word(pdev, PCI_COMMAND, pci_cmd);
461 } 450 }
462 451
463 err = iwl_probe((void *) bus, &pci_ops, cfg); 452 pci_set_drvdata(pdev, bus);
453
454 bus->dev = &pdev->dev;
455 bus->irq = pdev->irq;
456 bus->ops = &pci_ops;
457
458 err = iwl_probe(bus, cfg);
464 if (err) 459 if (err)
465 goto out_disable_msi; 460 goto out_disable_msi;
466 return 0; 461 return 0;
@@ -468,7 +463,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
468out_disable_msi: 463out_disable_msi:
469 pci_disable_msi(pdev); 464 pci_disable_msi(pdev);
470out_iounmap: 465out_iounmap:
471 pci_iounmap(pdev, bus->hw_base); 466 pci_iounmap(pdev, pci_bus->hw_base);
472out_pci_release_regions: 467out_pci_release_regions:
473 pci_set_drvdata(pdev, NULL); 468 pci_set_drvdata(pdev, NULL);
474 pci_release_regions(pdev); 469 pci_release_regions(pdev);
@@ -479,9 +474,9 @@ out_no_pci:
479 return err; 474 return err;
480} 475}
481 476
482static void iwl_pci_down(void *bus) 477static void iwl_pci_down(struct iwl_bus *bus)
483{ 478{
484 struct iwl_pci_bus *pci_bus = (struct iwl_pci_bus *) bus; 479 struct iwl_pci_bus *pci_bus = (struct iwl_pci_bus *) bus->bus_specific;
485 480
486 pci_disable_msi(pci_bus->pci_dev); 481 pci_disable_msi(pci_bus->pci_dev);
487 pci_iounmap(pci_bus->pci_dev, pci_bus->hw_base); 482 pci_iounmap(pci_bus->pci_dev, pci_bus->hw_base);
@@ -489,17 +484,16 @@ static void iwl_pci_down(void *bus)
489 pci_disable_device(pci_bus->pci_dev); 484 pci_disable_device(pci_bus->pci_dev);
490 pci_set_drvdata(pci_bus->pci_dev, NULL); 485 pci_set_drvdata(pci_bus->pci_dev, NULL);
491 486
492 kfree(pci_bus); 487 kfree(bus);
493} 488}
494 489
495static void __devexit iwl_pci_remove(struct pci_dev *pdev) 490static void __devexit iwl_pci_remove(struct pci_dev *pdev)
496{ 491{
497 struct iwl_priv *priv = pci_get_drvdata(pdev); 492 struct iwl_bus *bus = pci_get_drvdata(pdev);
498 void *bus_specific = priv->bus.bus_specific;
499 493
500 iwl_remove(priv); 494 iwl_remove(bus->priv);
501 495
502 iwl_pci_down(bus_specific); 496 iwl_pci_down(bus);
503} 497}
504 498
505#ifdef CONFIG_PM 499#ifdef CONFIG_PM
@@ -507,15 +501,15 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
507static int iwl_pci_suspend(struct device *device) 501static int iwl_pci_suspend(struct device *device)
508{ 502{
509 struct pci_dev *pdev = to_pci_dev(device); 503 struct pci_dev *pdev = to_pci_dev(device);
510 struct iwl_priv *priv = pci_get_drvdata(pdev); 504 struct iwl_bus *bus = pci_get_drvdata(pdev);
511 505
512 return iwl_suspend(priv); 506 return iwl_suspend(bus->priv);
513} 507}
514 508
515static int iwl_pci_resume(struct device *device) 509static int iwl_pci_resume(struct device *device)
516{ 510{
517 struct pci_dev *pdev = to_pci_dev(device); 511 struct pci_dev *pdev = to_pci_dev(device);
518 struct iwl_priv *priv = pci_get_drvdata(pdev); 512 struct iwl_bus *bus = pci_get_drvdata(pdev);
519 513
520 /* 514 /*
521 * We disable the RETRY_TIMEOUT register (0x41) to keep 515 * We disable the RETRY_TIMEOUT register (0x41) to keep
@@ -523,7 +517,7 @@ static int iwl_pci_resume(struct device *device)
523 */ 517 */
524 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); 518 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
525 519
526 return iwl_resume(priv); 520 return iwl_resume(bus->priv);
527} 521}
528 522
529static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume); 523static SIMPLE_DEV_PM_OPS(iwl_dev_pm_ops, iwl_pci_suspend, iwl_pci_resume);
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 7c99f432996d..de4f33304edb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -432,7 +432,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
432/* initialize to default */ 432/* initialize to default */
433void iwl_power_initialize(struct iwl_priv *priv) 433void iwl_power_initialize(struct iwl_priv *priv)
434{ 434{
435 priv->power_data.bus_pm = priv->bus.ops->get_pm_support(&priv->bus); 435 priv->power_data.bus_pm = bus_get_pm_support(priv->bus);
436 436
437 priv->power_data.debug_sleep_level_override = -1; 437 priv->power_data.debug_sleep_level_override = -1;
438 438
diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c
index d47483561a8f..b11f60de4f1e 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c
@@ -181,12 +181,10 @@ void iwl_testmode_init(struct iwl_priv *priv)
181 181
182static void iwl_trace_cleanup(struct iwl_priv *priv) 182static void iwl_trace_cleanup(struct iwl_priv *priv)
183{ 183{
184 struct device *dev = priv->bus.dev;
185
186 if (priv->testmode_trace.trace_enabled) { 184 if (priv->testmode_trace.trace_enabled) {
187 if (priv->testmode_trace.cpu_addr && 185 if (priv->testmode_trace.cpu_addr &&
188 priv->testmode_trace.dma_addr) 186 priv->testmode_trace.dma_addr)
189 dma_free_coherent(dev, 187 dma_free_coherent(priv->bus->dev,
190 priv->testmode_trace.total_size, 188 priv->testmode_trace.total_size,
191 priv->testmode_trace.cpu_addr, 189 priv->testmode_trace.cpu_addr,
192 priv->testmode_trace.dma_addr); 190 priv->testmode_trace.dma_addr);
@@ -486,7 +484,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb)
486 struct iwl_priv *priv = hw->priv; 484 struct iwl_priv *priv = hw->priv;
487 struct sk_buff *skb; 485 struct sk_buff *skb;
488 int status = 0; 486 int status = 0;
489 struct device *dev = priv->bus.dev; 487 struct device *dev = priv->bus->dev;
490 488
491 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { 489 switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) {
492 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: 490 case IWL_TM_CMD_APP2DEV_BEGIN_TRACE:
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
index d5b9adfc3cce..74343589f284 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-rx-pcie.c
@@ -305,7 +305,7 @@ static void iwlagn_rx_allocate(struct iwl_priv *priv, gfp_t priority)
305 BUG_ON(rxb->page); 305 BUG_ON(rxb->page);
306 rxb->page = page; 306 rxb->page = page;
307 /* Get physical address of the RB */ 307 /* Get physical address of the RB */
308 rxb->page_dma = dma_map_page(priv->bus.dev, page, 0, 308 rxb->page_dma = dma_map_page(priv->bus->dev, page, 0,
309 PAGE_SIZE << priv->hw_params.rx_page_order, 309 PAGE_SIZE << priv->hw_params.rx_page_order,
310 DMA_FROM_DEVICE); 310 DMA_FROM_DEVICE);
311 /* dma address must be no more than 36 bits */ 311 /* dma address must be no more than 36 bits */
@@ -404,7 +404,7 @@ static void iwl_rx_handle(struct iwl_priv *priv)
404 404
405 rxq->queue[i] = NULL; 405 rxq->queue[i] = NULL;
406 406
407 dma_unmap_page(priv->bus.dev, rxb->page_dma, 407 dma_unmap_page(priv->bus->dev, rxb->page_dma,
408 PAGE_SIZE << priv->hw_params.rx_page_order, 408 PAGE_SIZE << priv->hw_params.rx_page_order,
409 DMA_FROM_DEVICE); 409 DMA_FROM_DEVICE);
410 pkt = rxb_addr(rxb); 410 pkt = rxb_addr(rxb);
@@ -455,7 +455,7 @@ static void iwl_rx_handle(struct iwl_priv *priv)
455 * rx_free list for reuse later. */ 455 * rx_free list for reuse later. */
456 spin_lock_irqsave(&rxq->lock, flags); 456 spin_lock_irqsave(&rxq->lock, flags);
457 if (rxb->page != NULL) { 457 if (rxb->page != NULL) {
458 rxb->page_dma = dma_map_page(priv->bus.dev, rxb->page, 458 rxb->page_dma = dma_map_page(priv->bus->dev, rxb->page,
459 0, PAGE_SIZE << priv->hw_params.rx_page_order, 459 0, PAGE_SIZE << priv->hw_params.rx_page_order,
460 DMA_FROM_DEVICE); 460 DMA_FROM_DEVICE);
461 list_add_tail(&rxb->list, &rxq->rx_free); 461 list_add_tail(&rxb->list, &rxq->rx_free);
@@ -704,7 +704,7 @@ void iwl_irq_tasklet(struct iwl_priv *priv)
704void iwl_free_isr_ict(struct iwl_priv *priv) 704void iwl_free_isr_ict(struct iwl_priv *priv)
705{ 705{
706 if (priv->_agn.ict_tbl_vir) { 706 if (priv->_agn.ict_tbl_vir) {
707 dma_free_coherent(priv->bus.dev, 707 dma_free_coherent(priv->bus->dev,
708 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE, 708 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
709 priv->_agn.ict_tbl_vir, 709 priv->_agn.ict_tbl_vir,
710 priv->_agn.ict_tbl_dma); 710 priv->_agn.ict_tbl_dma);
@@ -725,7 +725,7 @@ int iwl_alloc_isr_ict(struct iwl_priv *priv)
725 725
726 /* allocate shrared data table */ 726 /* allocate shrared data table */
727 priv->_agn.ict_tbl_vir = 727 priv->_agn.ict_tbl_vir =
728 dma_alloc_coherent(priv->bus.dev, 728 dma_alloc_coherent(priv->bus->dev,
729 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE, 729 (sizeof(u32) * ICT_COUNT) + PAGE_SIZE,
730 &priv->_agn.ict_tbl_dma, GFP_KERNEL); 730 &priv->_agn.ict_tbl_dma, GFP_KERNEL);
731 if (!priv->_agn.ict_tbl_vir) 731 if (!priv->_agn.ict_tbl_vir)
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
index 7dac6ee23250..27f78fed2ec2 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-tx-pcie.c
@@ -182,14 +182,14 @@ static void iwlagn_unmap_tfd(struct iwl_priv *priv, struct iwl_cmd_meta *meta,
182 182
183 /* Unmap tx_cmd */ 183 /* Unmap tx_cmd */
184 if (num_tbs) 184 if (num_tbs)
185 dma_unmap_single(priv->bus.dev, 185 dma_unmap_single(priv->bus->dev,
186 dma_unmap_addr(meta, mapping), 186 dma_unmap_addr(meta, mapping),
187 dma_unmap_len(meta, len), 187 dma_unmap_len(meta, len),
188 DMA_BIDIRECTIONAL); 188 DMA_BIDIRECTIONAL);
189 189
190 /* Unmap chunks, if any. */ 190 /* Unmap chunks, if any. */
191 for (i = 1; i < num_tbs; i++) 191 for (i = 1; i < num_tbs; i++)
192 dma_unmap_single(priv->bus.dev, iwl_tfd_tb_get_addr(tfd, i), 192 dma_unmap_single(priv->bus->dev, iwl_tfd_tb_get_addr(tfd, i),
193 iwl_tfd_tb_get_len(tfd, i), dma_dir); 193 iwl_tfd_tb_get_len(tfd, i), dma_dir);
194} 194}
195 195
@@ -640,9 +640,9 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
640 le16_to_cpu(out_cmd->hdr.sequence), cmd_size, 640 le16_to_cpu(out_cmd->hdr.sequence), cmd_size,
641 q->write_ptr, idx, priv->cmd_queue); 641 q->write_ptr, idx, priv->cmd_queue);
642 642
643 phys_addr = dma_map_single(priv->bus.dev, &out_cmd->hdr, copy_size, 643 phys_addr = dma_map_single(priv->bus->dev, &out_cmd->hdr, copy_size,
644 DMA_BIDIRECTIONAL); 644 DMA_BIDIRECTIONAL);
645 if (unlikely(dma_mapping_error(priv->bus.dev, phys_addr))) { 645 if (unlikely(dma_mapping_error(priv->bus->dev, phys_addr))) {
646 idx = -ENOMEM; 646 idx = -ENOMEM;
647 goto out; 647 goto out;
648 } 648 }
@@ -662,9 +662,9 @@ static int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
662 continue; 662 continue;
663 if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY)) 663 if (!(cmd->dataflags[i] & IWL_HCMD_DFL_NOCOPY))
664 continue; 664 continue;
665 phys_addr = dma_map_single(priv->bus.dev, (void *)cmd->data[i], 665 phys_addr = dma_map_single(priv->bus->dev, (void *)cmd->data[i],
666 cmd->len[i], DMA_BIDIRECTIONAL); 666 cmd->len[i], DMA_BIDIRECTIONAL);
667 if (dma_mapping_error(priv->bus.dev, phys_addr)) { 667 if (dma_mapping_error(priv->bus->dev, phys_addr)) {
668 iwlagn_unmap_tfd(priv, out_meta, 668 iwlagn_unmap_tfd(priv, out_meta,
669 &txq->tfds[q->write_ptr], 669 &txq->tfds[q->write_ptr],
670 DMA_BIDIRECTIONAL); 670 DMA_BIDIRECTIONAL);
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.c b/drivers/net/wireless/iwlwifi/iwl-trans.c
index edd28f00dab5..582ab1b8e734 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans.c
@@ -72,7 +72,7 @@
72static int iwl_trans_rx_alloc(struct iwl_priv *priv) 72static int iwl_trans_rx_alloc(struct iwl_priv *priv)
73{ 73{
74 struct iwl_rx_queue *rxq = &priv->rxq; 74 struct iwl_rx_queue *rxq = &priv->rxq;
75 struct device *dev = priv->bus.dev; 75 struct device *dev = priv->bus->dev;
76 76
77 memset(&priv->rxq, 0, sizeof(priv->rxq)); 77 memset(&priv->rxq, 0, sizeof(priv->rxq));
78 78
@@ -118,7 +118,7 @@ static void iwl_trans_rxq_free_rx_bufs(struct iwl_priv *priv)
118 /* In the reset function, these buffers may have been allocated 118 /* In the reset function, these buffers may have been allocated
119 * to an SKB, so we need to unmap and free potential storage */ 119 * to an SKB, so we need to unmap and free potential storage */
120 if (rxq->pool[i].page != NULL) { 120 if (rxq->pool[i].page != NULL) {
121 dma_unmap_page(priv->bus.dev, rxq->pool[i].page_dma, 121 dma_unmap_page(priv->bus->dev, rxq->pool[i].page_dma,
122 PAGE_SIZE << priv->hw_params.rx_page_order, 122 PAGE_SIZE << priv->hw_params.rx_page_order,
123 DMA_FROM_DEVICE); 123 DMA_FROM_DEVICE);
124 __iwl_free_pages(priv, rxq->pool[i].page); 124 __iwl_free_pages(priv, rxq->pool[i].page);
@@ -233,13 +233,13 @@ static void iwl_trans_rx_free(struct iwl_priv *priv)
233 iwl_trans_rxq_free_rx_bufs(priv); 233 iwl_trans_rxq_free_rx_bufs(priv);
234 spin_unlock_irqrestore(&rxq->lock, flags); 234 spin_unlock_irqrestore(&rxq->lock, flags);
235 235
236 dma_free_coherent(priv->bus.dev, sizeof(__le32) * RX_QUEUE_SIZE, 236 dma_free_coherent(priv->bus->dev, sizeof(__le32) * RX_QUEUE_SIZE,
237 rxq->bd, rxq->bd_dma); 237 rxq->bd, rxq->bd_dma);
238 memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma)); 238 memset(&rxq->bd_dma, 0, sizeof(rxq->bd_dma));
239 rxq->bd = NULL; 239 rxq->bd = NULL;
240 240
241 if (rxq->rb_stts) 241 if (rxq->rb_stts)
242 dma_free_coherent(priv->bus.dev, 242 dma_free_coherent(priv->bus->dev,
243 sizeof(struct iwl_rb_status), 243 sizeof(struct iwl_rb_status),
244 rxq->rb_stts, rxq->rb_stts_dma); 244 rxq->rb_stts, rxq->rb_stts_dma);
245 else 245 else
@@ -263,7 +263,7 @@ static inline int iwlagn_alloc_dma_ptr(struct iwl_priv *priv,
263 if (WARN_ON(ptr->addr)) 263 if (WARN_ON(ptr->addr))
264 return -EINVAL; 264 return -EINVAL;
265 265
266 ptr->addr = dma_alloc_coherent(priv->bus.dev, size, 266 ptr->addr = dma_alloc_coherent(priv->bus->dev, size,
267 &ptr->dma, GFP_KERNEL); 267 &ptr->dma, GFP_KERNEL);
268 if (!ptr->addr) 268 if (!ptr->addr)
269 return -ENOMEM; 269 return -ENOMEM;
@@ -277,7 +277,7 @@ static inline void iwlagn_free_dma_ptr(struct iwl_priv *priv,
277 if (unlikely(!ptr->addr)) 277 if (unlikely(!ptr->addr))
278 return; 278 return;
279 279
280 dma_free_coherent(priv->bus.dev, ptr->size, ptr->addr, ptr->dma); 280 dma_free_coherent(priv->bus->dev, ptr->size, ptr->addr, ptr->dma);
281 memset(ptr, 0, sizeof(*ptr)); 281 memset(ptr, 0, sizeof(*ptr));
282} 282}
283 283
@@ -324,7 +324,7 @@ static int iwl_trans_txq_alloc(struct iwl_priv *priv, struct iwl_tx_queue *txq,
324 324
325 /* Circular buffer of transmit frame descriptors (TFDs), 325 /* Circular buffer of transmit frame descriptors (TFDs),
326 * shared with device */ 326 * shared with device */
327 txq->tfds = dma_alloc_coherent(priv->bus.dev, tfd_sz, &txq->q.dma_addr, 327 txq->tfds = dma_alloc_coherent(priv->bus->dev, tfd_sz, &txq->q.dma_addr,
328 GFP_KERNEL); 328 GFP_KERNEL);
329 if (!txq->tfds) { 329 if (!txq->tfds) {
330 IWL_ERR(priv, "dma_alloc_coherent(%zd) failed\n", tfd_sz); 330 IWL_ERR(priv, "dma_alloc_coherent(%zd) failed\n", tfd_sz);
@@ -415,7 +415,7 @@ static void iwl_tx_queue_unmap(struct iwl_priv *priv, int txq_id)
415static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id) 415static void iwl_tx_queue_free(struct iwl_priv *priv, int txq_id)
416{ 416{
417 struct iwl_tx_queue *txq = &priv->txq[txq_id]; 417 struct iwl_tx_queue *txq = &priv->txq[txq_id];
418 struct device *dev = priv->bus.dev; 418 struct device *dev = priv->bus->dev;
419 int i; 419 int i;
420 if (WARN_ON(!txq)) 420 if (WARN_ON(!txq))
421 return; 421 return;
@@ -1016,10 +1016,10 @@ static int iwl_trans_tx(struct iwl_priv *priv, struct sk_buff *skb,
1016 1016
1017 /* Physical address of this Tx command's header (not MAC header!), 1017 /* Physical address of this Tx command's header (not MAC header!),
1018 * within command buffer array. */ 1018 * within command buffer array. */
1019 txcmd_phys = dma_map_single(priv->bus.dev, 1019 txcmd_phys = dma_map_single(priv->bus->dev,
1020 &dev_cmd->hdr, firstlen, 1020 &dev_cmd->hdr, firstlen,
1021 DMA_BIDIRECTIONAL); 1021 DMA_BIDIRECTIONAL);
1022 if (unlikely(dma_mapping_error(priv->bus.dev, txcmd_phys))) 1022 if (unlikely(dma_mapping_error(priv->bus->dev, txcmd_phys)))
1023 return -1; 1023 return -1;
1024 dma_unmap_addr_set(out_meta, mapping, txcmd_phys); 1024 dma_unmap_addr_set(out_meta, mapping, txcmd_phys);
1025 dma_unmap_len_set(out_meta, len, firstlen); 1025 dma_unmap_len_set(out_meta, len, firstlen);
@@ -1035,10 +1035,10 @@ static int iwl_trans_tx(struct iwl_priv *priv, struct sk_buff *skb,
1035 * if any (802.11 null frames have no payload). */ 1035 * if any (802.11 null frames have no payload). */
1036 secondlen = skb->len - hdr_len; 1036 secondlen = skb->len - hdr_len;
1037 if (secondlen > 0) { 1037 if (secondlen > 0) {
1038 phys_addr = dma_map_single(priv->bus.dev, skb->data + hdr_len, 1038 phys_addr = dma_map_single(priv->bus->dev, skb->data + hdr_len,
1039 secondlen, DMA_TO_DEVICE); 1039 secondlen, DMA_TO_DEVICE);
1040 if (unlikely(dma_mapping_error(priv->bus.dev, phys_addr))) { 1040 if (unlikely(dma_mapping_error(priv->bus->dev, phys_addr))) {
1041 dma_unmap_single(priv->bus.dev, 1041 dma_unmap_single(priv->bus->dev,
1042 dma_unmap_addr(out_meta, mapping), 1042 dma_unmap_addr(out_meta, mapping),
1043 dma_unmap_len(out_meta, len), 1043 dma_unmap_len(out_meta, len),
1044 DMA_BIDIRECTIONAL); 1044 DMA_BIDIRECTIONAL);
@@ -1056,7 +1056,7 @@ static int iwl_trans_tx(struct iwl_priv *priv, struct sk_buff *skb,
1056 offsetof(struct iwl_tx_cmd, scratch); 1056 offsetof(struct iwl_tx_cmd, scratch);
1057 1057
1058 /* take back ownership of DMA buffer to enable update */ 1058 /* take back ownership of DMA buffer to enable update */
1059 dma_sync_single_for_cpu(priv->bus.dev, txcmd_phys, firstlen, 1059 dma_sync_single_for_cpu(priv->bus->dev, txcmd_phys, firstlen,
1060 DMA_BIDIRECTIONAL); 1060 DMA_BIDIRECTIONAL);
1061 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); 1061 tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys);
1062 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys); 1062 tx_cmd->dram_msb_ptr = iwl_get_dma_hi_addr(scratch_phys);
@@ -1072,7 +1072,7 @@ static int iwl_trans_tx(struct iwl_priv *priv, struct sk_buff *skb,
1072 iwl_trans_txq_update_byte_cnt_tbl(priv, txq, 1072 iwl_trans_txq_update_byte_cnt_tbl(priv, txq,
1073 le16_to_cpu(tx_cmd->len)); 1073 le16_to_cpu(tx_cmd->len));
1074 1074
1075 dma_sync_single_for_device(priv->bus.dev, txcmd_phys, firstlen, 1075 dma_sync_single_for_device(priv->bus->dev, txcmd_phys, firstlen,
1076 DMA_BIDIRECTIONAL); 1076 DMA_BIDIRECTIONAL);
1077 1077
1078 trace_iwlwifi_dev_tx(priv, 1078 trace_iwlwifi_dev_tx(priv,
@@ -1111,13 +1111,13 @@ static void iwl_trans_kick_nic(struct iwl_priv *priv)
1111static void iwl_trans_sync_irq(struct iwl_priv *priv) 1111static void iwl_trans_sync_irq(struct iwl_priv *priv)
1112{ 1112{
1113 /* wait to make sure we flush pending tasklet*/ 1113 /* wait to make sure we flush pending tasklet*/
1114 synchronize_irq(priv->bus.irq); 1114 synchronize_irq(priv->bus->irq);
1115 tasklet_kill(&priv->irq_tasklet); 1115 tasklet_kill(&priv->irq_tasklet);
1116} 1116}
1117 1117
1118static void iwl_trans_free(struct iwl_priv *priv) 1118static void iwl_trans_free(struct iwl_priv *priv)
1119{ 1119{
1120 free_irq(priv->bus.irq, priv); 1120 free_irq(priv->bus->irq, priv);
1121 iwl_free_isr_ict(priv); 1121 iwl_free_isr_ict(priv);
1122} 1122}
1123 1123
@@ -1155,10 +1155,10 @@ int iwl_trans_register(struct iwl_trans *trans, struct iwl_priv *priv)
1155 1155
1156 iwl_alloc_isr_ict(priv); 1156 iwl_alloc_isr_ict(priv);
1157 1157
1158 err = request_irq(priv->bus.irq, iwl_isr_ict, IRQF_SHARED, 1158 err = request_irq(priv->bus->irq, iwl_isr_ict, IRQF_SHARED,
1159 DRV_NAME, priv); 1159 DRV_NAME, priv);
1160 if (err) { 1160 if (err) {
1161 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->bus.irq); 1161 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->bus->irq);
1162 iwl_free_isr_ict(priv); 1162 iwl_free_isr_ict(priv);
1163 return err; 1163 return err;
1164 } 1164 }