moxart_ether: pass struct device to DMA API functions
authorChristoph Hellwig <hch@lst.de>
Mon, 11 Feb 2019 13:20:02 +0000 (14:20 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 12 Feb 2019 17:09:23 +0000 (12:09 -0500)
The DMA API generally relies on a struct device to work properly, and
only barely works without one for legacy reasons.  Pass the easily
available struct device from the platform_device to remedy this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/moxa/moxart_ether.c
drivers/net/ethernet/moxa/moxart_ether.h

index b34055ac476f72191ca498ad11808f47fedac767..00dec0ffb11b25e51cb389edbacf080dd4096b18 100644 (file)
@@ -81,11 +81,13 @@ static void moxart_mac_free_memory(struct net_device *ndev)
                                 priv->rx_buf_size, DMA_FROM_DEVICE);
 
        if (priv->tx_desc_base)
-               dma_free_coherent(NULL, TX_REG_DESC_SIZE * TX_DESC_NUM,
+               dma_free_coherent(&priv->pdev->dev,
+                                 TX_REG_DESC_SIZE * TX_DESC_NUM,
                                  priv->tx_desc_base, priv->tx_base);
 
        if (priv->rx_desc_base)
-               dma_free_coherent(NULL, RX_REG_DESC_SIZE * RX_DESC_NUM,
+               dma_free_coherent(&priv->pdev->dev,
+                                 RX_REG_DESC_SIZE * RX_DESC_NUM,
                                  priv->rx_desc_base, priv->rx_base);
 
        kfree(priv->tx_buf_base);
@@ -476,6 +478,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
 
        priv = netdev_priv(ndev);
        priv->ndev = ndev;
+       priv->pdev = pdev;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        ndev->base_addr = res->start;
@@ -491,7 +494,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
        priv->tx_buf_size = TX_BUF_SIZE;
        priv->rx_buf_size = RX_BUF_SIZE;
 
-       priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
+       priv->tx_desc_base = dma_alloc_coherent(&pdev->dev, TX_REG_DESC_SIZE *
                                                TX_DESC_NUM, &priv->tx_base,
                                                GFP_DMA | GFP_KERNEL);
        if (!priv->tx_desc_base) {
@@ -499,7 +502,7 @@ static int moxart_mac_probe(struct platform_device *pdev)
                goto init_fail;
        }
 
-       priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE *
+       priv->rx_desc_base = dma_alloc_coherent(&pdev->dev, RX_REG_DESC_SIZE *
                                                RX_DESC_NUM, &priv->rx_base,
                                                GFP_DMA | GFP_KERNEL);
        if (!priv->rx_desc_base) {
index bee608b547d172db72288b3a9f71c541f68c53ab..bf4c3029cd0cbe7b0ec1b9bf1b31ff70a27a0086 100644 (file)
 #define LINK_STATUS            0x4
 
 struct moxart_mac_priv_t {
+       struct platform_device *pdev;
        void __iomem *base;
        unsigned int reg_maccr;
        unsigned int reg_imr;