From patchwork Wed Jul 19 07:18:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 122430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2258907vqt; Wed, 19 Jul 2023 00:24:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlGH60rfFrnW84G95qnnTVSHrbHJ0zTipTHcpLRStsO9Iqa2tspCg0aPJOnkDvO88gRGc8wC X-Received: by 2002:a17:906:9f25:b0:98e:2413:952f with SMTP id fy37-20020a1709069f2500b0098e2413952fmr1399030ejc.18.1689751479353; Wed, 19 Jul 2023 00:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689751479; cv=none; d=google.com; s=arc-20160816; b=gqpxfVNEEP6kCO5sFhyUFq/2KJxShYC2/seL/+Wn6MBaQKu0/ikvv+Kc9F5oT6erkH yr3666JS/9LikWrh+1+0ojNc0WG6toMw2ArXFQQW2zdeFSvCF3asedq53U6B5xpX4PIo K+SFFuwsLwW7bI+6sPd/tJnzjWGdyIdkqWtXnARpDpSoXAZgbpJN9FSSWPX5Tbxhthtj GNfDQDYydD3q46BFYlTlDtmQFGK9XXReluWvJVnE8KSw74Bgh6GEaQU0uf0zPEPlLKFv 3jPNcsY/FKvwt7GAljk6GMFyWLrfCSqatUyZCvoBc+0X0Vpphcp2E1z8J851d36j8+9h VmBw== 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=xJH7nT39FRBv2flVrYQ0M4kbDo8QIGeX3RiBvsbExqQ=; fh=dVfXhkbP60ZT4KVr26y6imwTSq8xUCJNaPCgpFL70HA=; b=CYknIv88f3SweWG205rHDozbmFHC7cnj2EK43skAFv/kuME9Yn/+OL5FCOosL2Ewgh nU3N6/VBl6SzrAlmKYClfzwiz+WaZ8A8daUTklpM1cHNFMg3Pq5kFf6Vq/NVsxIMpClY E7hsOb3nzXyzYPAXPG51gMmYpoVYMOxCmus66gRF73Bm+BNeGd3U2GDIKzOFMBqA8928 4aeeVwNG0fAra17GdfZJhTn+xNDp9G7K2POJb/s1DwFnQVaRRcdEGc6xHdcxvhGg+pgD PWpHC+L82sTnUuHkGRpw1k0broziGDtgHdEfScO+Judh1iw6YVXQ7q3qailT7m0laHa4 NAHQ== 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 u2-20020a170906068200b009935121ecd7si2242264ejb.639.2023.07.19.00.24.15; Wed, 19 Jul 2023 00:24:39 -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 S229908AbjGSHUQ (ORCPT + 99 others); Wed, 19 Jul 2023 03:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjGSHUK (ORCPT ); Wed, 19 Jul 2023 03:20:10 -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 1B5DBE43; Wed, 19 Jul 2023 00:20:10 -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 1qM1Tk-0008I7-MQ; Wed, 19 Jul 2023 09:20:08 +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 1/4] hwrng: cctrng - don't open code init and exit functions Date: Wed, 19 Jul 2023 09:18:03 +0200 Message-Id: <20230719071806.335718-2-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: 1771832847490921386 X-GMAIL-MSGID: 1771832847490921386 Do not open code the init and exit functions of the cctrng driver. If we move the BUILD_BUG_ON checks into the probe function, we can use module_platform_driver and make the code shorter. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/cctrng.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c index 302ffa354c2f..241da7e44675 100644 --- a/drivers/char/hw_random/cctrng.c +++ b/drivers/char/hw_random/cctrng.c @@ -492,6 +492,10 @@ static int cctrng_probe(struct platform_device *pdev) u32 val; int irq; + /* Compile time assertion checks */ + BUILD_BUG_ON(CCTRNG_DATA_BUF_WORDS < 6); + BUILD_BUG_ON((CCTRNG_DATA_BUF_WORDS & (CCTRNG_DATA_BUF_WORDS-1)) != 0); + drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); if (!drvdata) return -ENOMEM; @@ -698,21 +702,7 @@ static struct platform_driver cctrng_driver = { .remove = cctrng_remove, }; -static int __init cctrng_mod_init(void) -{ - /* Compile time assertion checks */ - BUILD_BUG_ON(CCTRNG_DATA_BUF_WORDS < 6); - BUILD_BUG_ON((CCTRNG_DATA_BUF_WORDS & (CCTRNG_DATA_BUF_WORDS-1)) != 0); - - return platform_driver_register(&cctrng_driver); -} -module_init(cctrng_mod_init); - -static void __exit cctrng_mod_exit(void) -{ - platform_driver_unregister(&cctrng_driver); -} -module_exit(cctrng_mod_exit); +module_platform_driver(cctrng_driver); /* Module description */ MODULE_DESCRIPTION("ARM CryptoCell TRNG Driver"); 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; From patchwork Wed Jul 19 07:18:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 122431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2258945vqt; Wed, 19 Jul 2023 00:24:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFs/nuGqOK66l/6tOgSqPmntAEMRod+nSz3uhCCHWhm9WomUnSruMQlC8NcSuuXx7i34MxJ X-Received: by 2002:aa7:d70d:0:b0:51d:a263:ef0a with SMTP id t13-20020aa7d70d000000b0051da263ef0amr1703024edq.24.1689751483659; Wed, 19 Jul 2023 00:24:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689751483; cv=none; d=google.com; s=arc-20160816; b=gmhYZKd2oVLTDZv6uFzOvLlcr1D7nHvM/fu7SEEPWHYtRI+rrt3O0ieL0BXXpoloHa PKJ9FJqtOtOgo7EPy7SO+5yUeMSPBgPUgjAnH7oBoxeb9esB81q+2Uufr5/1+76vCJMJ woiGXq1+lgeUiIB+b4Dzkf5Ct5KyLvIPUrZAicvNGhb1LIO3VKxnAgXq4X6hf8sKQkf/ d9LvOWpTHsKQanjsdig61EVATLU9tDQ2w+nCWYAT33MFYkvgCC2xNPgDt9EHIDZZfj+8 iVnM/Nld59U1RKwJ4IaqeMVpIjE+RA+pNkGymieAntnboakueylbDX4nhr7LFHTXiV8j uzsQ== 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=lfG4+TxiryFG0wpNx3IP2X2iIpwspiCznvK16ZPGgyE=; fh=dVfXhkbP60ZT4KVr26y6imwTSq8xUCJNaPCgpFL70HA=; b=gSaK3sWr6HqKHBaPhh3E4WTMK9A0cqEOOfV3W+p2l+aH02ib4M6IQXBtgCthPll8Q6 f/+cLKT9JeJyDH09kEgkyAo38rbgNc5z1qF6a295TJN11pHntKbAbNIgezATycgPW96V kWtIuOKEdlQhbJhKUAMdVEK5M5uYom9HiDbI1+BymVUgt6Kup4IAXPeQ8xEvLyR+YRJN hbMrQBgI6qnbjgzijgCO0RhzGT1/+BNWditLWyxcrH9JqO7H96TxMmQiDJRQesFNy4TM aZrw42SlldV70VS1cyjfrlvZTXK13RWMIaAZ7SqQ9kJIMbA89vI37Ytbppb9cOjBP6mW q0cA== 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 bf22-20020a0564021a5600b0051bf8f889dbsi2692496edb.448.2023.07.19.00.24.20; Wed, 19 Jul 2023 00:24:43 -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 S229938AbjGSHUW (ORCPT + 99 others); Wed, 19 Jul 2023 03:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbjGSHUO (ORCPT ); Wed, 19 Jul 2023 03:20:14 -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 B3BC9E43; Wed, 19 Jul 2023 00:20:13 -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 1qM1Tn-0008I7-ES; Wed, 19 Jul 2023 09:20:12 +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 3/4] hwrng: cctrng - merge cc_trng_clk_init into its only caller Date: Wed, 19 Jul 2023 09:18:05 +0200 Message-Id: <20230719071806.335718-4-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: 1771832851805235742 X-GMAIL-MSGID: 1771832851805235742 cc_trng_clk_init is called only from the probe function. Merge the two functions, this saves some lines of code. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/cctrng.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c index ac4a2fbc6a0f..2a1887f6483f 100644 --- a/drivers/char/hw_random/cctrng.c +++ b/drivers/char/hw_random/cctrng.c @@ -455,21 +455,6 @@ static void cc_trng_startwork_handler(struct work_struct *w) cc_trng_hw_trigger(drvdata); } - -static int cc_trng_clk_init(struct cctrng_drvdata *drvdata) -{ - struct clk *clk; - struct device *dev = &(drvdata->pdev->dev); - - clk = devm_clk_get_optional_enabled(dev, NULL); - if (IS_ERR(clk)) - return dev_err_probe(dev, PTR_ERR(clk), - "Failed to get or enable the clock\n"); - - drvdata->clk = clk; - return 0; -} - static int cctrng_probe(struct platform_device *pdev) { struct cctrng_drvdata *drvdata; @@ -517,11 +502,10 @@ static int cctrng_probe(struct platform_device *pdev) return rc; } - rc = cc_trng_clk_init(drvdata); - if (rc) { - dev_err(dev, "cc_trng_clk_init failed\n"); - return rc; - } + drvdata->clk = devm_clk_get_optional_enabled(dev, NULL); + if (IS_ERR(drvdata->clk)) + return dev_err_probe(dev, PTR_ERR(drvdata->clk), + "Failed to get or enable the clock\n"); INIT_WORK(&drvdata->compwork, cc_trng_compwork_handler); INIT_WORK(&drvdata->startwork, cc_trng_startwork_handler); From patchwork Wed Jul 19 07:18:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 122435 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2264109vqt; Wed, 19 Jul 2023 00:36:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHyfgeplb+o3xiuy1uC36sHMWDD4aUO7itMIrqq3ZyqEs/c8RSU9Gd4zRib4y+1Z5xToP05 X-Received: by 2002:a17:902:d918:b0:1bb:3e35:6416 with SMTP id c24-20020a170902d91800b001bb3e356416mr2211245plz.56.1689752180159; Wed, 19 Jul 2023 00:36:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689752180; cv=none; d=google.com; s=arc-20160816; b=YOHJvCeqSZfMdm7vypR8xGzPstGhsPMOlrkQKDT5Dg8TCRQjuMxNFMqt5ayirKmel6 3ZzH1fYDqD+KyyHNR6ZxKohDeod9kRoF38DUoVGx0IgubyJQ6b5fj1PqkXO9nJ2NuCnY mIwPW7wbOpg846gCI+8GVWpSyInf6uanaEIStrg00b44NtWv9vtlHOjVEtl/1cHbNyAv fbuo3vNidRQpYZox5EnmWv2w61UrBKjRtBT52YsyO8rQyeaRXxFKsGgOm64glXpb+8Ub ypjA+L0N0jU6wJQTWVdt8kkMR1F/NkN2l+aebXXSWN620oSlkkCZsGecfn3MrmtuGCxK vdXQ== 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=krhIx6stVmnqk8f6UtEQLIGup/b8Y5GfesgupKU/U3s=; fh=dVfXhkbP60ZT4KVr26y6imwTSq8xUCJNaPCgpFL70HA=; b=KxzREZ8MzdoDIZCZfIQuOrvRTxG2BH8ZYLyXYXWMJXvzA+r5Ne5Va6utaNc5c3KP3w 0K9jfY7akHx4s26AQaGt+5pMl+lC5cd0DN13AOQmG11h8FyTTMDit8NtshgK8lwiH2eV ysTFleqsNEp70BWzxGfB2GLkmG4eDEajbSBO11GNMEM0CSwvPs8PY2vwjHK03a7GCFyr cVTCltWZUbTzQuMdx/uI5G1PRbBeH5jo8bF+dPD714+aqh1Jt+P6LvAw6atRy7HaoIrr uHhv7XTkktq3S5H87iQXPtIvMsFU2Bzpp7EkIeM5avlkhBtEs9Ohb3JY/cs2b6mgAYa5 46Sw== 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 u7-20020a17090341c700b001b9736814b6si3182917ple.309.2023.07.19.00.36.06; Wed, 19 Jul 2023 00:36:20 -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 S229574AbjGSHU2 (ORCPT + 99 others); Wed, 19 Jul 2023 03:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229909AbjGSHUQ (ORCPT ); Wed, 19 Jul 2023 03:20:16 -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 14164E43; Wed, 19 Jul 2023 00:20:15 -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 1qM1Tp-0008I7-LB; Wed, 19 Jul 2023 09:20:13 +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 4/4] hwrng: cctrng - use dev_err_probe in error paths Date: Wed, 19 Jul 2023 09:18:06 +0200 Message-Id: <20230719071806.335718-5-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: 1771833581693175981 X-GMAIL-MSGID: 1771833581693175981 Use dev_err_probe in error paths to make the code a bit shorter. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/cctrng.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c index 2a1887f6483f..1abbff04a015 100644 --- a/drivers/char/hw_random/cctrng.c +++ b/drivers/char/hw_random/cctrng.c @@ -485,10 +485,8 @@ static int cctrng_probe(struct platform_device *pdev) drvdata->circ.buf = (char *)drvdata->data_buf; drvdata->cc_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(drvdata->cc_base)) { - dev_err(dev, "Failed to ioremap registers"); - return PTR_ERR(drvdata->cc_base); - } + if (IS_ERR(drvdata->cc_base)) + return dev_err_probe(dev, PTR_ERR(drvdata->cc_base), "Failed to ioremap registers"); /* Then IRQ */ irq = platform_get_irq(pdev, 0); @@ -497,10 +495,8 @@ static int cctrng_probe(struct platform_device *pdev) /* parse sampling rate from device tree */ rc = cc_trng_parse_sampling_ratio(drvdata); - if (rc) { - dev_err(dev, "Failed to get legal sampling ratio for rosc\n"); - return rc; - } + if (rc) + return dev_err_probe(dev, rc, "Failed to get legal sampling ratio for rosc\n"); drvdata->clk = devm_clk_get_optional_enabled(dev, NULL); if (IS_ERR(drvdata->clk)) @@ -513,10 +509,8 @@ static int cctrng_probe(struct platform_device *pdev) /* register the driver isr function */ 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); - return rc; - } + if (rc) + return dev_err_probe(dev, rc, "Could not register to interrupt %d\n", irq); dev_dbg(dev, "Registered to IRQ: %d\n", irq); /* Clear all pending interrupts */ @@ -531,17 +525,13 @@ static int cctrng_probe(struct platform_device *pdev) /* init PM */ rc = cc_trng_pm_init(drvdata); - if (rc) { - dev_err(dev, "cc_trng_pm_init failed\n"); - return rc; - } + if (rc) + return dev_err_probe(dev, rc, "cc_trng_pm_init failed\n"); /* increment device's usage counter */ rc = cc_trng_pm_get(dev); - if (rc) { - dev_err(dev, "cc_trng_pm_get returned %x\n", rc); - return rc; - } + if (rc) + return dev_err_probe(dev, rc, "cc_trng_pm_get returned %x\n", rc); /* set pending_hw to verify that HW won't be triggered from read */ atomic_set(&drvdata->pending_hw, 1);