Commit 81adcd65 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by David S. Miller

ksz884x: switch from 'pci_' to 'dma_' API

The wrappers in include/linux/pci-dma-compat.h should go away.

The patch has been generated with the coccinelle script below and has been
hand modified to replace GFP_ with a correct flag.
It has been compile tested.

When memory is allocated in 'ksz_alloc_desc()', GFP_KERNEL can be used
because a few lines below, GFP_KERNEL is also used in the
'ksz_alloc_soft_desc()' calls.

@@
@@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@
@@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@
@@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
@@
-    PCI_DMA_NONE
+    DMA_NONE

@@
expression e1, e2, e3;
@@
-    pci_alloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3;
@@
-    pci_zalloc_consistent(e1, e2, e3)
+    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)

@@
expression e1, e2, e3, e4;
@@
-    pci_free_consistent(e1, e2, e3, e4)
+    dma_free_coherent(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_single(e1, e2, e3, e4)
+    dma_map_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_single(e1, e2, e3, e4)
+    dma_unmap_single(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4, e5;
@@
-    pci_map_page(e1, e2, e3, e4, e5)
+    dma_map_page(&e1->dev, e2, e3, e4, e5)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_page(e1, e2, e3, e4)
+    dma_unmap_page(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_map_sg(e1, e2, e3, e4)
+    dma_map_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_unmap_sg(e1, e2, e3, e4)
+    dma_unmap_sg(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
+    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_single_for_device(e1, e2, e3, e4)
+    dma_sync_single_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
+    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)

@@
expression e1, e2, e3, e4;
@@
-    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
+    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)

@@
expression e1, e2;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_dma_mask(e1, e2)
+    dma_set_mask(&e1->dev, e2)

@@
expression e1, e2;
@@
-    pci_set_consistent_dma_mask(e1, e2)
+    dma_set_coherent_mask(&e1->dev, e2)
Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e2a8a827
...@@ -4390,9 +4390,9 @@ static int ksz_alloc_desc(struct dev_info *adapter) ...@@ -4390,9 +4390,9 @@ static int ksz_alloc_desc(struct dev_info *adapter)
DESC_ALIGNMENT; DESC_ALIGNMENT;
adapter->desc_pool.alloc_virt = adapter->desc_pool.alloc_virt =
pci_zalloc_consistent(adapter->pdev, dma_alloc_coherent(&adapter->pdev->dev,
adapter->desc_pool.alloc_size, adapter->desc_pool.alloc_size,
&adapter->desc_pool.dma_addr); &adapter->desc_pool.dma_addr, GFP_KERNEL);
if (adapter->desc_pool.alloc_virt == NULL) { if (adapter->desc_pool.alloc_virt == NULL) {
adapter->desc_pool.alloc_size = 0; adapter->desc_pool.alloc_size = 0;
return 1; return 1;
...@@ -4431,7 +4431,8 @@ static int ksz_alloc_desc(struct dev_info *adapter) ...@@ -4431,7 +4431,8 @@ static int ksz_alloc_desc(struct dev_info *adapter)
static void free_dma_buf(struct dev_info *adapter, struct ksz_dma_buf *dma_buf, static void free_dma_buf(struct dev_info *adapter, struct ksz_dma_buf *dma_buf,
int direction) int direction)
{ {
pci_unmap_single(adapter->pdev, dma_buf->dma, dma_buf->len, direction); dma_unmap_single(&adapter->pdev->dev, dma_buf->dma, dma_buf->len,
direction);
dev_kfree_skb(dma_buf->skb); dev_kfree_skb(dma_buf->skb);
dma_buf->skb = NULL; dma_buf->skb = NULL;
dma_buf->dma = 0; dma_buf->dma = 0;
...@@ -4456,16 +4457,15 @@ static void ksz_init_rx_buffers(struct dev_info *adapter) ...@@ -4456,16 +4457,15 @@ static void ksz_init_rx_buffers(struct dev_info *adapter)
dma_buf = DMA_BUFFER(desc); dma_buf = DMA_BUFFER(desc);
if (dma_buf->skb && dma_buf->len != adapter->mtu) if (dma_buf->skb && dma_buf->len != adapter->mtu)
free_dma_buf(adapter, dma_buf, PCI_DMA_FROMDEVICE); free_dma_buf(adapter, dma_buf, DMA_FROM_DEVICE);
dma_buf->len = adapter->mtu; dma_buf->len = adapter->mtu;
if (!dma_buf->skb) if (!dma_buf->skb)
dma_buf->skb = alloc_skb(dma_buf->len, GFP_ATOMIC); dma_buf->skb = alloc_skb(dma_buf->len, GFP_ATOMIC);
if (dma_buf->skb && !dma_buf->dma) if (dma_buf->skb && !dma_buf->dma)
dma_buf->dma = pci_map_single( dma_buf->dma = dma_map_single(&adapter->pdev->dev,
adapter->pdev, skb_tail_pointer(dma_buf->skb),
skb_tail_pointer(dma_buf->skb), dma_buf->len,
dma_buf->len, DMA_FROM_DEVICE);
PCI_DMA_FROMDEVICE);
/* Set descriptor. */ /* Set descriptor. */
set_rx_buf(desc, dma_buf->dma); set_rx_buf(desc, dma_buf->dma);
...@@ -4543,11 +4543,10 @@ static void ksz_free_desc(struct dev_info *adapter) ...@@ -4543,11 +4543,10 @@ static void ksz_free_desc(struct dev_info *adapter)
/* Free memory. */ /* Free memory. */
if (adapter->desc_pool.alloc_virt) if (adapter->desc_pool.alloc_virt)
pci_free_consistent( dma_free_coherent(&adapter->pdev->dev,
adapter->pdev, adapter->desc_pool.alloc_size,
adapter->desc_pool.alloc_size, adapter->desc_pool.alloc_virt,
adapter->desc_pool.alloc_virt, adapter->desc_pool.dma_addr);
adapter->desc_pool.dma_addr);
/* Reset resource pool. */ /* Reset resource pool. */
adapter->desc_pool.alloc_size = 0; adapter->desc_pool.alloc_size = 0;
...@@ -4590,12 +4589,10 @@ static void ksz_free_buffers(struct dev_info *adapter, ...@@ -4590,12 +4589,10 @@ static void ksz_free_buffers(struct dev_info *adapter,
static void ksz_free_mem(struct dev_info *adapter) static void ksz_free_mem(struct dev_info *adapter)
{ {
/* Free transmit buffers. */ /* Free transmit buffers. */
ksz_free_buffers(adapter, &adapter->hw.tx_desc_info, ksz_free_buffers(adapter, &adapter->hw.tx_desc_info, DMA_TO_DEVICE);
PCI_DMA_TODEVICE);
/* Free receive buffers. */ /* Free receive buffers. */
ksz_free_buffers(adapter, &adapter->hw.rx_desc_info, ksz_free_buffers(adapter, &adapter->hw.rx_desc_info, DMA_FROM_DEVICE);
PCI_DMA_FROMDEVICE);
/* Free descriptors. */ /* Free descriptors. */
ksz_free_desc(adapter); ksz_free_desc(adapter);
...@@ -4657,9 +4654,8 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -4657,9 +4654,8 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev)
dma_buf->len = skb_headlen(skb); dma_buf->len = skb_headlen(skb);
dma_buf->dma = pci_map_single( dma_buf->dma = dma_map_single(&hw_priv->pdev->dev, skb->data,
hw_priv->pdev, skb->data, dma_buf->len, dma_buf->len, DMA_TO_DEVICE);
PCI_DMA_TODEVICE);
set_tx_buf(desc, dma_buf->dma); set_tx_buf(desc, dma_buf->dma);
set_tx_len(desc, dma_buf->len); set_tx_len(desc, dma_buf->len);
...@@ -4676,11 +4672,10 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -4676,11 +4672,10 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev)
dma_buf = DMA_BUFFER(desc); dma_buf = DMA_BUFFER(desc);
dma_buf->len = skb_frag_size(this_frag); dma_buf->len = skb_frag_size(this_frag);
dma_buf->dma = pci_map_single( dma_buf->dma = dma_map_single(&hw_priv->pdev->dev,
hw_priv->pdev, skb_frag_address(this_frag),
skb_frag_address(this_frag), dma_buf->len,
dma_buf->len, DMA_TO_DEVICE);
PCI_DMA_TODEVICE);
set_tx_buf(desc, dma_buf->dma); set_tx_buf(desc, dma_buf->dma);
set_tx_len(desc, dma_buf->len); set_tx_len(desc, dma_buf->len);
...@@ -4700,9 +4695,8 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev) ...@@ -4700,9 +4695,8 @@ static void send_packet(struct sk_buff *skb, struct net_device *dev)
} else { } else {
dma_buf->len = len; dma_buf->len = len;
dma_buf->dma = pci_map_single( dma_buf->dma = dma_map_single(&hw_priv->pdev->dev, skb->data,
hw_priv->pdev, skb->data, dma_buf->len, dma_buf->len, DMA_TO_DEVICE);
PCI_DMA_TODEVICE);
set_tx_buf(desc, dma_buf->dma); set_tx_buf(desc, dma_buf->dma);
set_tx_len(desc, dma_buf->len); set_tx_len(desc, dma_buf->len);
} }
...@@ -4756,9 +4750,8 @@ static void transmit_cleanup(struct dev_info *hw_priv, int normal) ...@@ -4756,9 +4750,8 @@ static void transmit_cleanup(struct dev_info *hw_priv, int normal)
} }
dma_buf = DMA_BUFFER(desc); dma_buf = DMA_BUFFER(desc);
pci_unmap_single( dma_unmap_single(&hw_priv->pdev->dev, dma_buf->dma,
hw_priv->pdev, dma_buf->dma, dma_buf->len, dma_buf->len, DMA_TO_DEVICE);
PCI_DMA_TODEVICE);
/* This descriptor contains the last buffer in the packet. */ /* This descriptor contains the last buffer in the packet. */
if (dma_buf->skb) { if (dma_buf->skb) {
...@@ -4991,9 +4984,8 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw, ...@@ -4991,9 +4984,8 @@ static inline int rx_proc(struct net_device *dev, struct ksz_hw* hw,
packet_len = status.rx.frame_len - 4; packet_len = status.rx.frame_len - 4;
dma_buf = DMA_BUFFER(desc); dma_buf = DMA_BUFFER(desc);
pci_dma_sync_single_for_cpu( dma_sync_single_for_cpu(&hw_priv->pdev->dev, dma_buf->dma,
hw_priv->pdev, dma_buf->dma, packet_len + 4, packet_len + 4, DMA_FROM_DEVICE);
PCI_DMA_FROMDEVICE);
do { do {
/* skb->data != skb->head */ /* skb->data != skb->head */
...@@ -6935,8 +6927,8 @@ static int pcidev_init(struct pci_dev *pdev, const struct pci_device_id *id) ...@@ -6935,8 +6927,8 @@ static int pcidev_init(struct pci_dev *pdev, const struct pci_device_id *id)
result = -ENODEV; result = -ENODEV;
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) || if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) ||
pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)))
return result; return result;
reg_base = pci_resource_start(pdev, 0); reg_base = pci_resource_start(pdev, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment