diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-08-08 02:16:04 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:50:22 -0400 |
commit | 6cc92cddb13a7874dcd7751c84b0e61738815077 (patch) | |
tree | 9e33135f1ed5f4ad80e240d86f725e0207d2f030 /drivers/net | |
parent | ae94607d19028f9805e82da8975c66d3858fcfd8 (diff) |
[netdrvr] 8139cp, 8139too: convert to generic DMA
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/8139cp.c | 31 | ||||
-rw-r--r-- | drivers/net/8139too.c | 20 |
2 files changed, 27 insertions, 24 deletions
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 7f18ca23d9f8..2dec3d6ae01a 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -562,7 +562,7 @@ rx_status_loop: | |||
562 | 562 | ||
563 | skb_reserve(new_skb, RX_OFFSET); | 563 | skb_reserve(new_skb, RX_OFFSET); |
564 | 564 | ||
565 | pci_unmap_single(cp->pdev, mapping, | 565 | dma_unmap_single(&cp->pdev->dev, mapping, |
566 | buflen, PCI_DMA_FROMDEVICE); | 566 | buflen, PCI_DMA_FROMDEVICE); |
567 | 567 | ||
568 | /* Handle checksum offloading for incoming packets. */ | 568 | /* Handle checksum offloading for incoming packets. */ |
@@ -573,7 +573,7 @@ rx_status_loop: | |||
573 | 573 | ||
574 | skb_put(skb, len); | 574 | skb_put(skb, len); |
575 | 575 | ||
576 | mapping = pci_map_single(cp->pdev, new_skb->data, buflen, | 576 | mapping = dma_map_single(&cp->pdev->dev, new_skb->data, buflen, |
577 | PCI_DMA_FROMDEVICE); | 577 | PCI_DMA_FROMDEVICE); |
578 | cp->rx_skb[rx_tail] = new_skb; | 578 | cp->rx_skb[rx_tail] = new_skb; |
579 | 579 | ||
@@ -701,7 +701,7 @@ static void cp_tx (struct cp_private *cp) | |||
701 | skb = cp->tx_skb[tx_tail]; | 701 | skb = cp->tx_skb[tx_tail]; |
702 | BUG_ON(!skb); | 702 | BUG_ON(!skb); |
703 | 703 | ||
704 | pci_unmap_single(cp->pdev, le64_to_cpu(txd->addr), | 704 | dma_unmap_single(&cp->pdev->dev, le64_to_cpu(txd->addr), |
705 | le32_to_cpu(txd->opts1) & 0xffff, | 705 | le32_to_cpu(txd->opts1) & 0xffff, |
706 | PCI_DMA_TODEVICE); | 706 | PCI_DMA_TODEVICE); |
707 | 707 | ||
@@ -779,7 +779,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
779 | dma_addr_t mapping; | 779 | dma_addr_t mapping; |
780 | 780 | ||
781 | len = skb->len; | 781 | len = skb->len; |
782 | mapping = pci_map_single(cp->pdev, skb->data, len, PCI_DMA_TODEVICE); | 782 | mapping = dma_map_single(&cp->pdev->dev, skb->data, len, PCI_DMA_TODEVICE); |
783 | CP_VLAN_TX_TAG(txd, vlan_tag); | 783 | CP_VLAN_TX_TAG(txd, vlan_tag); |
784 | txd->addr = cpu_to_le64(mapping); | 784 | txd->addr = cpu_to_le64(mapping); |
785 | wmb(); | 785 | wmb(); |
@@ -815,7 +815,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
815 | */ | 815 | */ |
816 | first_eor = eor; | 816 | first_eor = eor; |
817 | first_len = skb_headlen(skb); | 817 | first_len = skb_headlen(skb); |
818 | first_mapping = pci_map_single(cp->pdev, skb->data, | 818 | first_mapping = dma_map_single(&cp->pdev->dev, skb->data, |
819 | first_len, PCI_DMA_TODEVICE); | 819 | first_len, PCI_DMA_TODEVICE); |
820 | cp->tx_skb[entry] = skb; | 820 | cp->tx_skb[entry] = skb; |
821 | entry = NEXT_TX(entry); | 821 | entry = NEXT_TX(entry); |
@@ -827,7 +827,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
827 | dma_addr_t mapping; | 827 | dma_addr_t mapping; |
828 | 828 | ||
829 | len = this_frag->size; | 829 | len = this_frag->size; |
830 | mapping = pci_map_single(cp->pdev, | 830 | mapping = dma_map_single(&cp->pdev->dev, |
831 | ((void *) page_address(this_frag->page) + | 831 | ((void *) page_address(this_frag->page) + |
832 | this_frag->page_offset), | 832 | this_frag->page_offset), |
833 | len, PCI_DMA_TODEVICE); | 833 | len, PCI_DMA_TODEVICE); |
@@ -1066,8 +1066,8 @@ static int cp_refill_rx (struct cp_private *cp) | |||
1066 | 1066 | ||
1067 | skb_reserve(skb, RX_OFFSET); | 1067 | skb_reserve(skb, RX_OFFSET); |
1068 | 1068 | ||
1069 | mapping = pci_map_single(cp->pdev, skb->data, cp->rx_buf_sz, | 1069 | mapping = dma_map_single(&cp->pdev->dev, skb->data, |
1070 | PCI_DMA_FROMDEVICE); | 1070 | cp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1071 | cp->rx_skb[i] = skb; | 1071 | cp->rx_skb[i] = skb; |
1072 | 1072 | ||
1073 | cp->rx_ring[i].opts2 = 0; | 1073 | cp->rx_ring[i].opts2 = 0; |
@@ -1107,7 +1107,8 @@ static int cp_alloc_rings (struct cp_private *cp) | |||
1107 | { | 1107 | { |
1108 | void *mem; | 1108 | void *mem; |
1109 | 1109 | ||
1110 | mem = pci_alloc_consistent(cp->pdev, CP_RING_BYTES, &cp->ring_dma); | 1110 | mem = dma_alloc_coherent(&cp->pdev->dev, CP_RING_BYTES, |
1111 | &cp->ring_dma, GFP_KERNEL); | ||
1111 | if (!mem) | 1112 | if (!mem) |
1112 | return -ENOMEM; | 1113 | return -ENOMEM; |
1113 | 1114 | ||
@@ -1125,7 +1126,7 @@ static void cp_clean_rings (struct cp_private *cp) | |||
1125 | for (i = 0; i < CP_RX_RING_SIZE; i++) { | 1126 | for (i = 0; i < CP_RX_RING_SIZE; i++) { |
1126 | if (cp->rx_skb[i]) { | 1127 | if (cp->rx_skb[i]) { |
1127 | desc = cp->rx_ring + i; | 1128 | desc = cp->rx_ring + i; |
1128 | pci_unmap_single(cp->pdev, le64_to_cpu(desc->addr), | 1129 | dma_unmap_single(&cp->pdev->dev,le64_to_cpu(desc->addr), |
1129 | cp->rx_buf_sz, PCI_DMA_FROMDEVICE); | 1130 | cp->rx_buf_sz, PCI_DMA_FROMDEVICE); |
1130 | dev_kfree_skb(cp->rx_skb[i]); | 1131 | dev_kfree_skb(cp->rx_skb[i]); |
1131 | } | 1132 | } |
@@ -1136,7 +1137,7 @@ static void cp_clean_rings (struct cp_private *cp) | |||
1136 | struct sk_buff *skb = cp->tx_skb[i]; | 1137 | struct sk_buff *skb = cp->tx_skb[i]; |
1137 | 1138 | ||
1138 | desc = cp->tx_ring + i; | 1139 | desc = cp->tx_ring + i; |
1139 | pci_unmap_single(cp->pdev, le64_to_cpu(desc->addr), | 1140 | dma_unmap_single(&cp->pdev->dev,le64_to_cpu(desc->addr), |
1140 | le32_to_cpu(desc->opts1) & 0xffff, | 1141 | le32_to_cpu(desc->opts1) & 0xffff, |
1141 | PCI_DMA_TODEVICE); | 1142 | PCI_DMA_TODEVICE); |
1142 | if (le32_to_cpu(desc->opts1) & LastFrag) | 1143 | if (le32_to_cpu(desc->opts1) & LastFrag) |
@@ -1155,7 +1156,8 @@ static void cp_clean_rings (struct cp_private *cp) | |||
1155 | static void cp_free_rings (struct cp_private *cp) | 1156 | static void cp_free_rings (struct cp_private *cp) |
1156 | { | 1157 | { |
1157 | cp_clean_rings(cp); | 1158 | cp_clean_rings(cp); |
1158 | pci_free_consistent(cp->pdev, CP_RING_BYTES, cp->rx_ring, cp->ring_dma); | 1159 | dma_free_coherent(&cp->pdev->dev, CP_RING_BYTES, cp->rx_ring, |
1160 | cp->ring_dma); | ||
1159 | cp->rx_ring = NULL; | 1161 | cp->rx_ring = NULL; |
1160 | cp->tx_ring = NULL; | 1162 | cp->tx_ring = NULL; |
1161 | } | 1163 | } |
@@ -1519,7 +1521,8 @@ static void cp_get_ethtool_stats (struct net_device *dev, | |||
1519 | dma_addr_t dma; | 1521 | dma_addr_t dma; |
1520 | int i; | 1522 | int i; |
1521 | 1523 | ||
1522 | nic_stats = pci_alloc_consistent(cp->pdev, sizeof(*nic_stats), &dma); | 1524 | nic_stats = dma_alloc_coherent(&cp->pdev->dev, sizeof(*nic_stats), |
1525 | &dma, GFP_KERNEL); | ||
1523 | if (!nic_stats) | 1526 | if (!nic_stats) |
1524 | return; | 1527 | return; |
1525 | 1528 | ||
@@ -1554,7 +1557,7 @@ static void cp_get_ethtool_stats (struct net_device *dev, | |||
1554 | tmp_stats[i++] = cp->cp_stats.rx_frags; | 1557 | tmp_stats[i++] = cp->cp_stats.rx_frags; |
1555 | BUG_ON(i != CP_NUM_STATS); | 1558 | BUG_ON(i != CP_NUM_STATS); |
1556 | 1559 | ||
1557 | pci_free_consistent(cp->pdev, sizeof(*nic_stats), nic_stats, dma); | 1560 | dma_free_coherent(&cp->pdev->dev, sizeof(*nic_stats), nic_stats, dma); |
1558 | } | 1561 | } |
1559 | 1562 | ||
1560 | static const struct ethtool_ops cp_ethtool_ops = { | 1563 | static const struct ethtool_ops cp_ethtool_ops = { |
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 20af6baecfcb..76d3048a1a63 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c | |||
@@ -1316,18 +1316,18 @@ static int rtl8139_open (struct net_device *dev) | |||
1316 | if (retval) | 1316 | if (retval) |
1317 | return retval; | 1317 | return retval; |
1318 | 1318 | ||
1319 | tp->tx_bufs = pci_alloc_consistent(tp->pci_dev, TX_BUF_TOT_LEN, | 1319 | tp->tx_bufs = dma_alloc_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN, |
1320 | &tp->tx_bufs_dma); | 1320 | &tp->tx_bufs_dma, GFP_KERNEL); |
1321 | tp->rx_ring = pci_alloc_consistent(tp->pci_dev, RX_BUF_TOT_LEN, | 1321 | tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN, |
1322 | &tp->rx_ring_dma); | 1322 | &tp->rx_ring_dma, GFP_KERNEL); |
1323 | if (tp->tx_bufs == NULL || tp->rx_ring == NULL) { | 1323 | if (tp->tx_bufs == NULL || tp->rx_ring == NULL) { |
1324 | free_irq(dev->irq, dev); | 1324 | free_irq(dev->irq, dev); |
1325 | 1325 | ||
1326 | if (tp->tx_bufs) | 1326 | if (tp->tx_bufs) |
1327 | pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN, | 1327 | dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN, |
1328 | tp->tx_bufs, tp->tx_bufs_dma); | 1328 | tp->tx_bufs, tp->tx_bufs_dma); |
1329 | if (tp->rx_ring) | 1329 | if (tp->rx_ring) |
1330 | pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN, | 1330 | dma_free_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN, |
1331 | tp->rx_ring, tp->rx_ring_dma); | 1331 | tp->rx_ring, tp->rx_ring_dma); |
1332 | 1332 | ||
1333 | return -ENOMEM; | 1333 | return -ENOMEM; |
@@ -2246,10 +2246,10 @@ static int rtl8139_close (struct net_device *dev) | |||
2246 | 2246 | ||
2247 | rtl8139_tx_clear (tp); | 2247 | rtl8139_tx_clear (tp); |
2248 | 2248 | ||
2249 | pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN, | 2249 | dma_free_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN, |
2250 | tp->rx_ring, tp->rx_ring_dma); | 2250 | tp->rx_ring, tp->rx_ring_dma); |
2251 | pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN, | 2251 | dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN, |
2252 | tp->tx_bufs, tp->tx_bufs_dma); | 2252 | tp->tx_bufs, tp->tx_bufs_dma); |
2253 | tp->rx_ring = NULL; | 2253 | tp->rx_ring = NULL; |
2254 | tp->tx_bufs = NULL; | 2254 | tp->tx_bufs = NULL; |
2255 | 2255 | ||