From nobody Mon Dec 1 22:36:47 2025 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 4218C2C0F79; Fri, 28 Nov 2025 16:55:37 +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=1764348939; cv=none; b=Atsuz/aRrB9cz+3wrKqIdVc0dNqC3QgkeEcnAWMUhzeMEclB6ebmG6au9apHdQ6KNZOz1Q0uD/MVPvhB04HUTxBlD7w70xa4aZ2Y4GKuh8RrMWv7m48LI076t8+u+V9u5ZHLHtPmyqitkazVluhzVuUQNLeToo1VBBUbOwypTBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764348939; c=relaxed/simple; bh=kdMvbE9NXnFedS4vlmdyGovXQv35HqvvYWQQJDVYKzM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CHkxMWrmHr0PpkFRRKZDu27cLwM66bxOtOFOA0R/ZG6IRpMBg31dWJh1ji6DCrl6MdEap38tb1xRzZdUeVikWwjP9CmtpLH/1kiG6KzmuAYeBsXb6eKqSCVXLGeiUaeAA0tuvnRdNqu6jp4LVceUeDW5YBSQ4Ia9ReRlNozE7Eo= 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=k/OYs4Rp; 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="k/OYs4Rp" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 035751A1E0C; Fri, 28 Nov 2025 16:55:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C272B60706; Fri, 28 Nov 2025 16:55:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 832B510B021A5; Fri, 28 Nov 2025 17:55:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1764348933; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=w1vAMoKEVFgHijlnGupKEv319mUXS/TmzsSZZzLsZgQ=; b=k/OYs4RpuyCO8HqfjtIrYwBUOVvdUHmV4yuUO/y2/qxRq0uW+XkyslVfrZqAdsPoWdaXEw v7uAdiYQNA558rxnUuUvPi8SNTBPOeEvfdAz4X/mzlIif74abvEt/uAtnQvzGPA2qgdqut +/+wLFobRLBhH1E+kBtUEeZslXY/9Maed+C+aB3sIuS1+rpAjH392PgbRlYwOTdGFDsYcV NXsRj+53bfJwu/Y0MhMctKIa7TWEj7OZzQEcIsnfMD3gtG/l2tTKV+DgrjPWk6wTB+yl4X GyaheEwLH7Le2FfG6wgKVIptLkDQLscwXE5iznKIc36DNuFBZntPPdlNYaW6NA== From: Luca Ceresoli Date: Fri, 28 Nov 2025 17:50:36 +0100 Subject: [PATCH v2 26/26] drm/bridge: imx8qxp-pixel-link: convert to of_drm_get_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: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-26-88f8a107eca2@bootlin.com> References: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-0-88f8a107eca2@bootlin.com> In-Reply-To: <20251128-drm-bridge-alloc-getput-drm_of_find_bridge-v2-0-88f8a107eca2@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 , Jonathan Corbet , Alexey Brodkin , Phong LE , Liu Ying , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Adrien Grassein , Laurent Pinchart , Tomi Valkeinen , Kieran Bingham , Geert Uytterhoeven , Magnus Damm , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Chun-Kuang Hu , Philipp Zabel , Matthias Brugger , AngeloGioacchino Del Regno , Anitha Chrisanthus , Inki Dae , Seung-Woo Kim , Kyungmin Park , Krzysztof Kozlowski , Alim Akhtar Cc: Hui Pu , Thomas Petazzoni , Louis Chauvet , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-samsung-soc@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 of_drm_find_bridge() is deprecated. Move to its replacement of_drm_get_bridge() which gets a bridge reference, and put it when done. This needs to be handled in various steps: * the bridge returned of_drm_get_bridge() is stored in next_bridge whose scope is the for loop, so a cleanup action is enough * the value of next_bridge is copied into selected_bridge, potentially more than once, so a cleanup action at function scope is useful here too * however on successful return selected_bridge must be returned and ultimately stored, so it should not be put in that case: use return_ptr() to defuse the cleanup action on successful return * finally, put the bridge reference on device remove Signed-off-by: Luca Ceresoli --- Cc: Liu Ying --- drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c b/drivers/gpu/= drm/bridge/imx/imx8qxp-pixel-link.c index 2ecc3c1051e5..4f2f730142ea 100644 --- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c +++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-link.c @@ -256,12 +256,13 @@ static int imx8qxp_pixel_link_disable_all_controls(st= ruct imx8qxp_pixel_link *pl return imx8qxp_pixel_link_disable_sync(pl); } =20 +/* The returned bridge has its refcount incremented */ static struct drm_bridge * imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixel_link *pl) { struct device_node *np =3D pl->dev->of_node; struct device_node *port; - struct drm_bridge *selected_bridge =3D NULL; + struct drm_bridge *selected_bridge __free(drm_bridge_put) =3D NULL; u32 port_id; bool found_port =3D false; int reg; @@ -298,7 +299,7 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pixe= l_link *pl) continue; } =20 - struct drm_bridge *next_bridge =3D of_drm_find_bridge(remote); + struct drm_bridge *next_bridge __free(drm_bridge_put) =3D of_drm_get_bri= dge(remote); if (!next_bridge) return ERR_PTR(-EPROBE_DEFER); =20 @@ -306,13 +307,15 @@ imx8qxp_pixel_link_find_next_bridge(struct imx8qxp_pi= xel_link *pl) * Select the next bridge with companion PXL2DPI if * present, otherwise default to the first bridge */ - if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2d= pi")) - selected_bridge =3D next_bridge; + if (!selected_bridge || of_property_present(remote, "fsl,companion-pxl2d= pi")) { + drm_bridge_put(selected_bridge); + selected_bridge =3D drm_bridge_get(next_bridge); + } } =20 pl->mst_addr =3D port_id - 1; =20 - return selected_bridge; + return_ptr(selected_bridge); } =20 static int imx8qxp_pixel_link_bridge_probe(struct platform_device *pdev) @@ -392,6 +395,7 @@ static void imx8qxp_pixel_link_bridge_remove(struct pla= tform_device *pdev) struct imx8qxp_pixel_link *pl =3D platform_get_drvdata(pdev); =20 drm_bridge_remove(&pl->bridge); + drm_bridge_put(pl->next_bridge); } =20 static const struct of_device_id imx8qxp_pixel_link_dt_ids[] =3D { --=20 2.51.1