From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11B9C37E2EB for ; Tue, 28 Apr 2026 15:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777390336; cv=none; b=KvDKGC5VbXYkHZzj/wHwmJepr2Zy1pZgJUO111iv/pP972OEoEFL5+/B+Ty2VJnTFY9vFQeEn2YJE375Ipp/dqcSWywJzTvIRf9xcNIzjHHGjjLAFKRyWE799DfnAitdzVo9Orv3/JoIJvdCgerln6KlPtZoUGx0xbkRXOh5hoc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777390336; c=relaxed/simple; bh=iq7bihL/7bod5gRoSE+KZVggpv9ssT9oSFB32DKFN48=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cMTH3qvKVx7zVzrRM2w75/MJGHvRnmQFQ4E5YSFTHWPLTofNZg3NT60Y+tL7uwiQp0FjKRes7hDO3DtSm6GrbG5PoQgsFrUkiajY80G/plZChP5dyd1OklNBZ+XXk6G1hPH4MQAibgT7oeszPwJVPnmx6x9uzY6H5jt7APxotdQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=o5i2FGEw; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="o5i2FGEw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 4DBEB4E42B5C; Tue, 28 Apr 2026 15:32:11 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 218EA601D0; Tue, 28 Apr 2026 15:32:11 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A595210728E2C; Tue, 28 Apr 2026 17:32:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777390329; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=pOOUC/6IIIksC8MXl8RMQVMT+zs6jAuaGxEXoJvROdk=; b=o5i2FGEwZ9J4xEw406YB2Qry69Hbl4ztwna6UxopLMtqbuwvDWWBvpduxVugwnP5SZysyI 32/TtKNdp//VVZlLckL5fkEMevwZC08FXZbPa5i01t9MLz2xhe8VUxy0SSdXvWrMylCV7N GJP9LCicRpK/x4FKlWOay3t40qh7QKMGb8OClKhyk+YsnqEs48ZrtxDTbmthmnGsMzmK1+ NJgUkaJ9uVpG3qpJZwpkB/RGhos3KKuJUiMzBYYM70DswRcB13ZIjTKTEDhwR+gpBBFity zlucVzBmy5EHsouy0WKJpkEOiVRbNBUJHPW6M/cU/B5pmBTFTNlRxqDj5NZ6xg== From: Luca Ceresoli Date: Tue, 28 Apr 2026 17:31:00 +0200 Subject: [PATCH v3 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260428-drm-bridge-alloc-getput-panel_or_bridge-v3-11-a537b5567add@bootlin.com> References: <20260428-drm-bridge-alloc-getput-panel_or_bridge-v3-0-a537b5567add@bootlin.com> In-Reply-To: <20260428-drm-bridge-alloc-getput-panel_or_bridge-v3-0-a537b5567add@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 , Xinliang Liu , Sumit Semwal , Yongqin Liu , 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 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