spi: dw: Get rid of dma_inited flag
This flag is superfluous in all cases where it's being used, i.e. * ->can_dma() won't be called without dma_inited == 1 * DMA ->exit() callback can rely on txchan and rxchan variables So, get rid of dma_inited flag. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20200507115449.8093-2-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
140e45e1e6
commit
a041e672cb
|
@ -57,20 +57,21 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
|
||||||
dws->rxchan = dma_request_channel(mask, mid_spi_dma_chan_filter, rx);
|
dws->rxchan = dma_request_channel(mask, mid_spi_dma_chan_filter, rx);
|
||||||
if (!dws->rxchan)
|
if (!dws->rxchan)
|
||||||
goto err_exit;
|
goto err_exit;
|
||||||
dws->master->dma_rx = dws->rxchan;
|
|
||||||
|
|
||||||
/* 2. Init tx channel */
|
/* 2. Init tx channel */
|
||||||
tx->dma_dev = &dma_dev->dev;
|
tx->dma_dev = &dma_dev->dev;
|
||||||
dws->txchan = dma_request_channel(mask, mid_spi_dma_chan_filter, tx);
|
dws->txchan = dma_request_channel(mask, mid_spi_dma_chan_filter, tx);
|
||||||
if (!dws->txchan)
|
if (!dws->txchan)
|
||||||
goto free_rxchan;
|
goto free_rxchan;
|
||||||
|
|
||||||
|
dws->master->dma_rx = dws->rxchan;
|
||||||
dws->master->dma_tx = dws->txchan;
|
dws->master->dma_tx = dws->txchan;
|
||||||
|
|
||||||
dws->dma_inited = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
free_rxchan:
|
free_rxchan:
|
||||||
dma_release_channel(dws->rxchan);
|
dma_release_channel(dws->rxchan);
|
||||||
|
dws->rxchan = NULL;
|
||||||
err_exit:
|
err_exit:
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
@ -80,29 +81,31 @@ static int mid_spi_dma_init_generic(struct device *dev, struct dw_spi *dws)
|
||||||
dws->rxchan = dma_request_slave_channel(dev, "rx");
|
dws->rxchan = dma_request_slave_channel(dev, "rx");
|
||||||
if (!dws->rxchan)
|
if (!dws->rxchan)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
dws->master->dma_rx = dws->rxchan;
|
|
||||||
|
|
||||||
dws->txchan = dma_request_slave_channel(dev, "tx");
|
dws->txchan = dma_request_slave_channel(dev, "tx");
|
||||||
if (!dws->txchan) {
|
if (!dws->txchan) {
|
||||||
dma_release_channel(dws->rxchan);
|
dma_release_channel(dws->rxchan);
|
||||||
|
dws->rxchan = NULL;
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dws->master->dma_rx = dws->rxchan;
|
||||||
dws->master->dma_tx = dws->txchan;
|
dws->master->dma_tx = dws->txchan;
|
||||||
|
|
||||||
dws->dma_inited = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mid_spi_dma_exit(struct dw_spi *dws)
|
static void mid_spi_dma_exit(struct dw_spi *dws)
|
||||||
{
|
{
|
||||||
if (!dws->dma_inited)
|
if (dws->txchan) {
|
||||||
return;
|
dmaengine_terminate_sync(dws->txchan);
|
||||||
|
dma_release_channel(dws->txchan);
|
||||||
|
}
|
||||||
|
|
||||||
dmaengine_terminate_sync(dws->txchan);
|
if (dws->rxchan) {
|
||||||
dma_release_channel(dws->txchan);
|
dmaengine_terminate_sync(dws->rxchan);
|
||||||
|
dma_release_channel(dws->rxchan);
|
||||||
dmaengine_terminate_sync(dws->rxchan);
|
}
|
||||||
dma_release_channel(dws->rxchan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static irqreturn_t dma_transfer(struct dw_spi *dws)
|
static irqreturn_t dma_transfer(struct dw_spi *dws)
|
||||||
|
@ -126,9 +129,6 @@ static bool mid_spi_can_dma(struct spi_controller *master,
|
||||||
{
|
{
|
||||||
struct dw_spi *dws = spi_controller_get_devdata(master);
|
struct dw_spi *dws = spi_controller_get_devdata(master);
|
||||||
|
|
||||||
if (!dws->dma_inited)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return xfer->len > dws->fifo_len;
|
return xfer->len > dws->fifo_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -470,7 +470,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
|
||||||
|
|
||||||
dws->master = master;
|
dws->master = master;
|
||||||
dws->type = SSI_MOTO_SPI;
|
dws->type = SSI_MOTO_SPI;
|
||||||
dws->dma_inited = 0;
|
|
||||||
dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR);
|
dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR);
|
||||||
spin_lock_init(&dws->buf_lock);
|
spin_lock_init(&dws->buf_lock);
|
||||||
|
|
||||||
|
@ -509,7 +508,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
|
||||||
ret = dws->dma_ops->dma_init(dev, dws);
|
ret = dws->dma_ops->dma_init(dev, dws);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_warn(dev, "DMA init failed\n");
|
dev_warn(dev, "DMA init failed\n");
|
||||||
dws->dma_inited = 0;
|
|
||||||
} else {
|
} else {
|
||||||
master->can_dma = dws->dma_ops->can_dma;
|
master->can_dma = dws->dma_ops->can_dma;
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,6 @@ struct dw_spi {
|
||||||
u32 current_freq; /* frequency in hz */
|
u32 current_freq; /* frequency in hz */
|
||||||
|
|
||||||
/* DMA info */
|
/* DMA info */
|
||||||
int dma_inited;
|
|
||||||
struct dma_chan *txchan;
|
struct dma_chan *txchan;
|
||||||
struct dma_chan *rxchan;
|
struct dma_chan *rxchan;
|
||||||
unsigned long dma_chan_busy;
|
unsigned long dma_chan_busy;
|
||||||
|
|
Loading…
Reference in New Issue