From nobody Sat Jun 13 01:48:48 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 EA91E4418D8; Mon, 11 May 2026 16:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517637; cv=none; b=ZibsIsHjLvSVIMAZM6F07fIZNGnsTBfFZ7ml97MeeW8GXrLK78AdlMZD5eRosc9DhKqbj/o9bwBUJTEAcZM7/XKFa+jrelampCIiNpJmo5tJLVkwz2ax3vTVJ2NiV6oSeh+ALAUQO91WKDsTTEtG6IwUvcgvjywFnskh/XL+iO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517637; c=relaxed/simple; bh=8EKurX8ncIs+Umb8J2KQt2w0c09BoJEIbAWgJJiJF0M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dpsw6ZQfAJuwKzcccX1l/4bjBEy30rEvu6HDbmM4R/ijH+cvvTqPzHQ4D3b0j3wqb/V9J2adqdWBMRs2NHuzCqUsPnfrzzkLNhQnYL9s7+Or6qFGt9QRhgpvLxU9RfXI34hucElIPwKiRrQJNMLUTQls0srwlyfLyzTjcWY3au4= 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=nBoDRrVK; arc=none smtp.client-ip=185.171.202.116 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="nBoDRrVK" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id DC017C5E154; Mon, 11 May 2026 16:41:23 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4A71360646; Mon, 11 May 2026 16:40:34 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D003911AF9F72; Mon, 11 May 2026 18:40:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517632; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=du7mTFB8TgiYyJ6C84QWTHR8BuZC820VFo5/kI7Rv0w=; b=nBoDRrVK8+FhTrL3aSUIB8fPvFhZUFzAboftO07DxcnwypyzQgTBW0zbNXnKHdJj4hotvI paPYt7l9iED75uOhb4Uautbry3jwYQ2Hy/RZAIGboQWBQTFyT3g3c5gP15s6iOrJtkRTvv BBO43QoGNokKvDZyF/3yV72m0QVBKP9n1bBKs6V4VFGk5zEmyViypTQJqFbfVwQghvA22Q KY09EkC+5odJYxj1ihjE56a+72/p3XnqBjL2O9qaJ0L47tDLXw1LYiqwrKoZVfWC/VXA75 297MkmgzldjUBtSSdB5o9LjllKrb0WiOcNFsozUu5NbHjNwr/VALUO0Ym3jyMw== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:05 +0200 Subject: [PATCH v6 01/11] drm/bridge: drm_bridge_put(): ignore ERR_PTR 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-1-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 , Laurent Pinchart , Dmitry Baryshkov , Laurent Pinchart X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 Most functions returning a struct drm_bridge pointer currently return a valid pointer or NULL, but this restricts their ability to return an error code as an ERR_PTR describing the error kind. In preparation to have new APIs that can return a struct drm_bridge pointer holding an ERR_PTR (and for those which already do) make drm_bridge_put() ignore ERR_PTR values, just like it ignores NULL pointers. This will avoid annoying error checking in many places and the risk of missing error checks. Suggested-by: Laurent Pinchart Link: https://lore.kernel.org/all/20260318152533.GA633439@killaraus.ideason= board.com/ Suggested-by: Dmitry Baryshkov Link: https://lore.kernel.org/all/omlnswxukeqgnatzdvooaashgkfcacjevkvbkm6xt= 33itgua2k@jcmzll2w6kdq/ Reviewed-by: Dmitry Baryshkov Reviewed-by: Laurent Pinchart Signed-off-by: Luca Ceresoli --- Changes in v5: - don't change drm_bridge_get(), only drm_bridge_put() has known use cases Changes in v4: - removed incorrect change to drm_bridge_clear_and_put() kdoc Patch added in v2 --- drivers/gpu/drm/drm_bridge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index ce180f0b26b2..b46c01db8d83 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -300,7 +300,7 @@ EXPORT_SYMBOL(drm_bridge_get); =20 /** * drm_bridge_put - Release a bridge reference - * @bridge: DRM bridge; if NULL this function does nothing + * @bridge: DRM bridge; if NULL or an ERR_PTR this function does nothing * * This function decrements the bridge's reference count and frees the * object if the reference count drops to zero. @@ -310,7 +310,7 @@ EXPORT_SYMBOL(drm_bridge_get); */ void drm_bridge_put(struct drm_bridge *bridge) { - if (bridge) + if (!IS_ERR_OR_NULL(bridge)) kref_put(&bridge->refcount, __drm_bridge_free); } EXPORT_SYMBOL(drm_bridge_put); --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 091D64418FF for ; Mon, 11 May 2026 16:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517641; cv=none; b=bmm34NJRhXKMUzr/uQzN8tSE9cpV4JQqWIfxpAsQX3jhFJJdIZABgMZbzBKJ9VRneFMIO56FawYGtOjCic3ab/Hr2MJUZupNUuYLBCNS8NvpMNFOXL2j+Y2a9a7fxdVrL4UGqiujQZdJMFZGIYuqbZ+AmQvOXhNApBgErb7sg/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517641; c=relaxed/simple; bh=qr/H2MLRBgBiIE1XwGP7EHrUooywC5n6KijCgj9oaXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=X19lZYbUAnlN4gZlzfadNbxH3c6mObn0gY/wfqDiMEnP6VoWYo/nd++szAnSybt0iaZ5ZuRYQktOVfXgcT+Zp1P7+NLqZJwdAXqhdaMQ6oRezzKtpGrQcLFlbLkNcBR7zUWR12uO+KEyVzumHM14U0nWQpO54huz1gSYLa4N3JE= 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=fbqF2BDh; arc=none smtp.client-ip=185.246.84.56 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="fbqF2BDh" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id A0F731A350B; Mon, 11 May 2026 16:40:38 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6AAC660646; Mon, 11 May 2026 16:40:38 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3322811AF9EEB; Mon, 11 May 2026 18:40:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517636; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=mTxsqV2nFsX5BfihPYr16LuZcRB4011r8fFfYlYi8j4=; b=fbqF2BDh7mxZ58QRkqZwr/JEF/aaCVSEBBNYEobn56aoSCHtoSQD0LL+dmOUxR0JtPi2/+ bfaiBGk89F2zbfhar7QUkGklwElF63zaTcGvjixJ2xOI9kUpf2Ed6XV93O6/x8IAKn7mJe cA+PiPaGz2hISB998ZbbptgyPEcYRP7OBZ4qTMTUAj7gnbXJoiHUKD7hqA1EWQ2OAjbOgp M2QIemMkbMtrLJKdTLoaUQfkAtLp4UKBQ2G1gJUO/kK0YqUeOdFYA9JRs0f9evDHzRpp20 H2wE9J+sPep5EvWs8YLTIr1bTeaoHC2bGtaYnW4Kpo6cWhENUGSCss4gQn5Smg== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:06 +0200 Subject: [PATCH v6 02/11] drm/bridge: add of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-2-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 , Laurent Pinchart X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 drm_of_find_panel_or_bridge() is widely used, but many callers pass NULL into the @panel or the @bridge arguments, thus making a very partial usage of this rather complex function. Besides, the bridge returned in @bridge is not refcounted, thus making this API unsafe when DRM bridge hotplug will be introduced. Solve both issues for the cases of calls to drm_of_find_panel_or_bridge() with a NULL @panel pointer by adding a new function that only looks for bridges (and is thus much simpler) and increments the refcount of the returned bridge. The new function is identical to drm_of_find_panel_or_bridge() except it: - handles bridge refcounting: uses of_drm_find_and_get_bridge() instead of of_drm_find_bridge() internally to return a refcounted bridge - is simpler to use: just takes no @panel parameter, returns the pointer in the return value instead of a double pointer argument - has a simpler implementation: it is equal to drm_of_find_panel_or_bridge() after removing the code that becomes dead when @panel =3D=3D NULL Also add this function to drm_bridge.c and not drm_of.c because it returns bridges only. Reviewed-by: Dmitry Baryshkov Reviewed-by: Laurent Pinchart Signed-off-by: Luca Ceresoli --- Changes in v5: - add missing ERR_PTR() in return statement for no-OF inline variant Changes in v4: - update function declaration in non-OF case - fix grammar in comment Changes in v2: - return the bridge in the return value, not a double pointer --- drivers/gpu/drm/drm_bridge.c | 41 +++++++++++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 7 +++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index b46c01db8d83..687b36eea0c7 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -1582,6 +1582,47 @@ struct drm_bridge *of_drm_find_bridge(struct device_= node *np) return bridge; } EXPORT_SYMBOL(of_drm_find_bridge); + +/** + * of_drm_get_bridge_by_endpoint - return DRM bridge connected to a port/e= ndpoint + * @np: device tree node containing output ports + * @port: port in the device tree node, or -1 for the first port found + * @endpoint: endpoint in the device tree node, or -1 for the first endpoi= nt found + * + * Given a DT node's port and endpoint number, find the connected node and + * return the associated drm_bridge device. + * + * The refcount of the returned bridge is incremented. Use drm_bridge_put() + * when done with it. + * + * Returns a pointer to the connected drm_bridge, or a negative error on f= ailure + */ +struct drm_bridge *of_drm_get_bridge_by_endpoint(const struct device_node = *np, + int port, int endpoint) +{ + struct drm_bridge *bridge; + + /* + * of_graph_get_remote_node() produces a noisy error message if port + * node isn't found and the absence of the port is a legit case here, + * so at first we silently check whether graph is present in the + * device-tree node. + */ + if (!of_graph_is_present(np)) + return ERR_PTR(-ENODEV); + + struct device_node *remote __free(device_node) =3D + of_graph_get_remote_node(np, port, endpoint); + if (!remote) + return ERR_PTR(-ENODEV); + + bridge =3D of_drm_find_and_get_bridge(remote); + if (!bridge) + return ERR_PTR(-EPROBE_DEFER); + + return bridge; +} +EXPORT_SYMBOL_GPL(of_drm_get_bridge_by_endpoint); #endif =20 /** diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index fdac9a526f38..4ba3a5deef9a 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -1327,6 +1327,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, st= ruct drm_bridge *bridge, #ifdef CONFIG_OF struct drm_bridge *of_drm_find_and_get_bridge(struct device_node *np); struct drm_bridge *of_drm_find_bridge(struct device_node *np); +struct drm_bridge *of_drm_get_bridge_by_endpoint(const struct device_node = *np, + int port, int endpoint); #else static inline struct drm_bridge *of_drm_find_and_get_bridge(struct device_= node *np) { @@ -1336,6 +1338,11 @@ static inline struct drm_bridge *of_drm_find_bridge(= struct device_node *np) { return NULL; } +static inline struct drm_bridge *of_drm_get_bridge_by_endpoint(const struc= t device_node *np, + int port, int endpoint) +{ + return ERR_PTR(-ENODEV); +} #endif =20 static inline bool drm_bridge_is_last(struct drm_bridge *bridge) --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 3067D450906; Mon, 11 May 2026 16:40:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517644; cv=none; b=L9fd8Hm2lv1AOfqc6OXl0YutSs7IumU88YKYCr9xodQZw7RmddScBDO7trHyt2EKaKFM857I6NzRknwL7R/83agzWRhZcpoEXz9Txoyh7U9GUlJM6L78m54ppIMlhy3+I7Hg2FYgB22IXWqIPr0RLYEDQ2nWLWVfQti5KcTTv7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517644; c=relaxed/simple; bh=lce+aTTRLhf1XWWeSc0EFw29OaFv8KqBsBL1+8mD/mM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sLpCe/jMr7R7dAU4A+x/imuNFj28M0jDsNTqfdRse3R6hcJNuXT8B7B8UCSOmmGMJFNZSvkTaK/LlhvVmav8GKA+q7ukAS/dA9eLD4jP8DMVfWFhlqN1eEe3Nu8OQkg5xm78QtbLDigxTduIihwu82dqjxYMi3sAu+4qYqKmfU4= 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=TywpEAD7; arc=none smtp.client-ip=185.171.202.116 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="TywpEAD7" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 8AF4FC5E154; Mon, 11 May 2026 16:41:31 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id EF8E760646; Mon, 11 May 2026 16:40:41 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 26AF211AF9F70; Mon, 11 May 2026 18:40:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517640; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=695tIBtiGj0Zt5p+JSC1oz7b/RdXY/fqVD2MgB83H7c=; b=TywpEAD7Uo6nhAi0zlkPDokGJfN0z9RNpa71Y1ZzG9CIbCN9beeMSWqlofXm4mahl1HHOR cDTQJNzwT7j8gJ2n3cyGpa6OVDH7w7Qh8vhmpjgnZ6x4+31EdtzESYLyfb9otJF5Di06xl 6+LFcCA6Zg7KxP1r4sc3YI1sL3W2AhAtTff+5f2pLoH1YbJC83ZgKf5TbSvG1hoja4Hc6Z PTnpkk6B5wG1Udpyl49oxtlyIUBF4NXjvyCvICFYm/zZ9oEtuI+zO2EMz/21aqtWZapHE6 jLvQ1NQETLUODEEBs/lA4EEKlM2qLFlnuyHUhTgo04hHF/492BLWrktCr8XRdQ== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:07 +0200 Subject: [PATCH v6 03/11] drm/msm/hdmi: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-3-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. Signed-off-by: Luca Ceresoli Reviewed-by: Dmitry Baryshkov --- Changes in v6: - move assignment of next_bridge earlier (avoid access before assignment) Changes in v5: - simplify error management code flow Changes in v4: - ensure next_bridge is put on later probe failures Changes in v3: - fix ERR_PTR deref when -ENODEV is returned - move assignment of next_bridge earlier (avoid access before assignment) --- drivers/gpu/drm/msm/hdmi/hdmi.c | 70 +++++++++++++++++++++++++++----------= ---- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdm= i.c index d9491aac1a89..474006084633 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -285,19 +285,27 @@ static int msm_hdmi_dev_probe(struct platform_device = *pdev) spin_lock_init(&hdmi->reg_lock); mutex_init(&hdmi->state_mutex); =20 - ret =3D drm_of_find_panel_or_bridge(dev_of_node(dev), 1, 0, NULL, &hdmi->= next_bridge); - if (ret && ret !=3D -ENODEV) - return ret; + hdmi->next_bridge =3D of_drm_get_bridge_by_endpoint(dev_of_node(dev), 1, = 0); + if (IS_ERR(hdmi->next_bridge)) { + if (PTR_ERR(hdmi->next_bridge) !=3D -ENODEV) + return PTR_ERR(hdmi->next_bridge); + + hdmi->next_bridge =3D NULL; + } =20 hdmi->mmio =3D msm_ioremap(pdev, "core_physical"); - if (IS_ERR(hdmi->mmio)) - return PTR_ERR(hdmi->mmio); + if (IS_ERR(hdmi->mmio)) { + ret =3D PTR_ERR(hdmi->mmio); + goto err_put_bridge; + } =20 /* HDCP needs physical address of hdmi register */ res =3D platform_get_resource_byname(pdev, IORESOURCE_MEM, "core_physical"); - if (!res) - return -EINVAL; + if (!res) { + ret =3D -EINVAL; + goto err_put_bridge; + } hdmi->mmio_phy_addr =3D res->start; =20 hdmi->qfprom_mmio =3D msm_ioremap(pdev, "qfprom_physical"); @@ -307,45 +315,58 @@ static int msm_hdmi_dev_probe(struct platform_device = *pdev) } =20 hdmi->irq =3D platform_get_irq(pdev, 0); - if (hdmi->irq < 0) - return hdmi->irq; + if (hdmi->irq < 0) { + ret =3D hdmi->irq; + goto err_put_bridge; + } =20 hdmi->pwr_regs =3D devm_kcalloc(dev, config->pwr_reg_cnt, sizeof(hdmi->pwr_regs[0]), GFP_KERNEL); - if (!hdmi->pwr_regs) - return -ENOMEM; + if (!hdmi->pwr_regs) { + ret =3D -ENOMEM; + goto err_put_bridge; + } =20 for (i =3D 0; i < config->pwr_reg_cnt; i++) hdmi->pwr_regs[i].supply =3D config->pwr_reg_names[i]; =20 ret =3D devm_regulator_bulk_get(dev, config->pwr_reg_cnt, hdmi->pwr_regs); - if (ret) - return dev_err_probe(dev, ret, "failed to get pwr regulators\n"); + if (ret) { + dev_err_probe(dev, ret, "failed to get pwr regulators\n"); + goto err_put_bridge; + } =20 hdmi->pwr_clks =3D devm_kcalloc(dev, config->pwr_clk_cnt, sizeof(hdmi->pwr_clks[0]), GFP_KERNEL); - if (!hdmi->pwr_clks) - return -ENOMEM; + if (!hdmi->pwr_clks) { + ret =3D -ENOMEM; + goto err_put_bridge; + } =20 for (i =3D 0; i < config->pwr_clk_cnt; i++) hdmi->pwr_clks[i].id =3D config->pwr_clk_names[i]; =20 ret =3D devm_clk_bulk_get(dev, config->pwr_clk_cnt, hdmi->pwr_clks); if (ret) - return ret; + goto err_put_bridge; + =20 hdmi->extp_clk =3D devm_clk_get_optional(dev, "extp"); - if (IS_ERR(hdmi->extp_clk)) - return dev_err_probe(dev, PTR_ERR(hdmi->extp_clk), - "failed to get extp clock\n"); + if (IS_ERR(hdmi->extp_clk)) { + ret =3D dev_err_probe(dev, PTR_ERR(hdmi->extp_clk), + "failed to get extp clock\n"); + goto err_put_bridge; + } =20 hdmi->hpd_gpiod =3D devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); /* This will catch e.g. -EPROBE_DEFER */ - if (IS_ERR(hdmi->hpd_gpiod)) - return dev_err_probe(dev, PTR_ERR(hdmi->hpd_gpiod), - "failed to get hpd gpio\n"); + if (IS_ERR(hdmi->hpd_gpiod)) { + ret =3D dev_err_probe(dev, PTR_ERR(hdmi->hpd_gpiod), + "failed to get hpd gpio\n"); + goto err_put_bridge; + } =20 if (!hdmi->hpd_gpiod) DBG("failed to get HPD gpio"); @@ -355,7 +376,7 @@ static int msm_hdmi_dev_probe(struct platform_device *p= dev) =20 ret =3D msm_hdmi_get_phy(hdmi); if (ret) - return ret; + goto err_put_bridge; =20 ret =3D devm_pm_runtime_enable(dev); if (ret) @@ -371,6 +392,8 @@ static int msm_hdmi_dev_probe(struct platform_device *p= dev) =20 err_put_phy: msm_hdmi_put_phy(hdmi); +err_put_bridge: + drm_bridge_put(hdmi->next_bridge); return ret; } =20 @@ -381,6 +404,7 @@ static void msm_hdmi_dev_remove(struct platform_device = *pdev) component_del(&pdev->dev, &msm_hdmi_ops); =20 msm_hdmi_put_phy(hdmi); + drm_bridge_put(hdmi->next_bridge); } =20 static int msm_hdmi_runtime_suspend(struct device *dev) --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 B85AA45BD7B for ; Mon, 11 May 2026 16:40:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517649; cv=none; b=FgvFENskfesIvGqtduW7zHh75gpc6OUqZTEkyA8RIqS3l4ap12gGiR++X39oePi2R/UB0QKWNaeaMwsU4Lc1lcAVDeEzUiAznVMEKU9ncuNdIQA6Dwwlbu2kOgJGrq2vzfdNLXgC9QUhuPABwEvm04nYTi3/K8aMSDJzWXePGyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517649; c=relaxed/simple; bh=7dVAc6WhvZoPSp6wTgSoPW47pav5rQ4gNzXhkHynCLw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=O86Y2S9u4tX4ZJsauEAtnKfCLjxjcX/4zOc37QIMJpf3TuAI3Ih9rPU1QRMu+eOl4Uu6fW6FP/YcIvoQSeMoT8UF6DCs+GTSGYqIhsWoENBBELqLyPnuiIy131o3iF1dsb14pIkpdRj/dxfNRnVfkKNz6aRAch4Qu/A9a5zc4hY= 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=WDOKyAqE; arc=none smtp.client-ip=185.171.202.116 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="WDOKyAqE" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id B85F4C5E150; Mon, 11 May 2026 16:41:35 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 2655D60646; Mon, 11 May 2026 16:40:46 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 05B6611AF9F75; Mon, 11 May 2026 18:40:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517644; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=xrJ6R82Fk/ZXFNxBH4pvGWdunEuLqdqbyYIvPoA2Kwo=; b=WDOKyAqEF6r1GTY8bKWHD9XA4vnhKJlj5XKlvSVD062lKOSy5bxt8WC5u0ePEdZe8aseV1 ISGV31E8Lh/2eCdHneAs4dXo8TjWCdDyP6JW/OSEYb2gneW5Qg46OtvU6qNjkh0qQD/kb4 iytkEUEv+j5VQqToqseBwi/qySgYK+saeXFGZILreK/RgTUh/H60oJw3+FTDk+oGrB3xD8 fEWdJX03YdOj/uxlfhdrVMfiD4N0nJW2h0wTLLSkQagGfq+w1CrC3MvoM13bV+c3tqlmUX dUXyCZfVVN8T4HkI65yzD4LfuU7moAnLcZ2hxe/8is9GiIOh6ZCy4bPnVfNa9g== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:08 +0200 Subject: [PATCH v6 04/11] drm/hisilicon/kirin: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-4-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. Here the bridge pointer is only stored in a temporary variable, so a cleanup action is enough. Signed-off-by: Luca Ceresoli Reviewed-by: Louis Chauvet --- drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c b/drivers/gpu/drm= /hisilicon/kirin/dw_drm_dsi.c index e80debdc4176..ab3cd309505a 100644 --- a/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c +++ b/drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c @@ -778,17 +778,16 @@ static int dsi_host_init(struct device *dev, struct d= w_dsi *dsi) static int dsi_bridge_init(struct drm_device *dev, struct dw_dsi *dsi) { struct drm_encoder *encoder =3D &dsi->encoder; - struct drm_bridge *bridge; + struct drm_bridge *bridge __free(drm_bridge_put) =3D NULL; struct device_node *np =3D dsi->dev->of_node; - int ret; =20 /* * Get the endpoint node. In our case, dsi has one output port1 * to which the external HDMI bridge is connected. */ - ret =3D drm_of_find_panel_or_bridge(np, 1, 0, NULL, &bridge); - if (ret) - return ret; + bridge =3D of_drm_get_bridge_by_endpoint(np, 1, 0); + if (IS_ERR(bridge)) + return PTR_ERR(bridge); =20 /* associate the bridge to dsi encoder */ return drm_bridge_attach(encoder, bridge, NULL, 0); --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (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 E28D8427A15 for ; Mon, 11 May 2026 16:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517653; cv=none; b=iahIXZNil2xVG+f7ZaHFvnsUJL104md2msWgC96QenRWp6m/tC+VCZkJxl0PHPcFKPBLTICzJPI2bsdRfJZFbW1O/KHP6YLOYB1IPbvDiH3Jjla8q1o59NKIDV51eUKvKEkwuTbXP8CyAOEA48iscXbwy1vMusxIwK9Av2Hsm/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517653; c=relaxed/simple; bh=p/cc4i6wp/YDm7TbqYTtbhBC3u6bzf/lFz86enxa6rU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t6OIyoTVld7PPPmOe+9DbfY840yS9QtZuF1fSHk2bz8QqzvBn2+3Mh/qAh+5AtRo2eD6EH/wOmA9maqCT9CWUlqUhkNer2/VeIadImCYEmO2eHoi97ZM7vGgbyGu37MDj1aU97tQLiXmBB61Lr0w3zjiUlOdjBxYtgh9y8AAZjM= 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=hkHBwjqz; arc=none smtp.client-ip=185.171.202.116 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="hkHBwjqz" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 1B236C5E154; Mon, 11 May 2026 16:41:40 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7C47660646; Mon, 11 May 2026 16:40:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B303A11AF9F77; Mon, 11 May 2026 18:40:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517648; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=aQiLwU4eE3Me1Gr15TTZ3jrsK6Y1VMrcmciESbSasFw=; b=hkHBwjqzvzWjh0GfNSFFgnCxIlEjwB5li1JMUMSgBsA9/RhB7Jnxhk2AzRwp9mCWVEEpkS kjTZ6O6Hk2QLX+KU8lbXD1zsACIyAYKL1/lLicMQxyC8kTqEnQpSScc7AIcqHVnMGtRDdz 2hulpLa57itP3zKJ/SyDpbMf08PCU+nZWMqx7v7z7A25MM91f6ZqgYid6TODBBLRIrGK93 +buXEbdAV0/Pbnup4pVGRQ6vblnU6bLQ7xpCO6jxP8Y031YbCw5CUH20WkSz15nLcKr537 XzxrWzgS1AQT6CEbwIDRVgepTgDVpfprge2QvDK0gQ3l2foQ6aEncBfDovfaTA== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:09 +0200 Subject: [PATCH v6 05/11] drm/bridge: chrontel-ch7033: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-5-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/bridge/chrontel-ch7033.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/chrontel-ch7033.c b/drivers/gpu/drm/bri= dge/chrontel-ch7033.c index 54d49d4882c8..a237c65ebd69 100644 --- a/drivers/gpu/drm/bridge/chrontel-ch7033.c +++ b/drivers/gpu/drm/bridge/chrontel-ch7033.c @@ -199,7 +199,6 @@ enum { =20 struct ch7033_priv { struct regmap *regmap; - struct drm_bridge *next_bridge; struct drm_bridge bridge; struct drm_connector connector; }; @@ -215,7 +214,7 @@ static enum drm_connector_status ch7033_connector_detec= t( { struct ch7033_priv *priv =3D conn_to_ch7033_priv(connector); =20 - return drm_bridge_detect(priv->next_bridge, connector); + return drm_bridge_detect(priv->bridge.next_bridge, connector); } =20 static const struct drm_connector_funcs ch7033_connector_funcs =3D { @@ -233,7 +232,7 @@ static int ch7033_connector_get_modes(struct drm_connec= tor *connector) const struct drm_edid *drm_edid; int ret; =20 - drm_edid =3D drm_bridge_edid_read(priv->next_bridge, connector); + drm_edid =3D drm_bridge_edid_read(priv->bridge.next_bridge, connector); drm_edid_connector_update(connector, drm_edid); if (drm_edid) { ret =3D drm_edid_connector_add_modes(connector); @@ -275,7 +274,7 @@ static int ch7033_bridge_attach(struct drm_bridge *brid= ge, struct drm_connector *connector =3D &priv->connector; int ret; =20 - ret =3D drm_bridge_attach(encoder, priv->next_bridge, bridge, + ret =3D drm_bridge_attach(encoder, priv->bridge.next_bridge, bridge, DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) return ret; @@ -283,15 +282,15 @@ static int ch7033_bridge_attach(struct drm_bridge *br= idge, if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR) return 0; =20 - if (priv->next_bridge->ops & DRM_BRIDGE_OP_DETECT) { + if (priv->bridge.next_bridge->ops & DRM_BRIDGE_OP_DETECT) { connector->polled =3D DRM_CONNECTOR_POLL_HPD; } else { connector->polled =3D DRM_CONNECTOR_POLL_CONNECT | DRM_CONNECTOR_POLL_DISCONNECT; } =20 - if (priv->next_bridge->ops & DRM_BRIDGE_OP_HPD) { - drm_bridge_hpd_enable(priv->next_bridge, ch7033_hpd_event, + if (priv->bridge.next_bridge->ops & DRM_BRIDGE_OP_HPD) { + drm_bridge_hpd_enable(priv->bridge.next_bridge, ch7033_hpd_event, priv); } =20 @@ -299,8 +298,8 @@ static int ch7033_bridge_attach(struct drm_bridge *brid= ge, &ch7033_connector_helper_funcs); ret =3D drm_connector_init_with_ddc(bridge->dev, &priv->connector, &ch7033_connector_funcs, - priv->next_bridge->type, - priv->next_bridge->ddc); + priv->bridge.next_bridge->type, + priv->bridge.next_bridge->ddc); if (ret) { DRM_ERROR("Failed to initialize connector\n"); return ret; @@ -313,8 +312,8 @@ static void ch7033_bridge_detach(struct drm_bridge *bri= dge) { struct ch7033_priv *priv =3D bridge_to_ch7033_priv(bridge); =20 - if (priv->next_bridge->ops & DRM_BRIDGE_OP_HPD) - drm_bridge_hpd_disable(priv->next_bridge); + if (priv->bridge.next_bridge->ops & DRM_BRIDGE_OP_HPD) + drm_bridge_hpd_disable(priv->bridge.next_bridge); drm_connector_cleanup(&priv->connector); } =20 @@ -543,10 +542,9 @@ static int ch7033_probe(struct i2c_client *client) =20 dev_set_drvdata(dev, priv); =20 - ret =3D drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL, - &priv->next_bridge); - if (ret) - return ret; + priv->bridge.next_bridge =3D of_drm_get_bridge_by_endpoint(dev->of_node, = 1, -1); + if (IS_ERR(priv->bridge.next_bridge)) + return PTR_ERR(priv->bridge.next_bridge); =20 priv->regmap =3D devm_regmap_init_i2c(client, &ch7033_regmap_config); if (IS_ERR(priv->regmap)) { --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 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 3A10C46AEFA for ; Mon, 11 May 2026 16:40:56 +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=1778517657; cv=none; b=APBGRLz+CIY4YOynKlfgbe1a0X4BoUub9ildwaLnRh3qzBTR+y438rzR3uIwmLeV1bMgc3PA3H0LyxDPs0SrqenCqd6WrXDbtjS/GazGNU08t6O6nxjPXl0G1Y8uyBi3tD/hwbdNpEMapOOj7ReNH6ACdJcYvGER1THOhqvQvLU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517657; c=relaxed/simple; bh=GHjfR71AMR0n3PcVfZo2YDCc2397+0sTdvTC5OpDP3w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cEI5gtUqh3fjW3N/pPgvR3TICqTCtINeftnjV9tGHpDE9GrZz5Jh1vm1ipyP8eZ/7ddVUhB/v9O0kw7E72oyP2msTnL7D0Ho/3nWk2XY41Md3MwBpx8bU0rhUJ2LYNLkPllpiKbtFOgQmtItYz7So/UcgGr6gAs4w01PfCAxp68= 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=hj1eeppa; 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="hj1eeppa" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id DB83B4E42BF5; Mon, 11 May 2026 16:40:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id A75B160646; Mon, 11 May 2026 16:40:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4B1F811AF9F78; Mon, 11 May 2026 18:40:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517652; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=8MehjA850sW25thLd7/45pWDvM6QQu8N+rXW6HdhVww=; b=hj1eeppaOing1rwGNbz9hq5zBAbwXirYllsco8lmcQKnJr+8+lALjqlOl9jZiaZmL9fGkT ZH7vgFxiAP+wsq4UlgZaNsSYwi3nhjNxyhgk1YwYlTE8VHlR9PzHGXkHKQyoijk/npBQp7 bOrjKtZRsD14zx4d0cN/D9gqRSXbRkrlu5gNZ36iVcQilws/7GYmcjqzW5rUAYA9p5fzGG C2WKBIIHOxnNW8ilsQV0Kvu9U2pWYfee4oXugQ89IQynA1F8alCJbUZ0wAU/KL2wsefE7O imEsBJLmkjR2Hw8Ou1/iRy3i243AqyMvVOpd8C2QWeKIwtrAyYaxFjkFGsZe9g== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:10 +0200 Subject: [PATCH v6 06/11] drm/bridge: lontium-lt9611uxc: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-6-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/bridge/lontium-lt9611uxc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c b/drivers/gpu/drm/b= ridge/lontium-lt9611uxc.c index 11aab07d88df..9427cc2358ae 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611uxc.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611uxc.c @@ -35,7 +35,6 @@ struct lt9611uxc { struct device *dev; struct drm_bridge bridge; - struct drm_bridge *next_bridge; =20 struct regmap *regmap; /* Protects all accesses to registers by stopping the on-chip MCU */ @@ -284,7 +283,7 @@ static int lt9611uxc_bridge_attach(struct drm_bridge *b= ridge, { struct lt9611uxc *lt9611uxc =3D bridge_to_lt9611uxc(bridge); =20 - return drm_bridge_attach(encoder, lt9611uxc->next_bridge, + return drm_bridge_attach(encoder, lt9611uxc->bridge.next_bridge, bridge, flags); } =20 @@ -487,7 +486,11 @@ static int lt9611uxc_parse_dt(struct device *dev, =20 lt9611uxc->dsi1_node =3D of_graph_get_remote_node(dev->of_node, 1, -1); =20 - return drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, <9611uxc-= >next_bridge); + lt9611uxc->bridge.next_bridge =3D of_drm_get_bridge_by_endpoint(dev->of_n= ode, 2, -1); + if (IS_ERR(lt9611uxc->bridge.next_bridge)) + return PTR_ERR(lt9611uxc->bridge.next_bridge); + + return 0; } =20 static int lt9611uxc_gpio_init(struct lt9611uxc *lt9611uxc) --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 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 0FF9144BC82 for ; Mon, 11 May 2026 16:41:00 +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=1778517662; cv=none; b=clPRF4KqsbQgmGsogmKyhHb7uHz/QKVC/iKkehUQDuKuV62HIf8E4v7Pb5NiHNvzsTHG9tYp6bUK8fQLQuuKgj8S08QmNOwzIamYFrAWVf2GYcuE3WQHEp0HCsR0AN34LpDJ+Am6eFFZDKObAq5C7xA3HjKyz4jGsUcniDOTVf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517662; c=relaxed/simple; bh=6bsQ+A/teVFlCjC9RvwNOW0pxRFPJ/Hwoz6F67C1Pdk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RhBajxWC/hSX3X6j0ADB2v/OgxE+mKJZ+N3amrj7Hb/uJRKlOAfH2Z3NcsOGmQwMKTXsCcwsw/ysl4irk2CCgapQs18mKV82FarvXz5/6v7mI4egkgFlKpEkASKTeGbmo1SY+u3aT2RFfznO8c5zNMWcJtik30cH4LudDFoO9lQ= 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=khJWpo1c; 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="khJWpo1c" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 993E74E42BF6; Mon, 11 May 2026 16:40:59 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6BA6760646; Mon, 11 May 2026 16:40:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 90F2D11AF9F73; Mon, 11 May 2026 18:40:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517657; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=+aSetamBxog1tXfF9WLBiQFhYUb4rpTgh/j1AEW1jos=; b=khJWpo1cf1yA6oHhgJQYvcuTOkZyfKPxUGJpfDwJA4GCuxOq38sbIs4ojR0QkP878DuooF DEc9uIW0jQnJdUzKEf08Eojizb4uvXrR/0NGlwbHBdj8INRXOfr2Ze4nx6ctsGLrpS6xik XaDZirI9CUsnTw3vFIe0vx6ZMeBRvGuULK3/hK8+/8h+9BT9LXYsAv4IJ0oV60qBtZOgZV hNBWh82ei5QnFyfCnk8ERnrDtOafkXYHnGlZWjNUFc7C7o5AqZzywpuT+3tDGYw5Z1lRg0 hhjDXB23D0iq/16+QC0UI601wWUm0VctQqSAR4sJR5OnU8lou9JHO476F5nsFA== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:11 +0200 Subject: [PATCH v6 07/11] drm/bridge: lt9611: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-7-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/bridge/lontium-lt9611.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt9611.c b/drivers/gpu/drm/brid= ge/lontium-lt9611.c index 0f49b13193b9..21305296e111 100644 --- a/drivers/gpu/drm/bridge/lontium-lt9611.c +++ b/drivers/gpu/drm/bridge/lontium-lt9611.c @@ -37,7 +37,6 @@ struct lt9611 { struct device *dev; struct drm_bridge bridge; - struct drm_bridge *next_bridge; =20 struct regmap *regmap; =20 @@ -761,7 +760,7 @@ static int lt9611_bridge_attach(struct drm_bridge *brid= ge, { struct lt9611 *lt9611 =3D bridge_to_lt9611(bridge); =20 - return drm_bridge_attach(encoder, lt9611->next_bridge, + return drm_bridge_attach(encoder, lt9611->bridge.next_bridge, bridge, flags); } =20 @@ -1058,7 +1057,11 @@ static int lt9611_parse_dt(struct device *dev, =20 lt9611->ac_mode =3D of_property_read_bool(dev->of_node, "lt,ac-mode"); =20 - return drm_of_find_panel_or_bridge(dev->of_node, 2, -1, NULL, <9611->ne= xt_bridge); + lt9611->bridge.next_bridge =3D of_drm_get_bridge_by_endpoint(dev->of_node= , 2, -1); + if (IS_ERR(lt9611->bridge.next_bridge)) + return PTR_ERR(lt9611->bridge.next_bridge); + + return 0; } =20 static int lt9611_gpio_init(struct lt9611 *lt9611) --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 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 2E659286D7D for ; Mon, 11 May 2026 16:41:06 +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=1778517667; cv=none; b=MBkY+x/oknUDIpJLWmw/fjdYb9+dtJoia56Uq0C9SEaCfOG+34a8udXXLyY/SoQgzshJxcHxaBSYwJcSt6O1MEsIfBlBW8nBNIZZrGcrTD911dBOUgNqup1QklxalrPvpcaoWdpsDjmTIECUJtysRBsx7ELOG9QimkVFOyiATkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517667; c=relaxed/simple; bh=PImxneyEgIrHYm+psJ56Xa0zdiYCyR1kOl96yChwY/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Q/k49MqXNSFrKmQQEteXjuKe9/JuZsalIuNjbTpIwkN42RAsEismtUVf5GfcJLjHBfBO4nxXa9g1mpeiy5Sal3FgGMgcmZJzqCjcaSvB1G8NEKiAjePFqu0xUo+ki0YCn+hHyOO3iA99wzgNEPp1mj54l+nYFFy0p9Xm07NSnTg= 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=pqBC7fY8; 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="pqBC7fY8" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 0D7AA4E42BF4; Mon, 11 May 2026 16:41:05 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D33C560646; Mon, 11 May 2026 16:41:04 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 96CA311AF9F72; Mon, 11 May 2026 18:40:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517662; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=yiYVtzUlza0Qve4SSQyP8HkTKS3obvlG0k3Op32J9Q0=; b=pqBC7fY8RJy5WjC7w+vFEWyLDVMS/NJ+2jTnly/odIJqxFCfdO58ynT8kOfYhSqqZ4lmwP wVF753QdWrWi+v4CgnJWPb82Yq7KVLUsoz5hze8GKlB2ywhVhwgQ/0lGvHJFV4trxAFRFw P6lgCBhdnhRVIFOsEd6WI5YFjeT5uo4d1t/KDT2Vl7ufZTAhWMUEdKCUmXoWFVWllwp3P1 SoKCU9SuF6TY5UbcxsSxs7OCvYVrIrYDpcxkVBp4WzoOIMdiw/oJ4BMj9RefGZ7/stP6dT rXOL3W9Lm7+n3k8LTDRIalec82LHVVbURhGnSRxQGx/gEfFag/VfQYQPDm9z/w== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:12 +0200 Subject: [PATCH v6 08/11] drm/bridge: adv7511: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-8-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 , Biju Das , Dmitry Baryshkov , Laurent Pinchart X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Tested-by: Biju Das Reviewed-by: Dmitry Baryshkov Reviewed-by: Laurent Pinchart Signed-off-by: Luca Ceresoli --- Changes in v3: - fix ERR_PTR deref when -ENODEV is returned --- drivers/gpu/drm/bridge/adv7511/adv7511.h | 1 - drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 15 +++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bri= dge/adv7511/adv7511.h index 8be7266fd4f4..12c95198d9a4 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h @@ -354,7 +354,6 @@ struct adv7511 { enum drm_connector_status status; bool powered; =20 - struct drm_bridge *next_bridge; struct drm_display_mode curr_mode; =20 unsigned int f_tmds; diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm= /bridge/adv7511/adv7511_drv.c index 821a3008a1e7..02f8f7e78a16 100644 --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c @@ -849,8 +849,8 @@ static int adv7511_bridge_attach(struct drm_bridge *bri= dge, struct adv7511 *adv =3D bridge_to_adv7511(bridge); int ret =3D 0; =20 - if (adv->next_bridge) { - ret =3D drm_bridge_attach(encoder, adv->next_bridge, bridge, + if (adv->bridge.next_bridge) { + ret =3D drm_bridge_attach(encoder, adv->bridge.next_bridge, bridge, flags | DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) return ret; @@ -1249,10 +1249,13 @@ static int adv7511_probe(struct i2c_client *i2c) =20 memset(&link_config, 0, sizeof(link_config)); =20 - ret =3D drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL, - &adv7511->next_bridge); - if (ret && ret !=3D -ENODEV) - return ret; + adv7511->bridge.next_bridge =3D of_drm_get_bridge_by_endpoint(dev->of_nod= e, 1, -1); + if (IS_ERR(adv7511->bridge.next_bridge)) { + if (PTR_ERR(adv7511->bridge.next_bridge) =3D=3D -ENODEV) + adv7511->bridge.next_bridge =3D NULL; + else + return PTR_ERR(adv7511->bridge.next_bridge); + } =20 if (adv7511->info->link_config) ret =3D adv7511_parse_dt(dev->of_node, &link_config); --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 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 CF87B44CF2C for ; Mon, 11 May 2026 16:41:10 +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=1778517672; cv=none; b=iSD6vKn0oKeprGFOFIdiBquwrE67qmNCLzc6TkvhLCxKe855vvwJLL13g9l9BjvX81nL5V98PQRahXge+HvYoRtimeva0lRzcOXkbMYC8Cq34j0xm8YI+gL4aipbOEsr4l16LlEBG2TPuoGlcPnRWQfUxzs5kJpD9PS9aD44hoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517672; c=relaxed/simple; bh=7icdOSiHo2mSKNAs1N3XhrO1n59C8GSPKEuCxYKdzVg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jQ8K1mGZwi/+5TyvfjW0hm/ihBDtMyQXbhkjGdbcyoDycU7G3KedSiK4tVNcuXy96CjmeScG0HMKVTicUrPryK7w4dndW13yHGvKAtMqekSll23IzuhWTTKOGd5VsU/Mvs9h5NF/gbW4HPRxrJSlrEohcwPS1EG9gliFOnARago= 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=hSh7W9jC; 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="hSh7W9jC" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 705064E42BF5; Mon, 11 May 2026 16:41:09 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 43BFA60646; Mon, 11 May 2026 16:41:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id D0A4511AF9F70; Mon, 11 May 2026 18:41:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517667; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Ia33JKoZuaR8w6UXmFoEC0QlVGG/UpkjEX+mBP4ds/E=; b=hSh7W9jC8yTb4iDIsxOpUtuQmcteKrzKEAhE4Z6FSuCiXprak2lDEGkUru+40qrjvLoT9l Np3LIEVmSa8HyV5QQVBojpBwxjMhszMgmtcpDv4Ng7FdRo4oXuFYezQo+BOEQVgBYitlOP 3NqNbKCFDrmTXQP2vbVC2Qgy/h8EyZ/LNdrSSVBM5YWFkHBi+4P7hqbm38KREqiDNqdyGQ mK6qpE3TEfSym15fbQZqavHvKy+Ezv8OjfQdHq4Xmi0HN5v2Z8rW4cfUSCUFDwnERXQ+tS IjEWJWgersn3nxhDRNn6thcGnvDIsmq4sExWP8jEzeUdSZ0ylXgeB0oCe2KKvQ== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:13 +0200 Subject: [PATCH v6 09/11] drm/bridge: lt8713sx: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-9-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Reviewed-by: Dmitry Baryshkov Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/bridge/lontium-lt8713sx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/bridge/lontium-lt8713sx.c b/drivers/gpu/drm/br= idge/lontium-lt8713sx.c index 18fac6a46db4..cee485adf5e5 100644 --- a/drivers/gpu/drm/bridge/lontium-lt8713sx.c +++ b/drivers/gpu/drm/bridge/lontium-lt8713sx.c @@ -32,7 +32,6 @@ DECLARE_CRC8_TABLE(lt8713sx_crc_table); struct lt8713sx { struct device *dev; struct drm_bridge bridge; - struct drm_bridge *next_bridge; =20 struct regmap *regmap; /* Protects all accesses to registers by stopping the on-chip MCU */ @@ -458,7 +457,7 @@ static int lt8713sx_bridge_attach(struct drm_bridge *br= idge, struct lt8713sx *lt8713sx =3D container_of(bridge, struct lt8713sx, bridg= e); =20 return drm_bridge_attach(encoder, - lt8713sx->next_bridge, + lt8713sx->bridge.next_bridge, bridge, flags); } =20 @@ -537,10 +536,9 @@ static int lt8713sx_probe(struct i2c_client *client) if (IS_ERR(lt8713sx->regmap)) return dev_err_probe(dev, PTR_ERR(lt8713sx->regmap), "regmap i2c init fa= iled\n"); =20 - ret =3D drm_of_find_panel_or_bridge(lt8713sx->dev->of_node, 1, -1, NULL, - <8713sx->next_bridge); - if (ret < 0) - return ret; + lt8713sx->bridge.next_bridge =3D of_drm_get_bridge_by_endpoint(lt8713sx->= dev->of_node, 1, -1); + if (IS_ERR(lt8713sx->bridge.next_bridge)) + return PTR_ERR(lt8713sx->bridge.next_bridge); =20 ret =3D lt8713sx_gpio_init(lt8713sx); if (ret < 0) --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 0C4D846AEDF for ; Mon, 11 May 2026 16:41:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517677; cv=none; b=Mt7ljNif2vQvocjyxFcTZE+YlSTtAYqBRR2KQSOff+yArgN/AmFr1GfoUYSaZa1Ia3TIt4ch30/8UwT/xpsgqVGGjJecsdIlywMy6MQkEydPto/RT1HSBsNNGMJ0li5vo9hxeZDhqDzrZJY4CllkW4jas5ruC3pNKKtXF/BEkNw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517677; c=relaxed/simple; bh=GjaGlWYw5vi3RHQoYU2e2g/mtlTAGA3+eYoNefZUjpI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cpYGSNL1CcPndyfmUDEQOyiDI+t3nAHG326pF0XvOeSrQ3lqY5zfkEinsHVLmWg/G+qBsX4r9E+jjcJGus09GecsO6IwfSokh/yXmOToviyzA6Auej0IIIa37i+nzUtvz6DnkOX8CaHNwDhKs7mj2jY9OftadiLc8OEWwcejcmA= 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=gOiN3aSj; arc=none smtp.client-ip=185.246.84.56 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="gOiN3aSj" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 871561A3529; Mon, 11 May 2026 16:41:13 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5A19660646; Mon, 11 May 2026 16:41:13 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 027AD11AF9F75; Mon, 11 May 2026 18:41:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517671; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=uL1aJPopaCnPJg4xAy7YfNqjGDLGk+EbewEWLZewSaY=; b=gOiN3aSjhfH1yPbLvUML80A9+drIOn7gLEwgNryNYOO0TqERHvw5jcbzAeimfWNEbSaHZB /ffzmDPItoBuZ/GhQ+45iRqFD619dCZbFuwP9BGsmOEIMH/YnSlfCD5nn1uZl+IqB4v0DW WIxBmdrDoBEE9s6Q3VU/0/wAvb5ifdycDWspERq23hpVOE3snWWe0+GGbGdlZbevr1mS/A E4YFub+tCSLFqW1s/sjL8efLYUabrjNK+hZtsovDbr3DTMi8wVxMJ5RCFJNieHBkmxCMZp ooHT+OILaLWrWo60yhB9XVVEYhuZ4RjZHtpK51u29VZ7P3L3uJj5gdTD+J3EFw== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:14 +0200 Subject: [PATCH v6 10/11] drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint() 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-10-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 , Laurent Pinchart X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Reviewed-by: Laurent Pinchart Signed-off-by: Luca Ceresoli --- Changes in v4: - fix missing assignment - simplify error management code flow Changes in v3: - fix ERR_PTR deref when -ENODEV is returned --- drivers/gpu/drm/xlnx/zynqmp_dp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp= _dp.c index 05bd31fe675b..7fb11b0a44f0 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -353,7 +353,6 @@ struct zynqmp_dp_train_set_priv { * @lock: Mutex protecting this struct and register access (but not AUX) * @irq: irq * @bridge: DRM bridge for the DP encoder - * @next_bridge: The downstream bridge * @test: Configuration for test mode * @config: IP core configuration from DTS * @aux: aux channel @@ -385,7 +384,6 @@ struct zynqmp_dp { struct completion aux_done; struct mutex lock; =20 - struct drm_bridge *next_bridge; struct device *dev; struct zynqmp_dpsub *dpsub; void __iomem *iomem; @@ -1494,8 +1492,8 @@ static int zynqmp_dp_bridge_attach(struct drm_bridge = *bridge, return ret; } =20 - if (dp->next_bridge) { - ret =3D drm_bridge_attach(encoder, dp->next_bridge, + if (dp->bridge.next_bridge) { + ret =3D drm_bridge_attach(encoder, dp->bridge.next_bridge, bridge, flags); if (ret < 0) goto error; @@ -2461,10 +2459,15 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) * Acquire the next bridge in the chain. Ignore errors caused by port@5 * not being connected for backward-compatibility with older DTs. */ - ret =3D drm_of_find_panel_or_bridge(dp->dev->of_node, 5, 0, NULL, - &dp->next_bridge); - if (ret < 0 && ret !=3D -ENODEV) - goto err_reset; + dp->bridge.next_bridge =3D of_drm_get_bridge_by_endpoint(dp->dev->of_node= , 5, 0); + if (IS_ERR(dp->bridge.next_bridge)) { + if (PTR_ERR(dp->bridge.next_bridge) !=3D -ENODEV) { + ret =3D PTR_ERR(dp->bridge.next_bridge); + goto err_reset; + } + + dp->bridge.next_bridge =3D NULL; + } =20 /* Initialize the hardware. */ dp->config.misc0 &=3D ~ZYNQMP_DP_MAIN_STREAM_MISC0_SYNC_LOCK; --=20 2.54.0 From nobody Sat Jun 13 01:48:48 2026 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 26FD8477E51 for ; Mon, 11 May 2026 16:41:20 +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=1778517681; cv=none; b=EXS/cMhcWKR4ptupCbu2fY3VZthmwMZ564tfP8rIrhZndPpMeT5muhXwd12h/3FbhCEQI+9x4AhI/tPJnKbUZT8cYBoUq8F54CX+soE7xnAcwSmPXgy6OUkxWpq0ohHA078mhK0jK4spqjBcYVCguCtwsm2gBMnh4OD9fDKtFKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778517681; c=relaxed/simple; bh=N00dKcMMhlZFbvO5gMJYz8FkOVIuJ9KHdYXngIMJETE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XVgWeWJj11a1X78pVdbWXU7HK+2WwAGaoy6L0c+2fovERCdsPtmHk0n53ZMysPqkgaxtvDqR8NfPHxpfF0OC0m84h0ovsP9WbZ+EXVKJC3sqWz0vYhyASStgAbchn6Ra00/hggVRCjx3yZRxRPscdBe/WVfNE5PDckhF0tywCTs= 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=u1oxO7sr; 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="u1oxO7sr" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 02F334E42BF5; Mon, 11 May 2026 16:41:19 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C966560646; Mon, 11 May 2026 16:41:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6040F11AF9F7C; Mon, 11 May 2026 18:41:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1778517676; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=2UxxWf9CEg75RZLf6dSEu0deL3RvVtRrxoEWj8XzsRg=; b=u1oxO7srhKo2zO0ajkX3fx+b0/B7r/NeD17pvOk4jW6MHZbxN9PZFbG1qE8E40cwCToDqq 5uAXo9jZhJe2K8CRrKEGDeH3cHJPd8sxl3gDeiTRPXOVgqfZbavuJ8re9u5mK2uO/qs++T GQ+WveOMkj9EfFoPB4LwU8BT8+fyAegIvxqsjqlPqzoyan4r6cuiIpGqSnEE+NEAdy02pc NTFkKbStmsMe4CcKH3fRKQ8vyUHwseD+JPbL6uZmUMsGwmFDLOZKs78oj469zAs53Nz5gd dPTAc7x3gW0ox5E8NHRqT311AdWlwyhT5FlLBKJWa3kxJzihKUaxOm1Qra8UDg== From: Luca Ceresoli Date: Mon, 11 May 2026 18:40:15 +0200 Subject: [PATCH v6 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: quoted-printable Message-Id: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-11-f61c9e498b3f@bootlin.com> References: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@bootlin.com> In-Reply-To: <20260511-drm-bridge-alloc-getput-panel_or_bridge-v6-0-f61c9e498b3f@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 , Laurent Pinchart 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 Reviewed-by: Laurent Pinchart 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. Eit= her - * @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 fa= ils. */ @@ -245,10 +245,10 @@ int drm_of_find_panel_or_bridge(const struct device_n= ode *np, int ret =3D -EPROBE_DEFER; struct device_node *remote; =20 - if (!panel && !bridge) + if (WARN_ON(!panel)) return -EINVAL; - if (panel) - *panel =3D NULL; + + *panel =3D NULL; =20 /* * 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_n= ode *np, if (!remote) return -ENODEV; =20 - if (panel) { - *panel =3D of_drm_find_panel(remote); - if (!IS_ERR(*panel)) - ret =3D 0; - else - *panel =3D NULL; - } + *panel =3D of_drm_find_panel(remote); + if (!IS_ERR(*panel)) + ret =3D 0; + else + *panel =3D NULL; =20 if (bridge) { if (ret) { --=20 2.54.0