goto err_tx_channel;
        }
 
-       dma->tx_dma_buf = dma_alloc_coherent(dev, dspi->devtype_data->dma_bufsize,
+       dma->tx_dma_buf = dma_alloc_coherent(dma->chan_tx->device->dev,
+                                            dspi->devtype_data->dma_bufsize,
                                             &dma->tx_dma_phys, GFP_KERNEL);
        if (!dma->tx_dma_buf) {
                ret = -ENOMEM;
                goto err_tx_dma_buf;
        }
 
-       dma->rx_dma_buf = dma_alloc_coherent(dev, dspi->devtype_data->dma_bufsize,
+       dma->rx_dma_buf = dma_alloc_coherent(dma->chan_rx->device->dev,
+                                            dspi->devtype_data->dma_bufsize,
                                             &dma->rx_dma_phys, GFP_KERNEL);
        if (!dma->rx_dma_buf) {
                ret = -ENOMEM;
        return 0;
 
 err_slave_config:
-       dma_free_coherent(dev, dspi->devtype_data->dma_bufsize,
+       dma_free_coherent(dma->chan_rx->device->dev,
+                         dspi->devtype_data->dma_bufsize,
                          dma->rx_dma_buf, dma->rx_dma_phys);
 err_rx_dma_buf:
-       dma_free_coherent(dev, dspi->devtype_data->dma_bufsize,
+       dma_free_coherent(dma->chan_tx->device->dev,
+                         dspi->devtype_data->dma_bufsize,
                          dma->tx_dma_buf, dma->tx_dma_phys);
 err_tx_dma_buf:
        dma_release_channel(dma->chan_tx);
 static void dspi_release_dma(struct fsl_dspi *dspi)
 {
        struct fsl_dspi_dma *dma = dspi->dma;
-       struct device *dev = &dspi->pdev->dev;
 
        if (!dma)
                return;
 
        if (dma->chan_tx) {
-               dma_unmap_single(dev, dma->tx_dma_phys,
+               dma_unmap_single(dma->chan_tx->device->dev, dma->tx_dma_phys,
                                 dspi->devtype_data->dma_bufsize,
                                 DMA_TO_DEVICE);
                dma_release_channel(dma->chan_tx);
        }
 
        if (dma->chan_rx) {
-               dma_unmap_single(dev, dma->rx_dma_phys,
+               dma_unmap_single(dma->chan_rx->device->dev, dma->rx_dma_phys,
                                 dspi->devtype_data->dma_bufsize,
                                 DMA_FROM_DEVICE);
                dma_release_channel(dma->chan_rx);