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

tulip: dmfe: 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 'dmfe_init_one()' GFP_KERNEL can be used
because it is a probe function and no lock is taken in the between.

@@
@@
-    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 b5a3922a
...@@ -380,7 +380,7 @@ static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -380,7 +380,7 @@ static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
return -ENOMEM; return -ENOMEM;
SET_NETDEV_DEV(dev, &pdev->dev); SET_NETDEV_DEV(dev, &pdev->dev);
if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) { if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
pr_warn("32-bit PCI DMA not available\n"); pr_warn("32-bit PCI DMA not available\n");
err = -ENODEV; err = -ENODEV;
goto err_out_free; goto err_out_free;
...@@ -422,15 +422,17 @@ static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -422,15 +422,17 @@ static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
db = netdev_priv(dev); db = netdev_priv(dev);
/* Allocate Tx/Rx descriptor memory */ /* Allocate Tx/Rx descriptor memory */
db->desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * db->desc_pool_ptr = dma_alloc_coherent(&pdev->dev,
DESC_ALL_CNT + 0x20, &db->desc_pool_dma_ptr); sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
&db->desc_pool_dma_ptr, GFP_KERNEL);
if (!db->desc_pool_ptr) { if (!db->desc_pool_ptr) {
err = -ENOMEM; err = -ENOMEM;
goto err_out_res; goto err_out_res;
} }
db->buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * db->buf_pool_ptr = dma_alloc_coherent(&pdev->dev,
TX_DESC_CNT + 4, &db->buf_pool_dma_ptr); TX_BUF_ALLOC * TX_DESC_CNT + 4,
&db->buf_pool_dma_ptr, GFP_KERNEL);
if (!db->buf_pool_ptr) { if (!db->buf_pool_ptr) {
err = -ENOMEM; err = -ENOMEM;
goto err_out_free_desc; goto err_out_free_desc;
...@@ -492,11 +494,12 @@ static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -492,11 +494,12 @@ static int dmfe_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
err_out_unmap: err_out_unmap:
pci_iounmap(pdev, db->ioaddr); pci_iounmap(pdev, db->ioaddr);
err_out_free_buf: err_out_free_buf:
pci_free_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, dma_free_coherent(&pdev->dev, TX_BUF_ALLOC * TX_DESC_CNT + 4,
db->buf_pool_ptr, db->buf_pool_dma_ptr); db->buf_pool_ptr, db->buf_pool_dma_ptr);
err_out_free_desc: err_out_free_desc:
pci_free_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, dma_free_coherent(&pdev->dev,
db->desc_pool_ptr, db->desc_pool_dma_ptr); sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
db->desc_pool_ptr, db->desc_pool_dma_ptr);
err_out_res: err_out_res:
pci_release_regions(pdev); pci_release_regions(pdev);
err_out_disable: err_out_disable:
...@@ -519,11 +522,12 @@ static void dmfe_remove_one(struct pci_dev *pdev) ...@@ -519,11 +522,12 @@ static void dmfe_remove_one(struct pci_dev *pdev)
unregister_netdev(dev); unregister_netdev(dev);
pci_iounmap(db->pdev, db->ioaddr); pci_iounmap(db->pdev, db->ioaddr);
pci_free_consistent(db->pdev, sizeof(struct tx_desc) * dma_free_coherent(&db->pdev->dev,
DESC_ALL_CNT + 0x20, db->desc_pool_ptr, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20,
db->desc_pool_dma_ptr); db->desc_pool_ptr, db->desc_pool_dma_ptr);
pci_free_consistent(db->pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, dma_free_coherent(&db->pdev->dev,
db->buf_pool_ptr, db->buf_pool_dma_ptr); TX_BUF_ALLOC * TX_DESC_CNT + 4,
db->buf_pool_ptr, db->buf_pool_dma_ptr);
pci_release_regions(pdev); pci_release_regions(pdev);
free_netdev(dev); /* free board information */ free_netdev(dev); /* free board information */
} }
...@@ -955,8 +959,8 @@ static void dmfe_rx_packet(struct net_device *dev, struct dmfe_board_info *db) ...@@ -955,8 +959,8 @@ static void dmfe_rx_packet(struct net_device *dev, struct dmfe_board_info *db)
db->rx_avail_cnt--; db->rx_avail_cnt--;
db->interval_rx_cnt++; db->interval_rx_cnt++;
pci_unmap_single(db->pdev, le32_to_cpu(rxptr->rdes2), dma_unmap_single(&db->pdev->dev, le32_to_cpu(rxptr->rdes2),
RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE); RX_ALLOC_SIZE, DMA_FROM_DEVICE);
if ( (rdes0 & 0x300) != 0x300) { if ( (rdes0 & 0x300) != 0x300) {
/* A packet without First/Last flag */ /* A packet without First/Last flag */
...@@ -1329,8 +1333,8 @@ static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb) ...@@ -1329,8 +1333,8 @@ static void dmfe_reuse_skb(struct dmfe_board_info *db, struct sk_buff * skb)
if (!(rxptr->rdes0 & cpu_to_le32(0x80000000))) { if (!(rxptr->rdes0 & cpu_to_le32(0x80000000))) {
rxptr->rx_skb_ptr = skb; rxptr->rx_skb_ptr = skb;
rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, rxptr->rdes2 = cpu_to_le32(dma_map_single(&db->pdev->dev, skb->data,
skb->data, RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) ); RX_ALLOC_SIZE, DMA_FROM_DEVICE));
wmb(); wmb();
rxptr->rdes0 = cpu_to_le32(0x80000000); rxptr->rdes0 = cpu_to_le32(0x80000000);
db->rx_avail_cnt++; db->rx_avail_cnt++;
...@@ -1544,8 +1548,8 @@ static void allocate_rx_buffer(struct net_device *dev) ...@@ -1544,8 +1548,8 @@ static void allocate_rx_buffer(struct net_device *dev)
if ( ( skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE) ) == NULL ) if ( ( skb = netdev_alloc_skb(dev, RX_ALLOC_SIZE) ) == NULL )
break; break;
rxptr->rx_skb_ptr = skb; /* FIXME (?) */ rxptr->rx_skb_ptr = skb; /* FIXME (?) */
rxptr->rdes2 = cpu_to_le32( pci_map_single(db->pdev, skb->data, rxptr->rdes2 = cpu_to_le32(dma_map_single(&db->pdev->dev, skb->data,
RX_ALLOC_SIZE, PCI_DMA_FROMDEVICE) ); RX_ALLOC_SIZE, DMA_FROM_DEVICE));
wmb(); wmb();
rxptr->rdes0 = cpu_to_le32(0x80000000); rxptr->rdes0 = cpu_to_le32(0x80000000);
rxptr = rxptr->next_rx_desc; rxptr = rxptr->next_rx_desc;
......
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