ath9k: convert to use bus-agnostic DMA routines
authorGabor Juhos <juhosg@openwrt.org>
Wed, 14 Jan 2009 19:17:03 +0000 (20:17 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 29 Jan 2009 21:00:29 +0000 (16:00 -0500)
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>
drivers/net/wireless/ath9k/beacon.c
drivers/net/wireless/ath9k/main.c
drivers/net/wireless/ath9k/recv.c
drivers/net/wireless/ath9k/xmit.c

index f02b099d3e3ae00d236ee73f6f4002e287f40748..be1d84a5dafbcfaa86276926ae17b91a96a6a5b6 100644 (file)
@@ -164,9 +164,9 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
        bf = avp->av_bcbuf;
        skb = (struct sk_buff *)bf->bf_mpdu;
        if (skb) {
-               pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
+               dma_unmap_single(sc->dev, bf->bf_dmacontext,
                                 skb->len,
-                                PCI_DMA_TODEVICE);
+                                DMA_TO_DEVICE);
                dev_kfree_skb_any(skb);
        }
 
@@ -188,15 +188,14 @@ static struct ath_buf *ath_beacon_generate(struct ath_softc *sc, int if_id)
        }
 
        bf->bf_buf_addr = bf->bf_dmacontext =
-               pci_map_single(to_pci_dev(sc->dev), skb->data,
+               dma_map_single(sc->dev, skb->data,
                               skb->len,
-                              PCI_DMA_TODEVICE);
-       if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
-                                          bf->bf_buf_addr))) {
+                              DMA_TO_DEVICE);
+       if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
                dev_kfree_skb_any(skb);
                bf->bf_mpdu = NULL;
                DPRINTF(sc, ATH_DBG_CONFIG,
-                       "pci_dma_mapping_error() on beaconing\n");
+                       "dma_mapping_error() on beaconing\n");
                return NULL;
        }
 
@@ -344,9 +343,9 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
        bf = avp->av_bcbuf;
        if (bf->bf_mpdu != NULL) {
                skb = (struct sk_buff *)bf->bf_mpdu;
-               pci_unmap_single(to_pci_dev(sc->dev), bf->bf_dmacontext,
+               dma_unmap_single(sc->dev, bf->bf_dmacontext,
                                 skb->len,
-                                PCI_DMA_TODEVICE);
+                                DMA_TO_DEVICE);
                dev_kfree_skb_any(skb);
                bf->bf_mpdu = NULL;
        }
@@ -403,15 +402,14 @@ int ath_beacon_alloc(struct ath_softc *sc, int if_id)
 
        bf->bf_mpdu = skb;
        bf->bf_buf_addr = bf->bf_dmacontext =
-               pci_map_single(to_pci_dev(sc->dev), skb->data,
+               dma_map_single(sc->dev, skb->data,
                               skb->len,
-                              PCI_DMA_TODEVICE);
-       if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
-                                          bf->bf_buf_addr))) {
+                              DMA_TO_DEVICE);
+       if (unlikely(dma_mapping_error(sc->dev, bf->bf_buf_addr))) {
                dev_kfree_skb_any(skb);
                bf->bf_mpdu = NULL;
                DPRINTF(sc, ATH_DBG_CONFIG,
-                       "pci_dma_mapping_error() on beacon alloc\n");
+                       "dma_mapping_error() on beacon alloc\n");
                return -ENOMEM;
        }
 
@@ -431,10 +429,9 @@ void ath_beacon_return(struct ath_softc *sc, struct ath_vap *avp)
                bf = avp->av_bcbuf;
                if (bf->bf_mpdu != NULL) {
                        struct sk_buff *skb = (struct sk_buff *)bf->bf_mpdu;
-                       pci_unmap_single(to_pci_dev(sc->dev),
-                                        bf->bf_dmacontext,
+                       dma_unmap_single(sc->dev, bf->bf_dmacontext,
                                         skb->len,
-                                        PCI_DMA_TODEVICE);
+                                        DMA_TO_DEVICE);
                        dev_kfree_skb_any(skb);
                        bf->bf_mpdu = NULL;
                }
index 44931e42e2ba27eee55ab75e6e7dcde99b1d9c77..ebf0467674cf8a61ec017c26bd800abf7b15b7ee 100644 (file)
@@ -1715,9 +1715,8 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
        }
 
        /* allocate descriptors */
-       dd->dd_desc = pci_alloc_consistent(to_pci_dev(sc->dev),
-                             dd->dd_desc_len,
-                             &dd->dd_desc_paddr);
+       dd->dd_desc = dma_alloc_coherent(sc->dev, dd->dd_desc_len,
+                                        &dd->dd_desc_paddr, GFP_ATOMIC);
        if (dd->dd_desc == NULL) {
                error = -ENOMEM;
                goto fail;
@@ -1763,8 +1762,8 @@ int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd,
        }
        return 0;
 fail2:
-       pci_free_consistent(to_pci_dev(sc->dev),
-               dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
+       dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
+                         dd->dd_desc_paddr);
 fail:
        memset(dd, 0, sizeof(*dd));
        return error;
@@ -1777,8 +1776,8 @@ void ath_descdma_cleanup(struct ath_softc *sc,
                         struct ath_descdma *dd,
                         struct list_head *head)
 {
-       pci_free_consistent(to_pci_dev(sc->dev),
-               dd->dd_desc_len, dd->dd_desc, dd->dd_desc_paddr);
+       dma_free_coherent(sc->dev, dd->dd_desc_len, dd->dd_desc,
+                         dd->dd_desc_paddr);
 
        INIT_LIST_HEAD(head);
        kfree(dd->dd_bufptr);
index 645fae2f49d8f2d9af9220049a96ab4e9a8cfe93..648bb49e6734c4afe8ec91e24271e33a0315d933 100644 (file)
@@ -291,16 +291,15 @@ int ath_rx_init(struct ath_softc *sc, int nbufs)
                        }
 
                        bf->bf_mpdu = skb;
-                       bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
-                                                        skb->data,
+                       bf->bf_buf_addr = dma_map_single(sc->dev, skb->data,
                                                         sc->rx.bufsize,
-                                                        PCI_DMA_FROMDEVICE);
-                       if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
+                                                        DMA_FROM_DEVICE);
+                       if (unlikely(dma_mapping_error(sc->dev,
                                  bf->bf_buf_addr))) {
                                dev_kfree_skb_any(skb);
                                bf->bf_mpdu = NULL;
                                DPRINTF(sc, ATH_DBG_CONFIG,
-                                       "pci_dma_mapping_error() on RX init\n");
+                                       "dma_mapping_error() on RX init\n");
                                error = -ENOMEM;
                                break;
                        }
@@ -525,10 +524,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
                 * 1. accessing the frame
                 * 2. requeueing the same buffer to h/w
                 */
-               pci_dma_sync_single_for_cpu(to_pci_dev(sc->dev),
-                               bf->bf_buf_addr,
+               dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
                                sc->rx.bufsize,
-                               PCI_DMA_FROMDEVICE);
+                               DMA_FROM_DEVICE);
 
                /*
                 * If we're asked to flush receive queue, directly
@@ -559,9 +557,9 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
                        goto requeue;
 
                /* Unmap the frame */
-               pci_unmap_single(to_pci_dev(sc->dev), bf->bf_buf_addr,
+               dma_unmap_single(sc->dev, bf->bf_buf_addr,
                                 sc->rx.bufsize,
-                                PCI_DMA_FROMDEVICE);
+                                DMA_FROM_DEVICE);
 
                skb_put(skb, ds->ds_rxstat.rs_datalen);
                skb->protocol = cpu_to_be16(ETH_P_CONTROL);
@@ -607,16 +605,15 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush)
 
                /* We will now give hardware our shiny new allocated skb */
                bf->bf_mpdu = requeue_skb;
-               bf->bf_buf_addr = pci_map_single(to_pci_dev(sc->dev),
-                                        requeue_skb->data,
+               bf->bf_buf_addr = dma_map_single(sc->dev, requeue_skb->data,
                                         sc->rx.bufsize,
-                                        PCI_DMA_FROMDEVICE);
-               if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
+                                        DMA_FROM_DEVICE);
+               if (unlikely(dma_mapping_error(sc->dev,
                          bf->bf_buf_addr))) {
                        dev_kfree_skb_any(requeue_skb);
                        bf->bf_mpdu = NULL;
                        DPRINTF(sc, ATH_DBG_CONFIG,
-                               "pci_dma_mapping_error() on RX\n");
+                               "dma_mapping_error() on RX\n");
                        break;
                }
                bf->bf_dmacontext = bf->bf_buf_addr;
index 27cb9d523f5ffb410f457f08322f0688e9744b85..522078d809318570b39864e40077cbfc607ba043 100644 (file)
@@ -340,10 +340,8 @@ static void ath_tx_complete_buf(struct ath_softc *sc,
        }
 
        /* Unmap this frame */
-       pci_unmap_single(to_pci_dev(sc->dev),
-                        bf->bf_dmacontext,
-                        skb->len,
-                        PCI_DMA_TODEVICE);
+       dma_unmap_single(sc->dev, bf->bf_dmacontext, skb->len, DMA_TO_DEVICE);
+
        /* complete this frame */
        ath_tx_complete(sc, skb, &tx_status);
 
@@ -1716,13 +1714,12 @@ static int ath_tx_setup_buffer(struct ath_softc *sc, struct ath_buf *bf,
        /* DMA setup */
        bf->bf_mpdu = skb;
 
-       bf->bf_dmacontext = pci_map_single(to_pci_dev(sc->dev), skb->data,
-                                          skb->len, PCI_DMA_TODEVICE);
-       if (unlikely(pci_dma_mapping_error(to_pci_dev(sc->dev),
-                                          bf->bf_dmacontext))) {
+       bf->bf_dmacontext = dma_map_single(sc->dev, skb->data,
+                                          skb->len, DMA_TO_DEVICE);
+       if (unlikely(dma_mapping_error(sc->dev, bf->bf_dmacontext))) {
                bf->bf_mpdu = NULL;
                DPRINTF(sc, ATH_DBG_CONFIG,
-                       "pci_dma_mapping_error() on TX\n");
+                       "dma_mapping_error() on TX\n");
                return -ENOMEM;
        }