From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC482FF885A for ; Mon, 4 May 2026 10:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pOOUC/6IIIksC8MXl8RMQVMT+zs6jAuaGxEXoJvROdk=; b=Ti80cVDs5u61AaU0dJWZWLwnG2 Vsz/6vG0i6WLrqQtA/zBwewP/ryJ58qpjfMn9c7w0zWH/TcdK1q2IPVghvSN7lRiYr9hm/nvF7S4h G/kULcVJvykx9lCj9coH7q3nctqJodgVtJDm/vR7TLapPc/tFKCv972wvy5hV+UNM3UhT3IjgEaqE 8IaNmmU/iUZZmBGoFfbM6mvfICpAcccOAsbqbk4QA0zZySf6mQwTrkjU9EBUnNdG1zCkm3QBF/Llp sOKa+O3EO5JGYA8p8OmdD1NVeZqwC4OX3DVIt1ewg+GfWMoXBWLwTaH6l/oxxISZnQTUpkGApXo2W UpkCU3yA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wJqoY-0000000Cy7J-16Zr; Mon, 04 May 2026 10:46:14 +0000 Received: from smtpout-04.galae.net ([185.171.202.116]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wJqoV-0000000Cy2i-2TjX for linux-arm-kernel@lists.infradead.org; Mon, 04 May 2026 10:46:13 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 2999DC5D72B; Mon, 4 May 2026 10:46:55 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C95975FD5F; Mon, 4 May 2026 10:46:08 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 581A011AD26A1; Mon, 4 May 2026 12:46:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777891567; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=pOOUC/6IIIksC8MXl8RMQVMT+zs6jAuaGxEXoJvROdk=; b=JISm6dvDSmcY3CpEyUuFv4a2Up2zoXD5vJWycIpCXdTHAp80I46e47C8cVHESIp1rU5tFp fD1oQAdRo4EzdrtlRTpTtYtmOLqTL4IGC5vAMSNwjhhk+U5iAvtPBKb6EfKdU0SYMWDTcR nzEGdEuW9+wMflwMH6/pejXn6zC6iw7DsvNtqvcZiVoJ9zWRvs68Qn7LMyyObxSBkx5fRA S9RGL2BC6PQfi9fPfhGkGbh/ZvsjnOLOToJxRnHTwhT0nMdQObw+tDy1bOCviNROjd9TaN 674tABfuAW1qCWcujUOO4R6gQGTt97A/CkyEduBlNpcl1Eb4aOJAj8j9HgI8gA== From: Luca Ceresoli Date: Mon, 04 May 2026 12:45:14 +0200 Subject: [PATCH v4 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260504-drm-bridge-alloc-getput-panel_or_bridge-v4-11-b578c3daaf10@bootlin.com> References: <20260504-drm-bridge-alloc-getput-panel_or_bridge-v4-0-b578c3daaf10@bootlin.com> In-Reply-To: <20260504-drm-bridge-alloc-getput-panel_or_bridge-v4-0-b578c3daaf10@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , Sumit Semwal , John Stultz , Tomi Valkeinen , Michal Simek Cc: Hui Pu , Ian Ray , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Luca Ceresoli , Dmitry Baryshkov X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260504_034611_926377_D866F076 X-CRM114-Status: GOOD ( 14.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Up to now drm_of_find_panel_or_bridge() can be called with a bridge pointer only, a panel pointer only, or both a bridge and a panel pointers. The logic to handle all the three cases is somewhat complex to read however. Now all bridge-only callers have been converted to of_drm_get_bridge_by_endpoint(), which is simpler and handles bridge refcounting. So forbid new bridge-only users by mandating a non-NULL panel pointer in the docs and in the sanity checks along with a warning. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/drm_of.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index ef6b09316963..d03ada82eac9 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -225,15 +225,15 @@ EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); * @np: device tree node containing encoder output ports * @port: port in the device tree node * @endpoint: endpoint in the device tree node - * @panel: pointer to hold returned drm_panel + * @panel: pointer to hold returned drm_panel, must not be NULL * @bridge: pointer to hold returned drm_bridge * * Given a DT node's port and endpoint number, find the connected node and - * return either the associated struct drm_panel or drm_bridge device. Either - * @panel or @bridge must not be NULL. + * return either the associated struct drm_panel or drm_bridge device. * * This function is deprecated and should not be used in new drivers. Use - * devm_drm_of_get_bridge() instead. + * of_drm_get_bridge_by_endpoint() instead when not looking for a panel, or + * devm_drm_of_get_bridge() otherwise. * * Returns zero if successful, or one of the standard error codes if it fails. */ @@ -245,10 +245,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int ret = -EPROBE_DEFER; struct device_node *remote; - if (!panel && !bridge) + if (WARN_ON(!panel)) return -EINVAL; - if (panel) - *panel = NULL; + + *panel = NULL; /* * of_graph_get_remote_node() produces a noisy error message if port @@ -263,13 +263,11 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, if (!remote) return -ENODEV; - if (panel) { - *panel = of_drm_find_panel(remote); - if (!IS_ERR(*panel)) - ret = 0; - else - *panel = NULL; - } + *panel = of_drm_find_panel(remote); + if (!IS_ERR(*panel)) + ret = 0; + else + *panel = NULL; if (bridge) { if (ret) { -- 2.53.0