diff options
author | Christophe JAILLET <christophe.jaillet@wanadoo.fr> | 2020-07-20 15:36:09 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-07-20 17:50:07 -0700 |
commit | 256ca7449fbcc0351c349abf83d1869e31504725 (patch) | |
tree | 7df7808886fba3e64ab7136c55f59a7b2c6b82bd /drivers/net/ethernet/sis/sis190.c | |
parent | 0b0edb993c99bc9a2d6d92810736cd77300b3770 (diff) | |
download | linux-stable-256ca7449fbcc0351c349abf83d1869e31504725.tar.gz linux-stable-256ca7449fbcc0351c349abf83d1869e31504725.tar.bz2 linux-stable-256ca7449fbcc0351c349abf83d1869e31504725.zip |
sis: 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 'epic_init_one()' (sis190.c), GFP_KERNEL can be
used because this is a net_device_ops' 'ndo_open' function. This function
is protected by the rtnl_lock() semaphore. So only a mutex is used and no
spin_lock is acquired.
When memory is allocated in 'sis900_probe()' (sis900.c), GFP_KERNEL can be
used because it is a probe function and no spin_lock is acquired.
@@
@@
- 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: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/sis/sis190.c')
-rw-r--r-- | drivers/net/ethernet/sis/sis190.c | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c index 5a4b6e3ab38f..676b193833c0 100644 --- a/drivers/net/ethernet/sis/sis190.c +++ b/drivers/net/ethernet/sis/sis190.c @@ -494,9 +494,9 @@ static struct sk_buff *sis190_alloc_rx_skb(struct sis190_private *tp, skb = netdev_alloc_skb(tp->dev, rx_buf_sz); if (unlikely(!skb)) goto skb_alloc_failed; - mapping = pci_map_single(tp->pci_dev, skb->data, tp->rx_buf_sz, - PCI_DMA_FROMDEVICE); - if (pci_dma_mapping_error(tp->pci_dev, mapping)) + mapping = dma_map_single(&tp->pci_dev->dev, skb->data, tp->rx_buf_sz, + DMA_FROM_DEVICE); + if (dma_mapping_error(&tp->pci_dev->dev, mapping)) goto out; sis190_map_to_asic(desc, mapping, rx_buf_sz); @@ -542,8 +542,8 @@ static bool sis190_try_rx_copy(struct sis190_private *tp, if (!skb) goto out; - pci_dma_sync_single_for_cpu(tp->pci_dev, addr, tp->rx_buf_sz, - PCI_DMA_FROMDEVICE); + dma_sync_single_for_cpu(&tp->pci_dev->dev, addr, tp->rx_buf_sz, + DMA_FROM_DEVICE); skb_copy_to_linear_data(skb, sk_buff[0]->data, pkt_size); *sk_buff = skb; done = true; @@ -612,12 +612,14 @@ static int sis190_rx_interrupt(struct net_device *dev, if (sis190_try_rx_copy(tp, &skb, pkt_size, addr)) { - pci_dma_sync_single_for_device(pdev, addr, - tp->rx_buf_sz, PCI_DMA_FROMDEVICE); + dma_sync_single_for_device(&pdev->dev, addr, + tp->rx_buf_sz, + DMA_FROM_DEVICE); sis190_give_to_asic(desc, tp->rx_buf_sz); } else { - pci_unmap_single(pdev, addr, tp->rx_buf_sz, - PCI_DMA_FROMDEVICE); + dma_unmap_single(&pdev->dev, addr, + tp->rx_buf_sz, + DMA_FROM_DEVICE); tp->Rx_skbuff[entry] = NULL; sis190_make_unusable_by_asic(desc); } @@ -654,7 +656,8 @@ static void sis190_unmap_tx_skb(struct pci_dev *pdev, struct sk_buff *skb, len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; - pci_unmap_single(pdev, le32_to_cpu(desc->addr), len, PCI_DMA_TODEVICE); + dma_unmap_single(&pdev->dev, le32_to_cpu(desc->addr), len, + DMA_TO_DEVICE); memset(desc, 0x00, sizeof(*desc)); } @@ -785,8 +788,8 @@ static void sis190_free_rx_skb(struct sis190_private *tp, { struct pci_dev *pdev = tp->pci_dev; - pci_unmap_single(pdev, le32_to_cpu(desc->addr), tp->rx_buf_sz, - PCI_DMA_FROMDEVICE); + dma_unmap_single(&pdev->dev, le32_to_cpu(desc->addr), tp->rx_buf_sz, + DMA_FROM_DEVICE); dev_kfree_skb(*sk_buff); *sk_buff = NULL; sis190_make_unusable_by_asic(desc); @@ -1069,11 +1072,13 @@ static int sis190_open(struct net_device *dev) * Rx and Tx descriptors need 256 bytes alignment. * pci_alloc_consistent() guarantees a stronger alignment. */ - tp->TxDescRing = pci_alloc_consistent(pdev, TX_RING_BYTES, &tp->tx_dma); + tp->TxDescRing = dma_alloc_coherent(&pdev->dev, TX_RING_BYTES, + &tp->tx_dma, GFP_KERNEL); if (!tp->TxDescRing) goto out; - tp->RxDescRing = pci_alloc_consistent(pdev, RX_RING_BYTES, &tp->rx_dma); + tp->RxDescRing = dma_alloc_coherent(&pdev->dev, RX_RING_BYTES, + &tp->rx_dma, GFP_KERNEL); if (!tp->RxDescRing) goto err_free_tx_0; @@ -1095,9 +1100,11 @@ err_release_timer_2: sis190_delete_timer(dev); sis190_rx_clear(tp); err_free_rx_1: - pci_free_consistent(pdev, RX_RING_BYTES, tp->RxDescRing, tp->rx_dma); + dma_free_coherent(&pdev->dev, RX_RING_BYTES, tp->RxDescRing, + tp->rx_dma); err_free_tx_0: - pci_free_consistent(pdev, TX_RING_BYTES, tp->TxDescRing, tp->tx_dma); + dma_free_coherent(&pdev->dev, TX_RING_BYTES, tp->TxDescRing, + tp->tx_dma); goto out; } @@ -1159,8 +1166,10 @@ static int sis190_close(struct net_device *dev) free_irq(pdev->irq, dev); - pci_free_consistent(pdev, TX_RING_BYTES, tp->TxDescRing, tp->tx_dma); - pci_free_consistent(pdev, RX_RING_BYTES, tp->RxDescRing, tp->rx_dma); + dma_free_coherent(&pdev->dev, TX_RING_BYTES, tp->TxDescRing, + tp->tx_dma); + dma_free_coherent(&pdev->dev, RX_RING_BYTES, tp->RxDescRing, + tp->rx_dma); tp->TxDescRing = NULL; tp->RxDescRing = NULL; @@ -1197,8 +1206,9 @@ static netdev_tx_t sis190_start_xmit(struct sk_buff *skb, return NETDEV_TX_BUSY; } - mapping = pci_map_single(tp->pci_dev, skb->data, len, PCI_DMA_TODEVICE); - if (pci_dma_mapping_error(tp->pci_dev, mapping)) { + mapping = dma_map_single(&tp->pci_dev->dev, skb->data, len, + DMA_TO_DEVICE); + if (dma_mapping_error(&tp->pci_dev->dev, mapping)) { netif_err(tp, tx_err, dev, "PCI mapping failed, dropping packet"); return NETDEV_TX_BUSY; @@ -1498,7 +1508,7 @@ static struct net_device *sis190_init_board(struct pci_dev *pdev) goto err_pci_disable_2; } - rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + rc = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); if (rc < 0) { if (netif_msg_probe(tp)) pr_err("%s: DMA configuration failed\n", |