From patchwork Tue Jul 4 17:32:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 115881 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1386989vqx; Tue, 4 Jul 2023 11:07:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlGeSH109UcciejAlZ943qAi0HAKJKq77Uv51T9IaU9CLeSK21TWdiyQhvb5d4dk2qEq8cpL X-Received: by 2002:a17:902:da92:b0:1b3:b3c5:1d1f with SMTP id j18-20020a170902da9200b001b3b3c51d1fmr12817625plx.8.1688494076052; Tue, 04 Jul 2023 11:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688494076; cv=none; d=google.com; s=arc-20160816; b=x0/3mmEfnbkTrF7cbfv/eC5i2Fjffc4rngIbZxdtn1HOlezte3l59GJKfy6LxiW1Hy EI8QPc9avmSLoxi22kdf+pn1TL8PDmZ+4KylMJrZ4T7RZPyP80viC8UCpYeSRPDBfESp WpvtorWyeuEq9rxuKKBOKN1tVJWnT6CvFDsa43apGOKf9YdARbLdd6cQtnELTni2TAFI KxMpCDYKGsA5vdxmvs5FSFNak7uujdy81JQezULNy9ExOZkY9tQCHQNGAfffKOC7/UHL POoR7Tv9QH8GXWVsyeqvNd3AuJfTsoBD0RPr4e7vTqwKRbufaaKIxW/qyXj7Vufb4G3V q/lQ== 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=yW1T5aVd81nPIOIoHH4RxZnIfjzCSw0xd9QOOcaTaBg=; fh=lO4wmMQhvm8y/jaHDv9dt1CS5yb5ZTFKyt5xlt/d/d8=; b=GJOtsdMcWq2izEOdkgkMNRtwPknC1PJsJHR3sC/2fpK9x9M1RXE2B7ySxK+q1WM0l1 nvQQhdckpSjYAyWVLOfsPPutco0dds8vg80dulLKvCHEQYEKqE/Uvbh4o2Y3AKtKOGgz Sg5Ns8c25lwWayzO5aoFgVAOZLi+UjPpnaPZTA4Ip8YRNe2ztd8r3+5ttbZy1B4nIzDB kWdrqTRkQnfO8h7/3lxoFghrxEMYOTP7Zw1kgLzcWhkg+yx5SddKa1J78a/ojVa74B/t yaSl/kRM71uVSA61iUtGDh30ONHPH6Gag5hkMBVE+GvMNA4VRo4JaY77SETQOtntkBbB 7JVQ== 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 jj13-20020a170903048d00b001b89baba4f6si4079238plb.408.2023.07.04.11.07.42; Tue, 04 Jul 2023 11:07:56 -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 S231731AbjGDRdz (ORCPT + 99 others); Tue, 4 Jul 2023 13:33:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231642AbjGDRdw (ORCPT ); Tue, 4 Jul 2023 13:33:52 -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 4A34910D5; Tue, 4 Jul 2023 10:33:51 -0700 (PDT) Received: from ipservice-092-217-072-126.092.217.pools.vodafone-ip.de ([92.217.72.126] 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 1qGjuO-0000yT-DV; Tue, 04 Jul 2023 19:33:48 +0200 From: Martin Kaiser To: Herbert Xu Cc: Joshua Henderson , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 2/4] hwrng: pic32 - use devm_clk_get_enabled Date: Tue, 4 Jul 2023 19:32:01 +0200 Message-Id: <20230704173203.70706-3-martin@kaiser.cx> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230704173203.70706-1-martin@kaiser.cx> References: <20230704173203.70706-1-martin@kaiser.cx> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770514364301189332?= X-GMAIL-MSGID: =?utf-8?q?1770514364301189332?= Use devm_clk_get_enabled in the pic32 driver. Ensure that the clock is enabled as long as the driver is registered with the hwrng core. Fixes: 7ea39973d1e5 ("hwrng: pic32 - Use device-managed registration API") Signed-off-by: Martin Kaiser --- drivers/char/hw_random/pic32-rng.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/drivers/char/hw_random/pic32-rng.c b/drivers/char/hw_random/pic32-rng.c index 99c8bd0859a1..e04a054e8930 100644 --- a/drivers/char/hw_random/pic32-rng.c +++ b/drivers/char/hw_random/pic32-rng.c @@ -36,7 +36,6 @@ struct pic32_rng { void __iomem *base; struct hwrng rng; - struct clk *clk; }; /* @@ -70,6 +69,7 @@ static int pic32_rng_read(struct hwrng *rng, void *buf, size_t max, static int pic32_rng_probe(struct platform_device *pdev) { struct pic32_rng *priv; + struct clk *clk; u32 v; int ret; @@ -81,13 +81,9 @@ static int pic32_rng_probe(struct platform_device *pdev) if (IS_ERR(priv->base)) return PTR_ERR(priv->base); - priv->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk)) - return PTR_ERR(priv->clk); - - ret = clk_prepare_enable(priv->clk); - if (ret) - return ret; + clk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(clk)) + return PTR_ERR(clk); /* enable TRNG in enhanced mode */ v = TRNGEN | TRNGMOD; @@ -98,15 +94,11 @@ static int pic32_rng_probe(struct platform_device *pdev) ret = devm_hwrng_register(&pdev->dev, &priv->rng); if (ret) - goto err_register; + return ret; platform_set_drvdata(pdev, priv); return 0; - -err_register: - clk_disable_unprepare(priv->clk); - return ret; } static int pic32_rng_remove(struct platform_device *pdev) @@ -114,7 +106,6 @@ static int pic32_rng_remove(struct platform_device *pdev) struct pic32_rng *rng = platform_get_drvdata(pdev); writel(0, rng->base + RNGCON); - clk_disable_unprepare(rng->clk); return 0; }