Commit c08fa160 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Bjorn Helgaas

net: tsi108: Use DMA API properly

We need to pass a struct device to the DMA API, even if some architectures
still support that for legacy reasons, and should not mix it with the old
PCI DMA API.

Note that the driver also seems to never actually unmap its DMA mappings,
but to fix that we'll need someone more familar with the driver.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent 8d669f93
...@@ -152,6 +152,8 @@ struct tsi108_prv_data { ...@@ -152,6 +152,8 @@ struct tsi108_prv_data {
u32 msg_enable; /* debug message level */ u32 msg_enable; /* debug message level */
struct mii_if_info mii_if; struct mii_if_info mii_if;
unsigned int init_media; unsigned int init_media;
struct platform_device *pdev;
}; };
/* Structure for a device driver */ /* Structure for a device driver */
...@@ -703,17 +705,18 @@ static int tsi108_send_packet(struct sk_buff * skb, struct net_device *dev) ...@@ -703,17 +705,18 @@ static int tsi108_send_packet(struct sk_buff * skb, struct net_device *dev)
data->txskbs[tx] = skb; data->txskbs[tx] = skb;
if (i == 0) { if (i == 0) {
data->txring[tx].buf0 = dma_map_single(NULL, skb->data, data->txring[tx].buf0 = dma_map_single(&data->pdev->dev,
skb_headlen(skb), DMA_TO_DEVICE); skb->data, skb_headlen(skb),
DMA_TO_DEVICE);
data->txring[tx].len = skb_headlen(skb); data->txring[tx].len = skb_headlen(skb);
misc |= TSI108_TX_SOF; misc |= TSI108_TX_SOF;
} else { } else {
const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1]; const skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
data->txring[tx].buf0 = skb_frag_dma_map(NULL, frag, data->txring[tx].buf0 =
0, skb_frag_dma_map(&data->pdev->dev, frag,
skb_frag_size(frag), 0, skb_frag_size(frag),
DMA_TO_DEVICE); DMA_TO_DEVICE);
data->txring[tx].len = skb_frag_size(frag); data->txring[tx].len = skb_frag_size(frag);
} }
...@@ -808,9 +811,9 @@ static int tsi108_refill_rx(struct net_device *dev, int budget) ...@@ -808,9 +811,9 @@ static int tsi108_refill_rx(struct net_device *dev, int budget)
if (!skb) if (!skb)
break; break;
data->rxring[rx].buf0 = dma_map_single(NULL, skb->data, data->rxring[rx].buf0 = dma_map_single(&data->pdev->dev,
TSI108_RX_SKB_SIZE, skb->data, TSI108_RX_SKB_SIZE,
DMA_FROM_DEVICE); DMA_FROM_DEVICE);
/* Sometimes the hardware sets blen to zero after packet /* Sometimes the hardware sets blen to zero after packet
* reception, even though the manual says that it's only ever * reception, even though the manual says that it's only ever
...@@ -1308,15 +1311,15 @@ static int tsi108_open(struct net_device *dev) ...@@ -1308,15 +1311,15 @@ static int tsi108_open(struct net_device *dev)
data->id, dev->irq, dev->name); data->id, dev->irq, dev->name);
} }
data->rxring = dma_zalloc_coherent(NULL, rxring_size, &data->rxdma, data->rxring = dma_zalloc_coherent(&data->pdev->dev, rxring_size,
GFP_KERNEL); &data->rxdma, GFP_KERNEL);
if (!data->rxring) if (!data->rxring)
return -ENOMEM; return -ENOMEM;
data->txring = dma_zalloc_coherent(NULL, txring_size, &data->txdma, data->txring = dma_zalloc_coherent(&data->pdev->dev, txring_size,
GFP_KERNEL); &data->txdma, GFP_KERNEL);
if (!data->txring) { if (!data->txring) {
pci_free_consistent(NULL, rxring_size, data->rxring, dma_free_coherent(&data->pdev->dev, rxring_size, data->rxring,
data->rxdma); data->rxdma);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1428,10 +1431,10 @@ static int tsi108_close(struct net_device *dev) ...@@ -1428,10 +1431,10 @@ static int tsi108_close(struct net_device *dev)
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
dma_free_coherent(0, dma_free_coherent(&data->pdev->dev,
TSI108_RXRING_LEN * sizeof(rx_desc), TSI108_RXRING_LEN * sizeof(rx_desc),
data->rxring, data->rxdma); data->rxring, data->rxdma);
dma_free_coherent(0, dma_free_coherent(&data->pdev->dev,
TSI108_TXRING_LEN * sizeof(tx_desc), TSI108_TXRING_LEN * sizeof(tx_desc),
data->txring, data->txdma); data->txring, data->txdma);
...@@ -1576,6 +1579,7 @@ tsi108_init_one(struct platform_device *pdev) ...@@ -1576,6 +1579,7 @@ tsi108_init_one(struct platform_device *pdev)
printk("tsi108_eth%d: probe...\n", pdev->id); printk("tsi108_eth%d: probe...\n", pdev->id);
data = netdev_priv(dev); data = netdev_priv(dev);
data->dev = dev; data->dev = dev;
data->pdev = pdev;
pr_debug("tsi108_eth%d:regs:phyresgs:phy:irq_num=0x%x:0x%x:0x%x:0x%x\n", pr_debug("tsi108_eth%d:regs:phyresgs:phy:irq_num=0x%x:0x%x:0x%x:0x%x\n",
pdev->id, einfo->regs, einfo->phyregs, pdev->id, einfo->regs, einfo->phyregs,
......
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