The struct mipi_dsi_device .lanes field is of type unsigned int.
The return value of drm_of_get_data_lanes_count_ep() is signed int,
and therefore cannot be directly assigned into dsi->lanes followed
by check of dsi->lanes < 0 . Instead, assign the return value into
local temporary signed integer and check for negative return, and
if there is no negative return, assign the temporary signed integer
value into dsi->lanes. Note that drm_of_get_data_lanes_count_ep()
assures the return value is clamped to 1..4 or negative, and never
zero.
Fixes: fca11428425e ("drm/bridge: waveshare-dsi: Add support for 1..4 DSI data
lanes")
Reported-by: kernel test robot <[email protected]>
Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/
Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Andrzej Hajda <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Jernej Skrabec <[email protected]>
Cc: Jonas Karlman <[email protected]>
Cc: Laurent Pinchart <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Neil Armstrong <[email protected]>
Cc: Robert Foss <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
drivers/gpu/drm/bridge/waveshare-dsi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/bridge/waveshare-dsi.c
b/drivers/gpu/drm/bridge/waveshare-dsi.c
index 0497c7ecbc7a5..91826c1ffdddf 100644
--- a/drivers/gpu/drm/bridge/waveshare-dsi.c
+++ b/drivers/gpu/drm/bridge/waveshare-dsi.c
@@ -66,11 +66,13 @@ static int ws_bridge_attach_dsi(struct ws_bridge *ws)
dsi->mode_flags = MIPI_DSI_MODE_VIDEO_HSE | MIPI_DSI_MODE_VIDEO |
MIPI_DSI_CLOCK_NON_CONTINUOUS;
dsi->format = MIPI_DSI_FMT_RGB888;
- dsi->lanes = drm_of_get_data_lanes_count_ep(dev->of_node, 0, 0, 1, 4);
- if (dsi->lanes < 0) {
+ ret = drm_of_get_data_lanes_count_ep(dev->of_node, 0, 0, 1, 4);
+ if (ret < 0) {
dev_warn(dev, "Invalid or missing DSI lane count %d, falling
back to 2 lanes\n",
dsi->lanes);
dsi->lanes = 2; /* Old DT backward compatibility */
+ } else {
+ dsi->lanes = ret;
}
ret = devm_mipi_dsi_attach(dev, dsi);
--
2.51.0