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: 122436 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2264322vqt; Wed, 19 Jul 2023 00:36:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlGg/f/gEy0ASzHAhsGOauzUvXuBXFgxEZfEBO4gxcMu9kmLVVr4/6oegYjyBNDarO5LRP7A X-Received: by 2002:a17:903:32cc:b0:1b8:94e9:e7d2 with SMTP id i12-20020a17090332cc00b001b894e9e7d2mr2177336plr.0.1689752210744; Wed, 19 Jul 2023 00:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689752210; cv=none; d=google.com; s=arc-20160816; b=tu6aJw1uZaO6ElsNdeQlahwx2WQl4UukCXe0ekBTqAP1vigUYxtXcLC8M3HGJFpgSF 349y/3zzA69SGN8CfpBGven7x8Clq4cu3KXosm6/39MinXfBLMQ0YlF/+P+2j5Mq4LGD 8BUlXC6yccI1i4Ayr/7j4hmTElK+dObhO+kGP15dDvee/wiFM63uj9KhISmwbf46jUAH MDCfj/29El25owG2uek1KRLWnIDxpqNCQ1WOQ0LQ/q9v91U9AjGJyWfLmhxeFNnwRHNQ 1Q0uh8MNjA99BjozJp+EU79PuxfFl65Blag8RpOLBdDTL5AD6nBgs4hhWITsLmyZch8h sNGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=uTCFuNiWsAMi5r8o/oatf2I3ovgC17N7jxnvD+gQSOI=; fh=dVfXhkbP60ZT4KVr26y6imwTSq8xUCJNaPCgpFL70HA=; b=lb8eCGGb0uygEKfP5SsSCHPgYOvAb+X8HShqwExiUOcnXmzMGRuKTFw178IjgnhVq0 KKTjT8bwhwa9V9kn0Wbm7z92ZqTlYZBrwAOf+wZoNYldBC5qydh+rAp38XT9GqNj0TOo oaxE2mn9BlsX9tmVVhR7BZFacrOtre/UJ9bJkdIEHK2b9mEFb9jVuuPXyO0mkHH2WzES jAQWVmiIOgo1zKQ2aCoqi7d8Kp8Sn+BMVcvKfbeHMwc7FOKwW7vZL8aJC9kMKIzwJP4N LiU7kTNGRCiAMCRolwc3sGojfoNU/RiSykwIP0VY0iQk4/VUwzXgZ3do2/f7A0xr/w1+ c1yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a170902d0c900b001b9c120a39csi2942435pln.357.2023.07.19.00.36.36; Wed, 19 Jul 2023 00:36:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbjGSHUT (ORCPT + 99 others); Wed, 19 Jul 2023 03:20:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjGSHUM (ORCPT ); Wed, 19 Jul 2023 03:20:12 -0400 Received: from viti.kaiser.cx (viti.kaiser.cx [IPv6:2a01:238:43fe:e600:cd0c:bd4a:7a3:8e9f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F8D7A4; Wed, 19 Jul 2023 00:20:11 -0700 (PDT) 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-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771833614236730536 X-GMAIL-MSGID: 1771833614236730536 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;