lkml.org 
[lkml]   [2022]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] drm/mipi-dbi: Fix max_chunk calculation in spi_transfer
Date
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.xyz@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
\
 
 \ /
  Last update: 2022-03-08 02:57    [W:0.027 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site