From ef369922f4a1be1daa018d52272a798de6b1b7db Mon Sep 17 00:00:00 2001 From: Jon Lin Date: Sat, 4 Jan 2025 12:55:03 +0800 Subject: [PATCH] spi: rockchip_slave: Remove redundant dma_map behavior The driver itself has implemented DMA buffer, and does not require the map/unmap behavior of the spi framework. Change-Id: I00abd65233bf5b3112337c8da623bc8afe586bb6 Signed-off-by: Jon Lin --- drivers/spi/spi-rockchip-slave.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/spi/spi-rockchip-slave.c b/drivers/spi/spi-rockchip-slave.c index ed9e53bf13e6..58377839db0f 100644 --- a/drivers/spi/spi-rockchip-slave.c +++ b/drivers/spi/spi-rockchip-slave.c @@ -471,6 +471,20 @@ static int rockchip_spi_slave_prepare_dma(struct rockchip_spi *rs, return 1; } +static bool rockchip_spi_slave_can_dma(struct spi_controller *ctlr, + struct spi_device *spi, + struct spi_transfer *xfer) +{ + struct rockchip_spi *rs = spi_controller_get_devdata(ctlr); + unsigned int bytes_per_word = xfer->bits_per_word <= 8 ? 1 : 2; + + /* if the numbor of spi words to transfer is less than the fifo + * length we can just fill the fifo and wait for a single irq, + * so don't bother setting up dma + */ + return xfer->len / bytes_per_word >= rs->fifo_len; +} + static int rockchip_spi_slave_config(struct rockchip_spi *rs, struct spi_device *spi, struct spi_transfer *xfer) { @@ -673,7 +687,7 @@ static int rockchip_spi_slave_do_one_msg(struct spi_controller *ctlr, struct spi rs->n_bytes = xfer->bits_per_word <= 8 ? 1 : 2; rs->xfer = xfer; - use_dma = ctlr->can_dma(ctlr, spi, xfer); + use_dma = rockchip_spi_slave_can_dma(ctlr, spi, xfer); if (use_dma) rs->xfer_mode = ROCKCHIP_SPI_DMA; else @@ -724,20 +738,6 @@ out: return 0; } -static bool rockchip_spi_slave_can_dma(struct spi_controller *ctlr, - struct spi_device *spi, - struct spi_transfer *xfer) -{ - struct rockchip_spi *rs = spi_controller_get_devdata(ctlr); - unsigned int bytes_per_word = xfer->bits_per_word <= 8 ? 1 : 2; - - /* if the numbor of spi words to transfer is less than the fifo - * length we can just fill the fifo and wait for a single irq, - * so don't bother setting up dma - */ - return xfer->len / bytes_per_word >= rs->fifo_len; -} - static int rockchip_spi_slave_setup(struct spi_device *spi) { struct rockchip_spi *rs = spi_controller_get_devdata(spi->controller); @@ -885,7 +885,6 @@ static int rockchip_spi_slave_probe(struct platform_device *pdev) } rs->dma_addr_tx = mem->start + ROCKCHIP_SPI_TXDR; rs->dma_addr_rx = mem->start + ROCKCHIP_SPI_RXDR; - ctlr->can_dma = rockchip_spi_slave_can_dma; init_completion(&rs->xfer_done); switch (rs->version) {