From patchwork Mon Oct 25 15:15:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12582127 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7698CC433F5 for ; Mon, 25 Oct 2021 15:16:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 604E860F9B for ; Mon, 25 Oct 2021 15:16:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233937AbhJYPTN (ORCPT ); Mon, 25 Oct 2021 11:19:13 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:41351 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233939AbhJYPSp (ORCPT ); Mon, 25 Oct 2021 11:18:45 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id C70A35806C4; Mon, 25 Oct 2021 11:16:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 25 Oct 2021 11:16:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=R42zJVFPqXWis ftwmhRtrrTmMiiujU+L/s0xKJb/r2o=; b=G8sbIhRWJRjFM0oxtIOygCDXFkJaP OUQZMkypGyaWhvsaPc/2q9LWELPOE6BlD63OmqHvRC41sj0n2E7ITJaJ/GG7DEbx fK/9Fw68nBJV5rUqY5ZcWhaS67vdLAZpWv0kzaHKsYLd7c+VFJ+lRk/Gw0SXEDDx KLpDTL4+CqT7QAhnNJQjmPdXyCsxkMQQB7AdTyFXOVvB6WTdLmvEhSrQ4FngAjJU YFR9OplVESE6wrzBj7bD9V+Jres7fWpMUSaoB8C+XYBBCiNRoxmBoqsauyN/L8M7 7ElY40JBSddbWBigiwogvGajaBEukmkPVFATL9upG4wX6LyoeK1JEed3w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=R42zJVFPqXWisftwmhRtrrTmMiiujU+L/s0xKJb/r2o=; b=N+e9m8RI FV/EKYQ+/XOEEx5lvqdghY7c06ZbXMpwNhVNB+zogu+7QjKAd7Hxa6GgPtUL+6M2 MwKnIGrSylLHEj0N6tWuZv/fuvx37ic9nuU4k+jURY0mB2lOqbAmKsL1MY8Mb1wX xkM37wszviEfUzHxFODtiNRUrO8J0aYgkYaCl5OnhaR0cC71Tfmbcbxi7GBouJEq js7OIQKJpgpczFE18f2UAXKfkmfwlaZ36IxNQ3y4aqZjK7KZT9mgLjJSEL6+R1i4 vec0Xk+DI1xFgrj+z7MfWqhEpOuKGTKDaWxklzw6t89Oth0jilFHO9ifvciNFySz IbtesvdLrFEU0Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvdefhedgkeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepvdekleevfeffkeejhfffueelteelfeduieefheduudfggffhhfffheevveeh hedvnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Oct 2021 11:16:22 -0400 (EDT) From: Maxime Ripard To: Thierry Reding , Laurent Pinchart , Andrzej Hajda , Robert Foss , Jonas Karlman , Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Jernej Skrabec , Sam Ravnborg , Neil Armstrong Cc: Seung-Woo Kim , linux-arm-msm@vger.kernel.org, Joonyoung Shim , Rob Clark , Tian Tao , Chen Feng , Xinwei Kong , Kyungmin Park , linux-samsung-soc@vger.kernel.org, Xinliang Liu , John Stultz , linux-kernel@vger.kernel.org, Inki Dae , dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, Sean Paul Subject: [PATCH v6 16/21] drm/bridge: sn65dsi86: Switch to devm MIPI-DSI helpers Date: Mon, 25 Oct 2021 17:15:31 +0200 Message-Id: <20211025151536.1048186-17-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211025151536.1048186-1-maxime@cerno.tech> References: <20211025151536.1048186-1-maxime@cerno.tech> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's switch to the new devm MIPI-DSI function to register and attach our secondary device. This also avoids leaking the device when we detach the bridge. Acked-by: Sam Ravnborg Signed-off-by: Maxime Ripard --- drivers/gpu/drm/bridge/ti-sn65dsi86.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c index 6154bed0af5b..36a82e3d17ab 100644 --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c @@ -662,6 +662,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge); struct mipi_dsi_host *host; struct mipi_dsi_device *dsi; + struct device *dev = pdata->dev; const struct mipi_dsi_device_info info = { .type = "ti_sn_bridge", .channel = 0, .node = NULL, @@ -701,7 +702,7 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, goto err_dsi_host; } - dsi = mipi_dsi_device_register_full(host, &info); + dsi = devm_mipi_dsi_device_register_full(dev, host, &info); if (IS_ERR(dsi)) { DRM_ERROR("failed to create dsi device\n"); ret = PTR_ERR(dsi); @@ -714,16 +715,16 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, dsi->mode_flags = MIPI_DSI_MODE_VIDEO; /* check if continuous dsi clock is required or not */ - pm_runtime_get_sync(pdata->dev); + pm_runtime_get_sync(dev); regmap_read(pdata->regmap, SN_DPPLL_SRC_REG, &val); - pm_runtime_put_autosuspend(pdata->dev); + pm_runtime_put_autosuspend(dev); if (!(val & DPPLL_CLK_SRC_DSICLK)) dsi->mode_flags |= MIPI_DSI_CLOCK_NON_CONTINUOUS; - ret = mipi_dsi_attach(dsi); + ret = devm_mipi_dsi_attach(dev, dsi); if (ret < 0) { DRM_ERROR("failed to attach dsi to host\n"); - goto err_dsi_attach; + goto err_dsi_host; } pdata->dsi = dsi; @@ -734,14 +735,10 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge, ret = drm_bridge_attach(bridge->encoder, pdata->next_bridge, &pdata->bridge, flags); if (ret < 0) - goto err_dsi_detach; + goto err_dsi_host; return 0; -err_dsi_detach: - mipi_dsi_detach(dsi); -err_dsi_attach: - mipi_dsi_device_unregister(dsi); err_dsi_host: drm_connector_cleanup(&pdata->connector); err_conn_init: @@ -1237,11 +1234,6 @@ static void ti_sn_bridge_remove(struct auxiliary_device *adev) if (!pdata) return; - if (pdata->dsi) { - mipi_dsi_detach(pdata->dsi); - mipi_dsi_device_unregister(pdata->dsi); - } - drm_bridge_remove(&pdata->bridge); of_node_put(pdata->host_node);