From patchwork Thu Oct 21 07:39:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12574169 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 2CDFEC433FE for ; Thu, 21 Oct 2021 07:42:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17CF3610CF for ; Thu, 21 Oct 2021 07:42:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231573AbhJUHoO (ORCPT ); Thu, 21 Oct 2021 03:44:14 -0400 Received: from wnew3-smtp.messagingengine.com ([64.147.123.17]:59681 "EHLO wnew3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231750AbhJUHnY (ORCPT ); Thu, 21 Oct 2021 03:43:24 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id D4BDE2B01362; Thu, 21 Oct 2021 03:41:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 21 Oct 2021 03:41:08 -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=Ve5FuXreqcW5s8yaQ57TY8cqWF0Mn X7rVMHZlmysTlXXYtuLF2bKCB1SMfBUkayHBhetIFmBTtzC34FPmujgmzzzW7N7C 9saPIQ/28xVQN7DDK/EZ0UzNoF0em2JYW+tRVqaN1iPnCOi0HXek8jPzMHpjQEfH CSvuIjUv8lrNRmTm+B5k2hluHQ8UtA1XZByjxohS2Fsyth245LxqcDjUjfI4b6x5 AzRzm+MbkiSX5IljAFZNYB1sgp1DDDP1g2+7tZM41f8KY3hkvkkb3ccBtrh7sptC W4DIMh25bLsbGL8v/olDfxQpOH9ltvvw/eLiQAKXWMOCdF1087dFNVRuw== 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=bbPguaPW hWfirR9U1m+UYX5PsZLYsUt262l+CTFntR+ytG9PLhle7+tr7JZI227bZ+mNNV5J Urz+QKUUOPdgVTDwTPbIhPtsczYlpLg7en92Edxfm9zOtbRC8vF6mlSdelSjeUwN TrPexa91VU9fSQ6QfuLTrjCMC7Erf8tDFzAPyOzI8Aaopkc34szK3yxgUZII2rWY LGotj6Z0pH2lstrkiFtzBoiy24mlSB4qxB5RPl4Dx9AFcz0R3qzX863ik4LAyEnX xXLwLxS6GBt31dDTy8skjll7y0H6BZD9JtCXyeDzapvwrNmfHa40FcxNvitqRJKq XzELclE/IbKh2A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddvhedgudduiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpedvkeelveefffekjefhffeuleetleefudeifeehuddugffghffhffehveev heehvdenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 21 Oct 2021 03:41:05 -0400 (EDT) From: Maxime Ripard To: Laurent Pinchart , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard , Sam Ravnborg , Daniel Vetter , David Airlie , Thierry Reding , Andrzej Hajda , Robert Foss , Neil Armstrong , Jonas Karlman , Jernej Skrabec Cc: Seung-Woo Kim , Xinliang Liu , linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Tian Tao , freedreno@lists.freedesktop.org, Chen Feng , Joonyoung Shim , Kyungmin Park , John Stultz , Rob Clark , linux-arm-msm@vger.kernel.org, Sean Paul , Inki Dae , Xinwei Kong , dri-devel@lists.freedesktop.org Subject: [PATCH v5 16/21] drm/bridge: sn65dsi86: Switch to devm MIPI-DSI helpers Date: Thu, 21 Oct 2021 09:39:42 +0200 Message-Id: <20211021073947.499373-17-maxime@cerno.tech> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211021073947.499373-1-maxime@cerno.tech> References: <20211021073947.499373-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);