Skip to content

Commit 24dd377

Browse files
tititiou36davem330
authored andcommitted
wan: wanxl: 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 'wanxl_pci_init_one()', GFP_KERNEL can be used because it is a probe function and no lock is acquired. Moreover, just a few lines above, GFP_KERNEL is already used. @@ @@ - 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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7c9864b commit 24dd377

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

drivers/net/wan/wanxl.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static inline port_status_t *get_status(struct port *port)
9999
static inline dma_addr_t pci_map_single_debug(struct pci_dev *pdev, void *ptr,
100100
size_t size, int direction)
101101
{
102-
dma_addr_t addr = pci_map_single(pdev, ptr, size, direction);
102+
dma_addr_t addr = dma_map_single(&pdev->dev, ptr, size, direction);
103103
if (addr + size > 0x100000000LL)
104104
pr_crit("%s: pci_map_single() returned memory at 0x%llx!\n",
105105
pci_name(pdev), (unsigned long long)addr);
@@ -180,8 +180,8 @@ static inline void wanxl_tx_intr(struct port *port)
180180
dev->stats.tx_bytes += skb->len;
181181
}
182182
desc->stat = PACKET_EMPTY; /* Free descriptor */
183-
pci_unmap_single(port->card->pdev, desc->address, skb->len,
184-
PCI_DMA_TODEVICE);
183+
dma_unmap_single(&port->card->pdev->dev, desc->address,
184+
skb->len, DMA_TO_DEVICE);
185185
dev_consume_skb_irq(skb);
186186
port->tx_in = (port->tx_in + 1) % TX_BUFFERS;
187187
}
@@ -207,9 +207,9 @@ static inline void wanxl_rx_intr(struct card *card)
207207
if (!skb)
208208
dev->stats.rx_dropped++;
209209
else {
210-
pci_unmap_single(card->pdev, desc->address,
211-
BUFFER_LENGTH,
212-
PCI_DMA_FROMDEVICE);
210+
dma_unmap_single(&card->pdev->dev,
211+
desc->address, BUFFER_LENGTH,
212+
DMA_FROM_DEVICE);
213213
skb_put(skb, desc->length);
214214

215215
#ifdef DEBUG_PKT
@@ -227,9 +227,10 @@ static inline void wanxl_rx_intr(struct card *card)
227227
if (!skb) {
228228
skb = dev_alloc_skb(BUFFER_LENGTH);
229229
desc->address = skb ?
230-
pci_map_single(card->pdev, skb->data,
230+
dma_map_single(&card->pdev->dev,
231+
skb->data,
231232
BUFFER_LENGTH,
232-
PCI_DMA_FROMDEVICE) : 0;
233+
DMA_FROM_DEVICE) : 0;
233234
card->rx_skbs[card->rx_in] = skb;
234235
}
235236
}
@@ -291,8 +292,8 @@ static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev)
291292
#endif
292293

293294
port->tx_skbs[port->tx_out] = skb;
294-
desc->address = pci_map_single(port->card->pdev, skb->data, skb->len,
295-
PCI_DMA_TODEVICE);
295+
desc->address = dma_map_single(&port->card->pdev->dev, skb->data,
296+
skb->len, DMA_TO_DEVICE);
296297
desc->length = skb->len;
297298
desc->stat = PACKET_FULL;
298299
writel(1 << (DOORBELL_TO_CARD_TX_0 + port->node),
@@ -451,9 +452,9 @@ static int wanxl_close(struct net_device *dev)
451452

452453
if (desc->stat != PACKET_EMPTY) {
453454
desc->stat = PACKET_EMPTY;
454-
pci_unmap_single(port->card->pdev, desc->address,
455-
port->tx_skbs[i]->len,
456-
PCI_DMA_TODEVICE);
455+
dma_unmap_single(&port->card->pdev->dev,
456+
desc->address, port->tx_skbs[i]->len,
457+
DMA_TO_DEVICE);
457458
dev_kfree_skb(port->tx_skbs[i]);
458459
}
459460
}
@@ -524,18 +525,18 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)
524525

525526
for (i = 0; i < RX_QUEUE_LENGTH; i++)
526527
if (card->rx_skbs[i]) {
527-
pci_unmap_single(card->pdev,
528+
dma_unmap_single(&card->pdev->dev,
528529
card->status->rx_descs[i].address,
529-
BUFFER_LENGTH, PCI_DMA_FROMDEVICE);
530+
BUFFER_LENGTH, DMA_FROM_DEVICE);
530531
dev_kfree_skb(card->rx_skbs[i]);
531532
}
532533

533534
if (card->plx)
534535
iounmap(card->plx);
535536

536537
if (card->status)
537-
pci_free_consistent(pdev, sizeof(struct card_status),
538-
card->status, card->status_address);
538+
dma_free_coherent(&pdev->dev, sizeof(struct card_status),
539+
card->status, card->status_address);
539540

540541
pci_release_regions(pdev);
541542
pci_disable_device(pdev);
@@ -579,8 +580,8 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
579580
We set both dma_mask and consistent_dma_mask to 28 bits
580581
and pray pci_alloc_consistent() will use this info. It should
581582
work on most platforms */
582-
if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(28)) ||
583-
pci_set_dma_mask(pdev, DMA_BIT_MASK(28))) {
583+
if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(28)) ||
584+
dma_set_mask(&pdev->dev, DMA_BIT_MASK(28))) {
584585
pr_err("No usable DMA configuration\n");
585586
pci_disable_device(pdev);
586587
return -EIO;
@@ -608,9 +609,9 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
608609
pci_set_drvdata(pdev, card);
609610
card->pdev = pdev;
610611

611-
card->status = pci_alloc_consistent(pdev,
612-
sizeof(struct card_status),
613-
&card->status_address);
612+
card->status = dma_alloc_coherent(&pdev->dev,
613+
sizeof(struct card_status),
614+
&card->status_address, GFP_KERNEL);
614615
if (card->status == NULL) {
615616
wanxl_pci_remove_one(pdev);
616617
return -ENOBUFS;
@@ -625,8 +626,8 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
625626
/* FIXME when PCI/DMA subsystems are fixed.
626627
We set both dma_mask and consistent_dma_mask back to 32 bits
627628
to indicate the card can do 32-bit DMA addressing */
628-
if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)) ||
629-
pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
629+
if (dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32)) ||
630+
dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
630631
pr_err("No usable DMA configuration\n");
631632
wanxl_pci_remove_one(pdev);
632633
return -EIO;
@@ -699,9 +700,8 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
699700
card->rx_skbs[i] = skb;
700701
if (skb)
701702
card->status->rx_descs[i].address =
702-
pci_map_single(card->pdev, skb->data,
703-
BUFFER_LENGTH,
704-
PCI_DMA_FROMDEVICE);
703+
dma_map_single(&card->pdev->dev, skb->data,
704+
BUFFER_LENGTH, DMA_FROM_DEVICE);
705705
}
706706

707707
mem = ioremap(mem_phy, PDM_OFFSET + sizeof(firmware));

0 commit comments

Comments
 (0)