diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2009-01-14 14:17:03 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:00:29 -0500 |
commit | 7da3c55ce849e17fd9017c7bf770a03fa083d95b (patch) | |
tree | 9832274615883cbb3e3f383ca258d37b1fce4f62 /drivers/net/wireless/ath9k | |
parent | f5870acb3a8e2cad57b6c5ffd3157a7dfbb47942 (diff) |
ath9k: convert to use bus-agnostic DMA routines
Convert to use bus-agnostic DMA routines to make it usable on AHB bus as well.
Changes-licensed-under: ISC
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Tested-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k')
-rw-r--r-- | drivers/net/wireless/ath9k/beacon.c | 31 | ||||
-rw-r--r-- | drivers/net/wireless/ath9k/main.c | 13 | ||||
-rw-r--r-- | drivers/net/wireless/ath9k/recv.c | 27 | ||||
-rw-r--r-- | drivers/net/wireless/ath9k/xmit.c | 15 |
4 files changed, 38 insertions, 48 deletions
diff --git a/drivers/net/wireless/ath9k/beacon.c b/drivers/net/wireless/ath9k/beacon.c index f02b099d3e3a..be1d84a5dafb 100644 --- a/drivers/net/wireless/ath9k/beacon.c +++ b/drivers/net/wireless/ath9k/beacon.c | |||
@@ -164,9 +164,9 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id) | |||
164 | bf = avp->av_bcbuf; | 164 | bf = avp->av_bcbuf; |
165 | skb = (struct sk_buff *)bf->bf_mpdu; | 165 | skb = (struct sk_buff *)bf->bf_mpdu; |
166 | if (skb) { | 166 | if (skb) { |
167 | pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext, | 167 | dma_unmap_single(sc->dev, bf->bf_dmacontext, |
168 | skb->len, | 168 | skb->len, |
169 | PCI_DMA_TODEVICE); | 169 | DMA_TO_DEVICE); |
170 | dev_kfree_skb_any(skb); | 170 | dev_kfree_skb_any(skb); |
171 | } | 171 | } |
172 | 172 | ||
@@ -188,15 +188,14 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | bf->bf_buf_addr = bf->bf_dmacontext = | 190 | bf->bf_buf_addr = bf->bf_dmacontext = |
191 | pci_map_single(to_pci_dev(sc->dev), skb->data, | 191 | dma_map_single(sc->dev, skb->data, |
192 | skb->len, | 192 | skb->len, |
193 | PCI_DMA_TODEVICE); | 193 | DMA_TO_DEVICE); |
194 | if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev), | 194 | if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { |
195 | bf->bf_buf_addr))) { | ||
196 | dev_kfree_skb_any(skb); | 195 | dev_kfree_skb_any(skb); |
197 | bf->bf_mpdu = NULL; | 196 | bf->bf_mpdu = NULL; |
198 | DPRINTF(sc, ATH_DBG_CONFIG, | 197 | DPRINTF(sc, ATH_DBG_CONFIG, |
199 | "pci_dma_mapping_error() on beaconing\n"); | 198 | "dma_mapping_error() on beaconing\n"); |
200 | return NULL; | 199 | return NULL; |
201 | } | 200 | } |
202 | 201 | ||
@@ -344,9 +343,9 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id) | |||
344 | bf = avp->av_bcbuf; | 343 | bf = avp->av_bcbuf; |
345 | if (bf->bf_mpdu != NULL) { | 344 | if (bf->bf_mpdu != NULL) { |
346 | skb = (struct sk_buff *)bf->bf_mpdu; | 345 | skb = (struct sk_buff *)bf->bf_mpdu; |
347 | pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext, | 346 | dma_unmap_single(sc->dev, bf->bf_dmacontext, |
348 | skb->len, | 347 | skb->len, |
349 | PCI_DMA_TODEVICE); | 348 | DMA_TO_DEVICE); |
350 | dev_kfree_skb_any(skb); | 349 | dev_kfree_skb_any(skb); |
351 | bf->bf_mpdu = NULL; | 350 | bf->bf_mpdu = NULL; |
352 | } | 351 | } |
@@ -403,15 +402,14 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id) | |||
403 | 402 | ||
404 | bf->bf_mpdu = skb; | 403 | bf->bf_mpdu = skb; |
405 | bf->bf_buf_addr = bf->bf_dmacontext = | 404 | bf->bf_buf_addr = bf->bf_dmacontext = |
406 | pci_map_single(to_pci_dev(sc->dev), skb->data, | 405 | dma_map_single(sc->dev, skb->data, |
407 | skb->len, | 406 | skb->len, |
408 | PCI_DMA_TODEVICE); | 407 | DMA_TO_DEVICE); |
409 | if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev), | 408 | if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) { |
410 | bf->bf_buf_addr))) { | ||
411 | dev_kfree_skb_any(skb); | 409 | dev_kfree_skb_any(skb); |
412 | bf->bf_mpdu = NULL; | 410 | bf->bf_mpdu = NULL; |
413 | DPRINTF(sc, ATH_DBG_CONFIG, | 411 | DPRINTF(sc, ATH_DBG_CONFIG, |
414 | "pci_dma_mapping_error() on beacon alloc\n"); | 412 | "dma_mapping_error() on beacon alloc\n"); |
415 | return -ENOMEM; | 413 | return -ENOMEM; |
416 | } | 414 | } |
417 | 415 | ||
@@ -431,10 +429,9 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp) | |||
431 | bf = avp->av_bcbuf; | 429 | bf = avp->av_bcbuf; |
432 | if (bf->bf_mpdu != NULL) { | 430 | if (bf->bf_mpdu != NULL) { |
433 | struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu; | 431 | struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu; |
434 | pci_unmap_single(to_pci_dev(sc->dev), | 432 | dma_unmap_single(sc->dev, bf->bf_dmacontext, |
435 | bf->bf_dmacontext, | ||
436 | skb->len, | 433 | skb->len, |
437 | PCI_DMA_TODEVICE); | 434 | DMA_TO_DEVICE); |
438 | dev_kfree_skb_any(skb); | 435 | dev_kfree_skb_any(skb); |
439 | bf->bf_mpdu = NULL; | 436 | bf->bf_mpdu = NULL; |
440 | } | 437 | } |
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c index 44931e42e2ba..ebf0467674cf 100644 --- a/drivers/net/wireless/ath9k/main.c +++ b/drivers/net/wireless/ath9k/main.c | |||
@@ -1715,9 +1715,8 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, | |||
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | /* allocate descriptors */ | 1717 | /* allocate descriptors */ |
1718 | dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev), | 1718 | dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len, |
1719 | dd->dd_desc_len, | 1719 | &dd->dd_desc_paddr, GFP_ATOMIC); |
1720 | &dd->dd_desc_paddr); | ||
1721 | if (dd->dd_desc == NULL) { | 1720 | if (dd->dd_desc == NULL) { |
1722 | error = -ENOMEM; | 1721 | error = -ENOMEM; |
1723 | goto fail; | 1722 | goto fail; |
@@ -1763,8 +1762,8 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, | |||
1763 | } | 1762 | } |
1764 | return 0; | 1763 | return 0; |
1765 | fail2: | 1764 | fail2: |
1766 | pci_free_consistent(to_pci_dev(sc->dev), | 1765 | dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc, |
1767 | dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr); | 1766 | dd->dd_desc_paddr); |
1768 | fail: | 1767 | fail: |
1769 | memset(dd, 0, sizeof(*dd)); | 1768 | memset(dd, 0, sizeof(*dd)); |
1770 | return error; | 1769 | return error; |
@@ -1777,8 +1776,8 @@ void ath_descdma_cleanup(struct ath_softc *sc, | |||
1777 | struct ath_descdma *dd, | 1776 | struct ath_descdma *dd, |
1778 | struct list_head *head) | 1777 | struct list_head *head) |
1779 | { | 1778 | { |
1780 | pci_free_consistent(to_pci_dev(sc->dev), | 1779 | dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc, |
1781 | dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr); | 1780 | dd->dd_desc_paddr); |
1782 | 1781 | ||
1783 | INIT_LIST_HEAD(head); | 1782 | INIT_LIST_HEAD(head); |
1784 | kfree(dd->dd_bufptr); | 1783 | kfree(dd->dd_bufptr); |
diff --git a/drivers/net/wireless/ath9k/recv.c b/drivers/net/wireless/ath9k/recv.c index 645fae2f49d8..648bb49e6734 100644 --- a/drivers/net/wireless/ath9k/recv.c +++ b/drivers/net/wireless/ath9k/recv.c | |||
@@ -291,16 +291,15 @@ int ath_rx_init(struct ath_softc *sc, int nbufs) | |||
291 | } | 291 | } |
292 | 292 | ||
293 | bf->bf_mpdu = skb; | 293 | bf->bf_mpdu = skb; |
294 | bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev), | 294 | bf->bf_buf_addr = dma_map_single(sc->dev, skb->data, |
295 | skb->data, | ||
296 | sc->rx.bufsize, | 295 | sc->rx.bufsize, |
297 | PCI_DMA_FROMDEVICE); | 296 | DMA_FROM_DEVICE); |
298 | if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev), | 297 | if (unlikely(dma_mapping_error(sc->dev, |
299 | bf->bf_buf_addr))) { | 298 | bf->bf_buf_addr))) { |
300 | dev_kfree_skb_any(skb); | 299 | dev_kfree_skb_any(skb); |
301 | bf->bf_mpdu = NULL; | 300 | bf->bf_mpdu = NULL; |
302 | DPRINTF(sc, ATH_DBG_CONFIG, | 301 | DPRINTF(sc, ATH_DBG_CONFIG, |
303 | "pci_dma_mapping_error() on RX init\n"); | 302 | "dma_mapping_error() on RX init\n"); |
304 | error = -ENOMEM; | 303 | error = -ENOMEM; |
305 | break; | 304 | break; |
306 | } | 305 | } |
@@ -525,10 +524,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush) | |||
525 | * 1. accessing the frame | 524 | * 1. accessing the frame |
526 | * 2. requeueing the same buffer to h/w | 525 | * 2. requeueing the same buffer to h/w |
527 | */ | 526 | */ |
528 | pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev), | 527 | dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr, |
529 | bf->bf_buf_addr, | ||
530 | sc->rx.bufsize, | 528 | sc->rx.bufsize, |
531 | PCI_DMA_FROMDEVICE); | 529 | DMA_FROM_DEVICE); |
532 | 530 | ||
533 | /* | 531 | /* |
534 | * If we're asked to flush receive queue, directly | 532 | * If we're asked to flush receive queue, directly |
@@ -559,9 +557,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush) | |||
559 | goto requeue; | 557 | goto requeue; |
560 | 558 | ||
561 | /* Unmap the frame */ | 559 | /* Unmap the frame */ |
562 | pci_unmap_single(to_pci_dev(sc->dev), bf->bf_buf_addr, | 560 | dma_unmap_single(sc->dev, bf->bf_buf_addr, |
563 | sc->rx.bufsize, | 561 | sc->rx.bufsize, |
564 | PCI_DMA_FROMDEVICE); | 562 | DMA_FROM_DEVICE); |
565 | 563 | ||
566 | skb_put(skb, ds->ds_rxstat.rs_datalen); | 564 | skb_put(skb, ds->ds_rxstat.rs_datalen); |
567 | skb->protocol = cpu_to_be16(ETH_P_CONTROL); | 565 | skb->protocol = cpu_to_be16(ETH_P_CONTROL); |
@@ -607,16 +605,15 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush) | |||
607 | 605 | ||
608 | /* We will now give hardware our shiny new allocated skb */ | 606 | /* We will now give hardware our shiny new allocated skb */ |
609 | bf->bf_mpdu = requeue_skb; | 607 | bf->bf_mpdu = requeue_skb; |
610 | bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev), | 608 | bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data, |
611 | requeue_skb->data, | ||
612 | sc->rx.bufsize, | 609 | sc->rx.bufsize, |
613 | PCI_DMA_FROMDEVICE); | 610 | DMA_FROM_DEVICE); |
614 | if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev), | 611 | if (unlikely(dma_mapping_error(sc->dev, |
615 | bf->bf_buf_addr))) { | 612 | bf->bf_buf_addr))) { |
616 | dev_kfree_skb_any(requeue_skb); | 613 | dev_kfree_skb_any(requeue_skb); |
617 | bf->bf_mpdu = NULL; | 614 | bf->bf_mpdu = NULL; |
618 | DPRINTF(sc, ATH_DBG_CONFIG, | 615 | DPRINTF(sc, ATH_DBG_CONFIG, |
619 | "pci_dma_mapping_error() on RX\n"); | 616 | "dma_mapping_error() on RX\n"); |
620 | break; | 617 | break; |
621 | } | 618 | } |
622 | bf->bf_dmacontext = bf->bf_buf_addr; | 619 | bf->bf_dmacontext = bf->bf_buf_addr; |
diff --git a/drivers/net/wireless/ath9k/xmit.c b/drivers/net/wireless/ath9k/xmit.c index 27cb9d523f5f..522078d80931 100644 --- a/drivers/net/wireless/ath9k/xmit.c +++ b/drivers/net/wireless/ath9k/xmit.c | |||
@@ -340,10 +340,8 @@ static void ath_tx_complete_buf(struct ath_softc *sc, | |||
340 | } | 340 | } |
341 | 341 | ||
342 | /* Unmap this frame */ | 342 | /* Unmap this frame */ |
343 | pci_unmap_single(to_pci_dev(sc->dev), | 343 | dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE); |
344 | bf->bf_dmacontext, | 344 | |
345 | skb->len, | ||
346 | PCI_DMA_TODEVICE); | ||
347 | /* complete this frame */ | 345 | /* complete this frame */ |
348 | ath_tx_complete(sc, skb, &tx_status); | 346 | ath_tx_complete(sc, skb, &tx_status); |
349 | 347 | ||
@@ -1716,13 +1714,12 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf, | |||
1716 | /* DMA setup */ | 1714 | /* DMA setup */ |
1717 | bf->bf_mpdu = skb; | 1715 | bf->bf_mpdu = skb; |
1718 | 1716 | ||
1719 | bf->bf_dmacontext = pci_map_single(to_pci_dev(sc->dev), skb->data, | 1717 | bf->bf_dmacontext = dma_map_single(sc->dev, skb->data, |
1720 | skb->len, PCI_DMA_TODEVICE); | 1718 | skb->len, DMA_TO_DEVICE); |
1721 | if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev), | 1719 | if (unlikely(dma_mapping_error(sc->dev, bf->bf_dmacontext))) { |
1722 | bf->bf_dmacontext))) { | ||
1723 | bf->bf_mpdu = NULL; | 1720 | bf->bf_mpdu = NULL; |
1724 | DPRINTF(sc, ATH_DBG_CONFIG, | 1721 | DPRINTF(sc, ATH_DBG_CONFIG, |
1725 | "pci_dma_mapping_error() on TX\n"); | 1722 | "dma_mapping_error() on TX\n"); |
1726 | return -ENOMEM; | 1723 | return -ENOMEM; |
1727 | } | 1724 | } |
1728 | 1725 | ||