diff options
author | Gertjan van Wingerde <gwingerde@kpnplanet.nl> | 2008-06-16 13:55:43 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-06-26 16:49:15 -0400 |
commit | 14a3bf89212b5c758bd39bb4afc972c4ba6d599f (patch) | |
tree | 8ea03c6d2c69a0875c69fd13b4ecd772456cf710 /drivers/net/wireless/rt2x00/rt2x00pci.c | |
parent | c95edf5432f097c926dd3f59239ecde80da3b214 (diff) |
rt2x00: Convert rt2x00 to use generic DMA-mapping API
At the same time clean up the device administration a bit, by storing a pointer
to struct device instead of a void pointer that is dependent on the type of
device. The normal PCI and USB subsystem provided macros can be used to convert
the device pointer to the right type.
This makes the rt2x00 driver a bit more type-safe.
Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00pci.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00pci.c b/drivers/net/wireless/rt2x00/rt2x00pci.c index 8d6ad18d3890..d6138389a5d0 100644 --- a/drivers/net/wireless/rt2x00/rt2x00pci.c +++ b/drivers/net/wireless/rt2x00/rt2x00pci.c | |||
@@ -194,7 +194,6 @@ EXPORT_SYMBOL_GPL(rt2x00pci_txdone); | |||
194 | static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | 194 | static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, |
195 | struct data_queue *queue) | 195 | struct data_queue *queue) |
196 | { | 196 | { |
197 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | ||
198 | struct queue_entry_priv_pci *entry_priv; | 197 | struct queue_entry_priv_pci *entry_priv; |
199 | void *addr; | 198 | void *addr; |
200 | dma_addr_t dma; | 199 | dma_addr_t dma; |
@@ -203,7 +202,8 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
203 | /* | 202 | /* |
204 | * Allocate DMA memory for descriptor and buffer. | 203 | * Allocate DMA memory for descriptor and buffer. |
205 | */ | 204 | */ |
206 | addr = pci_alloc_consistent(pci_dev, dma_size(queue), &dma); | 205 | addr = dma_alloc_coherent(rt2x00dev->dev, dma_size(queue), &dma, |
206 | GFP_KERNEL | GFP_DMA); | ||
207 | if (!addr) | 207 | if (!addr) |
208 | return -ENOMEM; | 208 | return -ENOMEM; |
209 | 209 | ||
@@ -226,19 +226,18 @@ static int rt2x00pci_alloc_queue_dma(struct rt2x00_dev *rt2x00dev, | |||
226 | static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev, | 226 | static void rt2x00pci_free_queue_dma(struct rt2x00_dev *rt2x00dev, |
227 | struct data_queue *queue) | 227 | struct data_queue *queue) |
228 | { | 228 | { |
229 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | ||
230 | struct queue_entry_priv_pci *entry_priv = | 229 | struct queue_entry_priv_pci *entry_priv = |
231 | queue->entries[0].priv_data; | 230 | queue->entries[0].priv_data; |
232 | 231 | ||
233 | if (entry_priv->data) | 232 | if (entry_priv->data) |
234 | pci_free_consistent(pci_dev, dma_size(queue), | 233 | dma_free_coherent(rt2x00dev->dev, dma_size(queue), |
235 | entry_priv->data, entry_priv->data_dma); | 234 | entry_priv->data, entry_priv->data_dma); |
236 | entry_priv->data = NULL; | 235 | entry_priv->data = NULL; |
237 | } | 236 | } |
238 | 237 | ||
239 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) | 238 | int rt2x00pci_initialize(struct rt2x00_dev *rt2x00dev) |
240 | { | 239 | { |
241 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 240 | struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); |
242 | struct data_queue *queue; | 241 | struct data_queue *queue; |
243 | int status; | 242 | int status; |
244 | 243 | ||
@@ -279,7 +278,7 @@ void rt2x00pci_uninitialize(struct rt2x00_dev *rt2x00dev) | |||
279 | /* | 278 | /* |
280 | * Free irq line. | 279 | * Free irq line. |
281 | */ | 280 | */ |
282 | free_irq(rt2x00dev_pci(rt2x00dev)->irq, rt2x00dev); | 281 | free_irq(to_pci_dev(rt2x00dev->dev)->irq, rt2x00dev); |
283 | 282 | ||
284 | /* | 283 | /* |
285 | * Free DMA | 284 | * Free DMA |
@@ -308,7 +307,7 @@ static void rt2x00pci_free_reg(struct rt2x00_dev *rt2x00dev) | |||
308 | 307 | ||
309 | static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) | 308 | static int rt2x00pci_alloc_reg(struct rt2x00_dev *rt2x00dev) |
310 | { | 309 | { |
311 | struct pci_dev *pci_dev = rt2x00dev_pci(rt2x00dev); | 310 | struct pci_dev *pci_dev = to_pci_dev(rt2x00dev->dev); |
312 | 311 | ||
313 | rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), | 312 | rt2x00dev->csr.base = ioremap(pci_resource_start(pci_dev, 0), |
314 | pci_resource_len(pci_dev, 0)); | 313 | pci_resource_len(pci_dev, 0)); |
@@ -357,7 +356,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) | |||
357 | if (pci_set_mwi(pci_dev)) | 356 | if (pci_set_mwi(pci_dev)) |
358 | ERROR_PROBE("MWI not available.\n"); | 357 | ERROR_PROBE("MWI not available.\n"); |
359 | 358 | ||
360 | if (pci_set_dma_mask(pci_dev, DMA_32BIT_MASK)) { | 359 | if (dma_set_mask(&pci_dev->dev, DMA_32BIT_MASK)) { |
361 | ERROR_PROBE("PCI DMA not supported.\n"); | 360 | ERROR_PROBE("PCI DMA not supported.\n"); |
362 | retval = -EIO; | 361 | retval = -EIO; |
363 | goto exit_disable_device; | 362 | goto exit_disable_device; |
@@ -373,7 +372,7 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id) | |||
373 | pci_set_drvdata(pci_dev, hw); | 372 | pci_set_drvdata(pci_dev, hw); |
374 | 373 | ||
375 | rt2x00dev = hw->priv; | 374 | rt2x00dev = hw->priv; |
376 | rt2x00dev->dev = pci_dev; | 375 | rt2x00dev->dev = &pci_dev->dev; |
377 | rt2x00dev->ops = ops; | 376 | rt2x00dev->ops = ops; |
378 | rt2x00dev->hw = hw; | 377 | rt2x00dev->hw = hw; |
379 | 378 | ||