From patchwork Mon May 22 17:03:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 13250889 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3504FC77B75 for ; Mon, 22 May 2023 17:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=As19XckcdVwWPvYrFwemPIM0BXS13e4SBT8pch/COhE=; b=IgteMKG5rZnpcM fEoPMZzUadXdp/ljgTiNzCXqan50EmWR8hX4T/wEuRuhRBa2tjyUt9V9F0+JFOdgMdBTX2r468Vk7 259kQ0KhIMOdP31a8EiLB09HK5HniTFTydvk6LshNhosqMgp9ynrSJSmrPnQQF/xw1GusVvYAmMRJ sUmsaQWuu8oBquBgjnn+4ce+o5a3N+JMthnwKOFWQSDLPL00j/19ch9LNsjdngXQDj/ABIvm13nfu 4uFf9LFmaG1DOxfMesJWXrEYki3tDDBnOJ7HybfyDx/YsTo4ap1w4xIWjsNEQsjvReR8MtBXZ9DNP d6ixXKW6Df679K8Hab0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q18xG-007Ic4-2l; Mon, 22 May 2023 17:04:18 +0000 Received: from madras.collabora.co.uk ([46.235.227.172]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q18wn-007IJi-30; Mon, 22 May 2023 17:03:51 +0000 Received: from jupiter.universe (dyndsl-091-248-208-162.ewe-ip-backbone.de [91.248.208.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 0D45E6606E6F; Mon, 22 May 2023 18:03:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1684775025; bh=aOdRu9IgBBsXxS1i+3a2pCjzvGT6Hcmagn1UYmXetkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iZPGWsHQ05ONMyoFxPyoBnZsYqF53ShQRH/KtCwJzPTjZvSDTHO2twimXkWH7jgbO bMB0hLsm98/il6bGvm53IjZcLQVy5z1YM3+W3bTNTGoD/sWBk/73FiVt2NJqyaXy4e ynlSPUUhC83263oLDQiB2r6lz54MIct2M42bMCxNIK5XZXX+DK4mbQ1g4D9xbCB/ja 02sc8KG4+j+Ub3b/brmfS2+QV6xaqYOM99xIyHaigpiQJiRtlbvx3xh0ZGp7DOijFb mLeg4BsGLryCxkrv950UmBGx+dHkkKciNChr5bFIFuYbjcxzRJg+wOHQBnUpMs42JK gAV0IJkoGfgKQ== Received: by jupiter.universe (Postfix, from userid 1000) id 7FCAB4807EF; Mon, 22 May 2023 19:03:40 +0200 (CEST) From: Sebastian Reichel To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski Cc: Heiko Stuebner , linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCH v3 5/7] phy: phy-rockchip-inno-usb2: simplify phy clock handling Date: Mon, 22 May 2023 19:03:22 +0200 Message-Id: <20230522170324.61349-6-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230522170324.61349-1-sebastian.reichel@collabora.com> References: <20230522170324.61349-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230522_100350_107087_0F31F5E5 X-CRM114-Status: GOOD ( 12.63 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Simplify phyclk handling by using devm_clk_get_optional_enabled to acquire and enable the optional clock. This also fixes a resource leak in driver remove path and adds proper error handling. Signed-off-by: Sebastian Reichel --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index aa8c55609c0d..1cf84869e78b 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1390,24 +1390,22 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) if (IS_ERR(rphy->phy_reset)) return PTR_ERR(rphy->phy_reset); - rphy->clk = of_clk_get_by_name(np, "phyclk"); - if (!IS_ERR(rphy->clk)) { - clk_prepare_enable(rphy->clk); - } else { - dev_info(&pdev->dev, "no phyclk specified\n"); - rphy->clk = NULL; + rphy->clk = devm_clk_get_optional_enabled(dev, "phyclk"); + if (IS_ERR(rphy->clk)) { + return dev_err_probe(&pdev->dev, PTR_ERR(rphy->clk), + "failed to get phyclk\n"); } ret = rockchip_usb2phy_clk480m_register(rphy); if (ret) { dev_err(dev, "failed to register 480m output clock\n"); - goto disable_clks; + return ret; } if (rphy->phy_cfg->phy_tuning) { ret = rphy->phy_cfg->phy_tuning(rphy); if (ret) - goto disable_clks; + return ret; } index = 0; @@ -1470,11 +1468,6 @@ static int rockchip_usb2phy_probe(struct platform_device *pdev) put_child: of_node_put(child_np); -disable_clks: - if (rphy->clk) { - clk_disable_unprepare(rphy->clk); - clk_put(rphy->clk); - } return ret; }