From patchwork Wed Jul 19 07:18:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 13318437 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 86CB7C0015E for ; Wed, 19 Jul 2023 07:20:34 +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=tWskXSkm9aDYSzl7jcI16mdMRIjisI3ujJT8oul1xEc=; b=LVeu/WmQkxJzt8 dDhhP4jX+ZXXHvxeb9rvcShDFG6v90/aY3A5LFDd+9TVIDFBIoO+4TKCSXwVlTJCeVY0VfHbT9grc qkkBjjRdraJGfMDETAq9B6X3ZYtURxVRw/GMNLQ9NSAF1u+1oo0gKJ42dhG5L11vNDNEUuGy9Sjhx S13+8+H6LR4YTJAuPNrkGtUmVZMsOHsQtJTfKDWgviVnOA+ZxK5FmYgLDwVEXsXmsfsTMOSbBs79b ztcRq2zbDob5u7m2EFhs5FnMGgMIF7WmzdYVQ/yvydcDJw/DXsaMajymkLC1f4r+x44OqlVS1CZXr 4fp41dA0BiNPs+B3KDeQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM1Tu-0064VF-17; Wed, 19 Jul 2023 07:20:18 +0000 Received: from viti.kaiser.cx ([2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM1Tq-0064T0-33 for linux-arm-kernel@lists.infradead.org; Wed, 19 Jul 2023 07:20:16 +0000 Received: from ipservice-092-217-093-053.092.217.pools.vodafone-ip.de ([92.217.93.53] helo=martin-debian-2.paytec.ch) by viti.kaiser.cx with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1qM1Tl-0008I7-L0; Wed, 19 Jul 2023 09:20:09 +0200 From: Martin Kaiser To: Herbert Xu Cc: linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 2/4] hwrng: cctrng - let devres enable the clock Date: Wed, 19 Jul 2023 09:18:04 +0200 Message-Id: <20230719071806.335718-3-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230719071806.335718-1-martin@kaiser.cx> References: <20230719071806.335718-1-martin@kaiser.cx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_002015_150197_9BDBD5E1 X-CRM114-Status: GOOD ( 13.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Call devm_clk_get_optional_enabled in the cctrng driver. We don't have to disable and unprepare the clock any more in error paths or in the remove function. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/cctrng.c | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c index 241da7e44675..ac4a2fbc6a0f 100644 --- a/drivers/char/hw_random/cctrng.c +++ b/drivers/char/hw_random/cctrng.c @@ -460,30 +460,16 @@ static int cc_trng_clk_init(struct cctrng_drvdata *drvdata) { struct clk *clk; struct device *dev = &(drvdata->pdev->dev); - int rc = 0; - clk = devm_clk_get_optional(dev, NULL); + clk = devm_clk_get_optional_enabled(dev, NULL); if (IS_ERR(clk)) return dev_err_probe(dev, PTR_ERR(clk), - "Error getting clock\n"); + "Failed to get or enable the clock\n"); drvdata->clk = clk; - - rc = clk_prepare_enable(drvdata->clk); - if (rc) { - dev_err(dev, "Failed to enable clock\n"); - return rc; - } - return 0; } -static void cc_trng_clk_fini(struct cctrng_drvdata *drvdata) -{ - clk_disable_unprepare(drvdata->clk); -} - - static int cctrng_probe(struct platform_device *pdev) { struct cctrng_drvdata *drvdata; @@ -545,7 +531,7 @@ static int cctrng_probe(struct platform_device *pdev) rc = devm_request_irq(dev, irq, cc_isr, IRQF_SHARED, "cctrng", drvdata); if (rc) { dev_err(dev, "Could not register to interrupt %d\n", irq); - goto post_clk_err; + return rc; } dev_dbg(dev, "Registered to IRQ: %d\n", irq); @@ -563,14 +549,14 @@ static int cctrng_probe(struct platform_device *pdev) rc = cc_trng_pm_init(drvdata); if (rc) { dev_err(dev, "cc_trng_pm_init failed\n"); - goto post_clk_err; + return rc; } /* increment device's usage counter */ rc = cc_trng_pm_get(dev); if (rc) { dev_err(dev, "cc_trng_pm_get returned %x\n", rc); - goto post_pm_err; + return rc; } /* set pending_hw to verify that HW won't be triggered from read */ @@ -597,9 +583,6 @@ static int cctrng_probe(struct platform_device *pdev) post_pm_err: cc_trng_pm_fini(drvdata); -post_clk_err: - cc_trng_clk_fini(drvdata); - return rc; } @@ -612,8 +595,6 @@ static int cctrng_remove(struct platform_device *pdev) cc_trng_pm_fini(drvdata); - cc_trng_clk_fini(drvdata); - dev_info(dev, "ARM cctrng device terminated\n"); return 0;