In __spi_validate, there's a validation that no partial transfers
are accepted (xfer->len % w_size must be zero). When
max_chunk is not a multiple of bpw (e.g.max_chunk = 65535,
bpw = 16), the transfer will be rejected.

This patch clamps max_chunk to the word size, preventing
the transfer from being rejected.

Signed-off-by: Yunhao Tian <t123yh....@gmail.com>
---
 drivers/gpu/drm/drm_mipi_dbi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
index 71b646c4131f..440dc9fec6cc 100644
--- a/drivers/gpu/drm/drm_mipi_dbi.c
+++ b/drivers/gpu/drm/drm_mipi_dbi.c
@@ -1182,6 +1182,15 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 
speed_hz,
        struct spi_message m;
        size_t chunk;
        int ret;
+       int w_size;
+
+       if (bpw <= 8)
+               w_size = 1;
+       else if (bpw <= 16)
+               w_size = 2;
+       else
+               w_size = 4;
+       max_chunk -= (max_chunk % w_size);
 
        spi_message_init_with_transfers(&m, &tr, 1);
 
-- 
2.25.1

Reply via email to