developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame^] | 1 | --- a/drivers/spi/spi-mt65xx.c |
| 2 | +++ b/drivers/spi/spi-mt65xx.c |
| 3 | @@ -720,6 +720,23 @@ static irqreturn_t mtk_spi_interrupt(int |
| 4 | return IRQ_HANDLED; |
| 5 | } |
| 6 | |
| 7 | +static int mtk_spi_mem_adjust_op_size(struct spi_mem *mem, |
| 8 | + struct spi_mem_op *op) |
| 9 | +{ |
| 10 | + int opcode_len; |
| 11 | + |
| 12 | + if(!op->data.nbytes) |
| 13 | + return 0; |
| 14 | + |
| 15 | + if (op->data.dir != SPI_MEM_NO_DATA) { |
| 16 | + opcode_len = 1 + op->addr.nbytes + op->dummy.nbytes; |
| 17 | + if (opcode_len + op->data.nbytes > MTK_SPI_IPM_PACKET_SIZE) |
| 18 | + op->data.nbytes = MTK_SPI_IPM_PACKET_SIZE -opcode_len; |
| 19 | + } |
| 20 | + |
| 21 | + return 0; |
| 22 | +} |
| 23 | + |
| 24 | static bool mtk_spi_mem_supports_op(struct spi_mem *mem, |
| 25 | const struct spi_mem_op *op) |
| 26 | { |
| 27 | @@ -946,6 +963,7 @@ err_exit: |
| 28 | } |
| 29 | |
| 30 | static const struct spi_controller_mem_ops mtk_spi_mem_ops = { |
| 31 | + .adjust_op_size = mtk_spi_mem_adjust_op_size, |
| 32 | .supports_op = mtk_spi_mem_supports_op, |
| 33 | .exec_op = mtk_spi_mem_exec_op, |
| 34 | }; |