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

net: spider_net: switch from 'pci_' to 'dma_' API

In [1], Christoph Hellwig has proposed to remove the wrappers in
include/linux/pci-dma-compat.h.

Some reasons why this API should be removed have been given by Julia
Lawall in [2].

A coccinelle script has been used to perform the needed transformation
Only relevant parts are given below.

@@ @@
-    PCI_DMA_BIDIRECTIONAL
+    DMA_BIDIRECTIONAL

@@ @@
-    PCI_DMA_TODEVICE
+    DMA_TO_DEVICE

@@ @@
-    PCI_DMA_FROMDEVICE
+    DMA_FROM_DEVICE

@@
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;
@@
-    pci_dma_mapping_error(e1, e2)
+    dma_mapping_error(&e1->dev, e2)

[1]: https://lore.kernel.org/kernel-janitors/20200421081257.GA131897@infradead.org/
[2]: https://lore.kernel.org/kernel-janitors/alpine.DEB.2.22.394.2007120902170.2424@hadrien/Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: default avatarGeoff Levand <geoff@infradead.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dce677da
...@@ -354,9 +354,10 @@ spider_net_free_rx_chain_contents(struct spider_net_card *card) ...@@ -354,9 +354,10 @@ spider_net_free_rx_chain_contents(struct spider_net_card *card)
descr = card->rx_chain.head; descr = card->rx_chain.head;
do { do {
if (descr->skb) { if (descr->skb) {
pci_unmap_single(card->pdev, descr->hwdescr->buf_addr, dma_unmap_single(&card->pdev->dev,
descr->hwdescr->buf_addr,
SPIDER_NET_MAX_FRAME, SPIDER_NET_MAX_FRAME,
PCI_DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
dev_kfree_skb(descr->skb); dev_kfree_skb(descr->skb);
descr->skb = NULL; descr->skb = NULL;
} }
...@@ -411,9 +412,9 @@ spider_net_prepare_rx_descr(struct spider_net_card *card, ...@@ -411,9 +412,9 @@ spider_net_prepare_rx_descr(struct spider_net_card *card,
if (offset) if (offset)
skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset); skb_reserve(descr->skb, SPIDER_NET_RXBUF_ALIGN - offset);
/* iommu-map the skb */ /* iommu-map the skb */
buf = pci_map_single(card->pdev, descr->skb->data, buf = dma_map_single(&card->pdev->dev, descr->skb->data,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); SPIDER_NET_MAX_FRAME, DMA_FROM_DEVICE);
if (pci_dma_mapping_error(card->pdev, buf)) { if (dma_mapping_error(&card->pdev->dev, buf)) {
dev_kfree_skb_any(descr->skb); dev_kfree_skb_any(descr->skb);
descr->skb = NULL; descr->skb = NULL;
if (netif_msg_rx_err(card) && net_ratelimit()) if (netif_msg_rx_err(card) && net_ratelimit())
...@@ -653,8 +654,9 @@ spider_net_prepare_tx_descr(struct spider_net_card *card, ...@@ -653,8 +654,9 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
dma_addr_t buf; dma_addr_t buf;
unsigned long flags; unsigned long flags;
buf = pci_map_single(card->pdev, skb->data, skb->len, PCI_DMA_TODEVICE); buf = dma_map_single(&card->pdev->dev, skb->data, skb->len,
if (pci_dma_mapping_error(card->pdev, buf)) { DMA_TO_DEVICE);
if (dma_mapping_error(&card->pdev->dev, buf)) {
if (netif_msg_tx_err(card) && net_ratelimit()) if (netif_msg_tx_err(card) && net_ratelimit())
dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). " dev_err(&card->netdev->dev, "could not iommu-map packet (%p, %i). "
"Dropping packet\n", skb->data, skb->len); "Dropping packet\n", skb->data, skb->len);
...@@ -666,7 +668,8 @@ spider_net_prepare_tx_descr(struct spider_net_card *card, ...@@ -666,7 +668,8 @@ spider_net_prepare_tx_descr(struct spider_net_card *card,
descr = card->tx_chain.head; descr = card->tx_chain.head;
if (descr->next == chain->tail->prev) { if (descr->next == chain->tail->prev) {
spin_unlock_irqrestore(&chain->lock, flags); spin_unlock_irqrestore(&chain->lock, flags);
pci_unmap_single(card->pdev, buf, skb->len, PCI_DMA_TODEVICE); dma_unmap_single(&card->pdev->dev, buf, skb->len,
DMA_TO_DEVICE);
return -ENOMEM; return -ENOMEM;
} }
hwdescr = descr->hwdescr; hwdescr = descr->hwdescr;
...@@ -822,8 +825,8 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal) ...@@ -822,8 +825,8 @@ spider_net_release_tx_chain(struct spider_net_card *card, int brutal)
/* unmap the skb */ /* unmap the skb */
if (skb) { if (skb) {
pci_unmap_single(card->pdev, buf_addr, skb->len, dma_unmap_single(&card->pdev->dev, buf_addr, skb->len,
PCI_DMA_TODEVICE); DMA_TO_DEVICE);
dev_consume_skb_any(skb); dev_consume_skb_any(skb);
} }
} }
...@@ -1165,8 +1168,8 @@ spider_net_decode_one_descr(struct spider_net_card *card) ...@@ -1165,8 +1168,8 @@ spider_net_decode_one_descr(struct spider_net_card *card)
/* unmap descriptor */ /* unmap descriptor */
hw_buf_addr = hwdescr->buf_addr; hw_buf_addr = hwdescr->buf_addr;
hwdescr->buf_addr = 0xffffffff; hwdescr->buf_addr = 0xffffffff;
pci_unmap_single(card->pdev, hw_buf_addr, dma_unmap_single(&card->pdev->dev, hw_buf_addr, SPIDER_NET_MAX_FRAME,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE); DMA_FROM_DEVICE);
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) || if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
(status == SPIDER_NET_DESCR_PROTECTION_ERROR) || (status == SPIDER_NET_DESCR_PROTECTION_ERROR) ||
......
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