From patchwork Wed Aug 21 18:12:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 13771971 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 A7FB5C52D7C for ; Wed, 21 Aug 2024 18:14:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=0JCDbBEordoVXYaPA74oKGa4Tpzl4KmJRmBmv34+29U=; b=HK39HQOzwqymf/LMN6Lk/0XLO5 w7p01YGDZjendo2NJIN/Ag48KfspzmRt/r8QtVwWIlIPfsbkPJC/eWPSQYV+PmQefyvcWy+u4zRWv +93Hee4vSpgVQQR8znxJ9aHWjetAcbaPMGpXbviO556A6fXMnD/xPGwh5/Tmw+updthafWTuvmn4T uVIVmkYrV8AgDwIQGWmd/OI4EKCAajlDca+8qrzdUFmdrWk4fR4aDCnwUXqD/YzZi92upoWb67VtJ FnmA6RfYNy45D+8hmDZXegIyPdLV07zeXhY/HWfzViWFAyTi+ED0WT2M1/h7TMobgyJGnMFlXuM9N epuRRgHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpqo-0000000A280-3Wvh; Wed, 21 Aug 2024 18:14:30 +0000 Received: from akranes.kaiser.cx ([2a0a:4cc0:1:11ef:4484:ccff:febf:ddfa]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpq5-0000000A1zK-2LkC for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 18:13:47 +0000 Received: from dslb-178-004-206-174.178.004.pools.vodafone-ip.de ([178.4.206.174] helo=martin-debian-3.kaiser.cx) by akranes.kaiser.cx with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sgppQ-00227j-2L; Wed, 21 Aug 2024 20:13:04 +0200 From: Martin Kaiser To: Herbert Xu Cc: Aurelien Jarno , Daniel Golle , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 1/2] hwrng: rockchip - rst is used only during probe Date: Wed, 21 Aug 2024 20:12:34 +0200 Message-Id: <20240821181235.22270-2-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821181235.22270-1-martin@kaiser.cx> References: <20240821181235.22270-1-martin@kaiser.cx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_111345_615636_A4202965 X-CRM114-Status: GOOD ( 13.36 ) 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 The driver uses the rst variable only for an initial reset when the chip is probed. There's no need to store rst in the driver's private data, we can make it a local variable in the probe function. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/rockchip-rng.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c index 548e2f4d1490..0dff9de64bc5 100644 --- a/drivers/char/hw_random/rockchip-rng.c +++ b/drivers/char/hw_random/rockchip-rng.c @@ -52,7 +52,6 @@ struct rk_rng { struct hwrng rng; void __iomem *base; - struct reset_control *rst; int clk_num; struct clk_bulk_data *clk_bulks; }; @@ -132,6 +131,7 @@ static int rk_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait) static int rk_rng_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct reset_control *rst; struct rk_rng *rk_rng; int ret; @@ -148,14 +148,13 @@ static int rk_rng_probe(struct platform_device *pdev) return dev_err_probe(dev, rk_rng->clk_num, "Failed to get clks property\n"); - rk_rng->rst = devm_reset_control_array_get_exclusive(&pdev->dev); - if (IS_ERR(rk_rng->rst)) - return dev_err_probe(dev, PTR_ERR(rk_rng->rst), - "Failed to get reset property\n"); + rst = devm_reset_control_array_get_exclusive(&pdev->dev); + if (IS_ERR(rst)) + return dev_err_probe(dev, PTR_ERR(rst), "Failed to get reset property\n"); - reset_control_assert(rk_rng->rst); + reset_control_assert(rst); udelay(2); - reset_control_deassert(rk_rng->rst); + reset_control_deassert(rst); platform_set_drvdata(pdev, rk_rng); From patchwork Wed Aug 21 18:12:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kaiser X-Patchwork-Id: 13771973 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 AE4BDC52D6F for ; Wed, 21 Aug 2024 18:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zLBpo8GlfyUpdppLlG6ukHijZu/gSxmkvzIJ09hDL68=; b=hmtri9Lg3SYA9zwVroc9OQ524k fJXK+NTq/dm89F/fgVYBfhgvAQitS6fIsMfFBU0UDIAbIydlPbxlGX78h9a7EgQmepEHADP6reZ/n lDiEHkeQ6DXr8R5wXyU3CkjAhttppgOt6CknaCr+YckFsykvHUXI1g9Lfcv4hfHLm/oKC2e2Kv9RK pbsf0YQ9DDZ4sgJuIq40fdGXJW6vEAKC/HyY5fIyvPC9AqcHNn7kfu8CR9ioaL4MyBo8zITtZlw4/ 5hegeHq4xZKvMtwNcb8/FaNboE4TFTSAw2JKL9KkrPYE8Zrr+5Z3Uxbz0qVC9lTmU+WrMAjRDSWMz wgwe9b5Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpsB-0000000A2QU-418O; Wed, 21 Aug 2024 18:15:55 +0000 Received: from akranes.kaiser.cx ([2a0a:4cc0:1:11ef:4484:ccff:febf:ddfa]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgpq6-0000000A1zN-0hZQ for linux-arm-kernel@lists.infradead.org; Wed, 21 Aug 2024 18:13:48 +0000 Received: from dslb-178-004-206-174.178.004.pools.vodafone-ip.de ([178.4.206.174] helo=martin-debian-3.kaiser.cx) by akranes.kaiser.cx with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1sgppV-00227j-2m; Wed, 21 Aug 2024 20:13:09 +0200 From: Martin Kaiser To: Herbert Xu Cc: Aurelien Jarno , Daniel Golle , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Kaiser Subject: [PATCH 2/2] hwrng: rockchip - handle devm_pm_runtime_enable errors Date: Wed, 21 Aug 2024 20:12:35 +0200 Message-Id: <20240821181235.22270-3-martin@kaiser.cx> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240821181235.22270-1-martin@kaiser.cx> References: <20240821181235.22270-1-martin@kaiser.cx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240821_111346_230628_C5505335 X-CRM114-Status: GOOD ( 11.92 ) 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 It's unlikely that devm_pm_runtime_enable ever fails. Still, it makes sense to read the return value and handle errors. Signed-off-by: Martin Kaiser --- drivers/char/hw_random/rockchip-rng.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/char/hw_random/rockchip-rng.c b/drivers/char/hw_random/rockchip-rng.c index 0dff9de64bc5..289b385bbf05 100644 --- a/drivers/char/hw_random/rockchip-rng.c +++ b/drivers/char/hw_random/rockchip-rng.c @@ -169,7 +169,9 @@ static int rk_rng_probe(struct platform_device *pdev) pm_runtime_set_autosuspend_delay(dev, RK_RNG_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(dev); - devm_pm_runtime_enable(dev); + ret = devm_pm_runtime_enable(dev); + if (ret) + return dev_err_probe(&pdev->dev, ret, "Runtime pm activation failed.\n"); ret = devm_hwrng_register(dev, &rk_rng->rng); if (ret)