| From 8efe8045522d7bd790b9ae7408c64f497a54e643 Mon Sep 17 00:00:00 2001 |
| From: Sam Shih <sam.shih@mediatek.com> |
| Date: Fri, 2 Jun 2023 13:06:18 +0800 |
| Subject: [PATCH] |
| [spi-and-storage][999-2363-spi-mediatek-fix-timeout-for-large-data.patch] |
| |
| --- |
| drivers/spi/spi-mt65xx.c | 18 ++++++++++++++++++ |
| 1 file changed, 18 insertions(+) |
| |
| diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c |
| index dbb471769..871eff03f 100644 |
| --- a/drivers/spi/spi-mt65xx.c |
| +++ b/drivers/spi/spi-mt65xx.c |
| @@ -721,6 +721,23 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id) |
| return IRQ_HANDLED; |
| } |
| |
| +static int mtk_spi_mem_adjust_op_size(struct spi_mem *mem, |
| + struct spi_mem_op *op) |
| +{ |
| + int opcode_len; |
| + |
| + if(!op->data.nbytes) |
| + return 0; |
| + |
| + if (op->data.dir != SPI_MEM_NO_DATA) { |
| + opcode_len = 1 + op->addr.nbytes + op->dummy.nbytes; |
| + if (opcode_len + op->data.nbytes > MTK_SPI_IPM_PACKET_SIZE) |
| + op->data.nbytes = MTK_SPI_IPM_PACKET_SIZE -opcode_len; |
| + } |
| + |
| + return 0; |
| +} |
| + |
| static bool mtk_spi_mem_supports_op(struct spi_mem *mem, |
| const struct spi_mem_op *op) |
| { |
| @@ -947,6 +964,7 @@ err_exit: |
| } |
| |
| static const struct spi_controller_mem_ops mtk_spi_mem_ops = { |
| + .adjust_op_size = mtk_spi_mem_adjust_op_size, |
| .supports_op = mtk_spi_mem_supports_op, |
| .exec_op = mtk_spi_mem_exec_op, |
| }; |
| -- |
| 2.34.1 |
| |