Skip to content

Commit c534df9

Browse files
fancerbroonie
authored andcommitted
spi: dw: Parameterize the DMA Rx/Tx burst length
It isn't good to have numeric literals in the code especially if there are multiple of them and they are related. Let's replace the Tx and Rx burst level literals with the corresponding constants. Co-developed-by: Georgy Vlasov <[email protected]> Co-developed-by: Ramil Zaripov <[email protected]> Signed-off-by: Georgy Vlasov <[email protected]> Signed-off-by: Ramil Zaripov <[email protected]> Signed-off-by: Serge Semin <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Cc: Alexey Malahov <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Feng Tang <[email protected]> Cc: Rob Herring <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 33726ef commit c534df9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/spi/spi-dw-mid.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
#define WAIT_RETRIES 5
2323
#define RX_BUSY 0
24+
#define RX_BURST_LEVEL 16
2425
#define TX_BUSY 1
26+
#define TX_BURST_LEVEL 16
2527

2628
static bool mid_spi_dma_chan_filter(struct dma_chan *chan, void *param)
2729
{
@@ -227,7 +229,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_tx(struct dw_spi *dws,
227229
memset(&txconf, 0, sizeof(txconf));
228230
txconf.direction = DMA_MEM_TO_DEV;
229231
txconf.dst_addr = dws->dma_addr;
230-
txconf.dst_maxburst = 16;
232+
txconf.dst_maxburst = TX_BURST_LEVEL;
231233
txconf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
232234
txconf.dst_addr_width = convert_dma_width(dws->n_bytes);
233235
txconf.device_fc = false;
@@ -319,7 +321,7 @@ static struct dma_async_tx_descriptor *dw_spi_dma_prepare_rx(struct dw_spi *dws,
319321
memset(&rxconf, 0, sizeof(rxconf));
320322
rxconf.direction = DMA_DEV_TO_MEM;
321323
rxconf.src_addr = dws->dma_addr;
322-
rxconf.src_maxburst = 16;
324+
rxconf.src_maxburst = RX_BURST_LEVEL;
323325
rxconf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
324326
rxconf.src_addr_width = convert_dma_width(dws->n_bytes);
325327
rxconf.device_fc = false;
@@ -344,8 +346,8 @@ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer)
344346
{
345347
u16 imr = 0, dma_ctrl = 0;
346348

347-
dw_writel(dws, DW_SPI_DMARDLR, 0xf);
348-
dw_writel(dws, DW_SPI_DMATDLR, 0x10);
349+
dw_writel(dws, DW_SPI_DMARDLR, RX_BURST_LEVEL - 1);
350+
dw_writel(dws, DW_SPI_DMATDLR, TX_BURST_LEVEL);
349351

350352
if (xfer->tx_buf) {
351353
dma_ctrl |= SPI_DMA_TDMAE;

0 commit comments

Comments
 (0)