| --- a/drivers/spi/spi-mt65xx.c |
| +++ b/drivers/spi/spi-mt65xx.c |
| @@ -720,6 +720,23 @@ static irqreturn_t mtk_spi_interrupt(int |
| 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) |
| { |
| @@ -946,6 +963,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, |
| }; |