From: Neil Armstrong Subject: [RFC 01/11] fixup! drm/bridge: Add the necessary bits to support bus format negotiation Date: Tue, 20 Aug 2019 10:40:59 +0200 Message-ID: <20190820084109.24616-2-narmstrong@baylibre.com> References: <20190820084109.24616-1-narmstrong@baylibre.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190820084109.24616-1-narmstrong@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org To: a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@siol.net, boris.brezillon@collabora.com Cc: Neil Armstrong , linux-amlogic@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org List-Id: dri-devel@lists.freedesktop.org > + } else if (b->num_supported_fmts > 1 && b->supported_fmts) { > + *selected_bus_fmt = b->supported_fmts[0]; > + return 0; Here, `!a->num_supported_fmts &&` is missing otherwise this code will select b->supported_fmts[0] whatever the supported formats of a. > + } else if (a->num_supported_fmts > 1 && a->supported_fmts) { > + *selected_bus_fmt = a->supported_fmts[0]; > + return 0; Here, `!b->num_supported_fmts &&` is missing otherwise this code will select a->supported_fmts[0] whatever the supported formats of b. Signed-off-by: Neil Armstrong --- drivers/gpu/drm/drm_bridge.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 5f0925467292..82fe7728fcd1 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -615,10 +615,12 @@ int drm_find_best_bus_format(const struct drm_bus_caps *a, if (!a->num_supported_fmts && !b->num_supported_fmts) { *selected_bus_fmt = 0; return 0; - } else if (b->num_supported_fmts > 1 && b->supported_fmts) { + } else if (!a->num_supported_fmts && + b->num_supported_fmts > 1 && b->supported_fmts) { *selected_bus_fmt = b->supported_fmts[0]; return 0; - } else if (a->num_supported_fmts > 1 && a->supported_fmts) { + } else if (!b->num_supported_fmts && + a->num_supported_fmts > 1 && a->supported_fmts) { *selected_bus_fmt = a->supported_fmts[0]; return 0; } else if (!a->num_supported_fmts || !a->supported_fmts || -- 2.22.0