From patchwork Mon Jul 10 20:27:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 118069 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp57655vqm; Mon, 10 Jul 2023 13:34:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlHbFpSUvcF0y1iG4pjJtFzGPy4WjsBoO6dela4aI2fvV2y1jcc6HIBree/aV0zCJHhQYK/H X-Received: by 2002:a05:6a00:179b:b0:667:d0ff:6a0f with SMTP id s27-20020a056a00179b00b00667d0ff6a0fmr19704808pfg.5.1689021260074; Mon, 10 Jul 2023 13:34:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689021260; cv=none; d=google.com; s=arc-20160816; b=ScciN4O1RwmJT5Qk7+6Rloi4nCcV6NIcX8QNsg5Z/fLDJZnCTojPpmWwjVk+tpBLCm weReUtFiLhwJ2nTuM/piWDqu1MnOEaMcoQnSTcmqcDFQlUKjGuRvuuGaeI7cuAc8JS0P hMKkDDyrXq9xa03e1vSp1fkJ43XqzVq0pOBw5EOpDM3WQtURG9wDnmzDROZPycmi3oTt SlRjeqQ419yBqdCRlHjADyylDATjQPjo7u5yqr9UNKG6Jzy3g0XU7wcf0vQwf37tUDvQ F21t4wgelK0gF5V2ryWLHna4mUyfd9aCdQXLDL4u7JrwOSrtFlBX/25Qu4KaDhMn7oSN VOUw== 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=i/wbYjwFFvmTp0Y3JUIUuRNE6Y+C5dsFxTE78YP6G34=; fh=GUQwZ7uCW3sOebrGSFJwPRX8di32vmIzxh/oFyyWwpA=; b=Cj8QJ5q964PJCt3GCjjqUKDBWJysw7wqIz+R/5bc4MO3m9SOp16LC4xaIf4Rk7l7tR 6VJHheJptkKmJoeioSl1GznVgIEzqMSZZWcS9ZzrYQhZ2t6ErlSQkaE1/9KRSesohFaV gvoV9Wv6eVrX5rpn3JrqH25jIvUI+VZQPiCLgEb+tNRlOUHGd+M6U5H3Mne5OcOxWinR AWtAW6govxmNEgJdBSYHN2Gjl7ctf32KpGLaIzGuo5NA+gWH2xmyRNifRzu8ZbSz+nKj FG8ABVpcfTOZ2cCjf/9KFYngEy75P3TVpDjnWqg6/l8GRAxcpozAy1W1hj1P7EW8qGtu L1fw== 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 y11-20020a056a00190b00b006824cda542fsi215672pfi.395.2023.07.10.13.34.06; Mon, 10 Jul 2023 13:34: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 S232271AbjGJU3n (ORCPT + 99 others); Mon, 10 Jul 2023 16:29:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231689AbjGJU3e (ORCPT ); Mon, 10 Jul 2023 16:29:34 -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 87165AD; Mon, 10 Jul 2023 13:29:30 -0700 (PDT) Received: from 250.57.4.146.static.wline.lns.sme.cust.swisscom.ch ([146.4.57.250] 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 1qIxVf-0002mg-OH; Mon, 10 Jul 2023 22:29:27 +0200 From: Martin Kaiser To: Herbert Xu Cc: aric.pzqi@ingenic.com, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 4/7] hwrng: ingenic - use devm_clk_get_enabled Date: Mon, 10 Jul 2023 22:27:30 +0200 Message-Id: <20230710202733.116133-5-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230710202733.116133-1-martin@kaiser.cx> References: <20230710202733.116133-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: 1771067156826100113 X-GMAIL-MSGID: 1771067156826100113 Use devm_clk_get_enabled in the ingenic-trng 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/ingenic-trng.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/char/hw_random/ingenic-trng.c b/drivers/char/hw_random/ingenic-trng.c index bfec28ceab00..906fa78de47e 100644 --- a/drivers/char/hw_random/ingenic-trng.c +++ b/drivers/char/hw_random/ingenic-trng.c @@ -29,7 +29,6 @@ struct ingenic_trng { void __iomem *base; - struct clk *clk; struct hwrng rng; }; @@ -77,6 +76,7 @@ static int ingenic_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait static int ingenic_trng_probe(struct platform_device *pdev) { struct ingenic_trng *trng; + struct clk *clk; int ret; trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL); @@ -89,16 +89,10 @@ static int ingenic_trng_probe(struct platform_device *pdev) return PTR_ERR(trng->base); } - trng->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(trng->clk)) { - pr_crit("%s: Cannot get DTRNG clock\n", __func__); - return PTR_ERR(trng->clk); - } - - ret = clk_prepare_enable(trng->clk); - if (ret) { - pr_crit("%s: Unable to enable DTRNG clock\n", __func__); - return ret; + clk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(clk)) { + pr_crit("%s: Cannot get and enable DTRNG clock\n", __func__); + return PTR_ERR(clk); } trng->rng.name = pdev->name; @@ -109,17 +103,13 @@ static int ingenic_trng_probe(struct platform_device *pdev) ret = hwrng_register(&trng->rng); if (ret) { dev_err(&pdev->dev, "Failed to register hwrng\n"); - goto err_unprepare_clk; + return ret; } platform_set_drvdata(pdev, trng); dev_info(&pdev->dev, "Ingenic DTRNG driver registered\n"); return 0; - -err_unprepare_clk: - clk_disable_unprepare(trng->clk); - return ret; } static int ingenic_trng_remove(struct platform_device *pdev) @@ -133,8 +123,6 @@ static int ingenic_trng_remove(struct platform_device *pdev) ctrl &= ~CFG_GEN_EN; writel(ctrl, trng->base + TRNG_REG_CFG_OFFSET); - clk_disable_unprepare(trng->clk); - return 0; }