mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 03:27:03 +02:00
spi: imx: group spi_imx_dma_configure() with spi_imx_dma_transfer()
Relocate spi_imx_dma_configure() next to spi_imx_dma_transfer() so that all DMA-related functions are grouped together for better readability. No functional changes. Signed-off-by: Carlos Song <carlos.song@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20251203085949.2922166-2-carlos.song@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
8f0b4cce44
commit
c64f62b036
|
|
@ -1282,50 +1282,6 @@ static irqreturn_t spi_imx_isr(int irq, void *dev_id)
|
|||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static int spi_imx_dma_configure(struct spi_controller *controller)
|
||||
{
|
||||
int ret;
|
||||
enum dma_slave_buswidth buswidth;
|
||||
struct dma_slave_config rx = {}, tx = {};
|
||||
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
|
||||
|
||||
switch (spi_imx_bytes_per_word(spi_imx->bits_per_word)) {
|
||||
case 4:
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
||||
break;
|
||||
case 2:
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
|
||||
break;
|
||||
case 1:
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tx.direction = DMA_MEM_TO_DEV;
|
||||
tx.dst_addr = spi_imx->base_phys + MXC_CSPITXDATA;
|
||||
tx.dst_addr_width = buswidth;
|
||||
tx.dst_maxburst = spi_imx->wml;
|
||||
ret = dmaengine_slave_config(controller->dma_tx, &tx);
|
||||
if (ret) {
|
||||
dev_err(spi_imx->dev, "TX dma configuration failed with %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
rx.direction = DMA_DEV_TO_MEM;
|
||||
rx.src_addr = spi_imx->base_phys + MXC_CSPIRXDATA;
|
||||
rx.src_addr_width = buswidth;
|
||||
rx.src_maxburst = spi_imx->wml;
|
||||
ret = dmaengine_slave_config(controller->dma_rx, &rx);
|
||||
if (ret) {
|
||||
dev_err(spi_imx->dev, "RX dma configuration failed with %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_imx_setupxfer(struct spi_device *spi,
|
||||
struct spi_transfer *t)
|
||||
{
|
||||
|
|
@ -1481,6 +1437,50 @@ static int spi_imx_calculate_timeout(struct spi_imx_data *spi_imx, int size)
|
|||
return secs_to_jiffies(2 * timeout);
|
||||
}
|
||||
|
||||
static int spi_imx_dma_configure(struct spi_controller *controller)
|
||||
{
|
||||
int ret;
|
||||
enum dma_slave_buswidth buswidth;
|
||||
struct dma_slave_config rx = {}, tx = {};
|
||||
struct spi_imx_data *spi_imx = spi_controller_get_devdata(controller);
|
||||
|
||||
switch (spi_imx_bytes_per_word(spi_imx->bits_per_word)) {
|
||||
case 4:
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
|
||||
break;
|
||||
case 2:
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
|
||||
break;
|
||||
case 1:
|
||||
buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tx.direction = DMA_MEM_TO_DEV;
|
||||
tx.dst_addr = spi_imx->base_phys + MXC_CSPITXDATA;
|
||||
tx.dst_addr_width = buswidth;
|
||||
tx.dst_maxburst = spi_imx->wml;
|
||||
ret = dmaengine_slave_config(controller->dma_tx, &tx);
|
||||
if (ret) {
|
||||
dev_err(spi_imx->dev, "TX dma configuration failed with %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
rx.direction = DMA_DEV_TO_MEM;
|
||||
rx.src_addr = spi_imx->base_phys + MXC_CSPIRXDATA;
|
||||
rx.src_addr_width = buswidth;
|
||||
rx.src_maxburst = spi_imx->wml;
|
||||
ret = dmaengine_slave_config(controller->dma_rx, &rx);
|
||||
if (ret) {
|
||||
dev_err(spi_imx->dev, "RX dma configuration failed with %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_imx_dma_transfer(struct spi_imx_data *spi_imx,
|
||||
struct spi_transfer *transfer)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user