Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1344673ybe; Fri, 13 Sep 2019 15:10:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPbCWYRBYEe8UsL1brJKC9Bf7ZM1kk8jIQsjUkB8V3jvPTtBv1sJC8gTrBDfMdpExhMHma X-Received: by 2002:aa7:dc56:: with SMTP id g22mr50419832edu.212.1568412609589; Fri, 13 Sep 2019 15:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568412609; cv=none; d=google.com; s=arc-20160816; b=iu4kMajc6HyBAVgymAPYn83PINW8fASKjoc1EX6PJU+TGk1FBXIzdV9+/2aHA/KaP9 YC1vTRpCCswsiIWKaxp4Vd9fO2EBok0LpFtRE6pLIy6bN8hV7jvfWg7O3Jb0yN2RQndb GWEX7+J1IqaGbW+DgV3qhFgJ7IW9sKyseoPHwAZEkJJ0jsuxUsSSYbIwAiMbjD1PwKhP +Dfz2yssmrVzx4+Z2a0Kmj7qym+57D9otvTC8USazPX/s5350mQRu64po1abE84vBqSE +kG3w8qIL9GDPL1FMqIEwxFrH5+oAcbkAVyC6ZnHnfegxTVvXiCcRgOjAAKOTaN6ZYp5 in/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=WwI0mA2y1Drgp4s1kKlaue6LdwdzAPQ1VR6dn0g7tEY=; b=xPs8pzqXKoUQUV1japqvvOZGXBC3zFYwHLb4pHL6O3Yzea82SqUcKnwHVk+pzhUfDy zueCdfiQZGigpejTL4kgBVhJ8eYv52yKAbnnLpcMXbGKoxSZhGWAtlnVHICAKbMkONRI VzqydMZGPckSeNt/jHthEEzw4/VuFeOhBFdKGBKm+2XP6bplqGRkh1WTznCmniFx59pW YMs4La4RNVeHm9KSgVodO8aqUbuYBq7ZYZOK+k+ACyj0fuBLKGqeqJUaQ9gEED2tjaYG kxOXmcZm1Xr+aUL7WPKpZHDCM2W1fFyoFXlbXjGUvSVgd+MwFmQX1IfmX+DYb9TMM8K7 wUwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c19si15228087ejx.223.2019.09.13.15.09.45; Fri, 13 Sep 2019 15:10:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390552AbfIMWJd (ORCPT + 99 others); Fri, 13 Sep 2019 18:09:33 -0400 Received: from muru.com ([72.249.23.125]:60742 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390550AbfIMWJd (ORCPT ); Fri, 13 Sep 2019 18:09:33 -0400 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 18DC681A1; Fri, 13 Sep 2019 22:10:03 +0000 (UTC) From: Tony Lindgren To: Matt Mackall , Herbert Xu , linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org Cc: linux-crypto@vger.kernel.org, Aaro Koskinen , Adam Ford , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Tero Kristo , Rob Herring , devicetree@vger.kernel.org Subject: [PATCH 3/6] hwrng: omap3-rom - Call clk_prepare() on init and exit only Date: Fri, 13 Sep 2019 15:09:19 -0700 Message-Id: <20190913220922.29501-4-tony@atomide.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913220922.29501-1-tony@atomide.com> References: <20190913220922.29501-1-tony@atomide.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org When unloading omap3-rom-rng, we'll get the following: WARNING: CPU: 0 PID: 100 at drivers/clk/clk.c:948 clk_core_disable This is because the clock is already disabled by omap3_rom_rng_idle(). Also, we should not call prepare and unprepare except during init, and only call enable and disable during use. Cc: Aaro Koskinen Cc: Adam Ford Cc: Pali Rohár Cc: Tero Kristo Fixes: 1c6b7c2108bd ("hwrng: OMAP3 ROM Random Number Generator support") Signed-off-by: Tony Lindgren --- drivers/char/hw_random/omap3-rom-rng.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/char/hw_random/omap3-rom-rng.c b/drivers/char/hw_random/omap3-rom-rng.c --- a/drivers/char/hw_random/omap3-rom-rng.c +++ b/drivers/char/hw_random/omap3-rom-rng.c @@ -44,7 +44,7 @@ static void omap3_rom_rng_idle(struct work_struct *work) pr_err("reset failed: %d\n", r); return; } - clk_disable_unprepare(rng_clk); + clk_disable(rng_clk); rng_idle = 1; } @@ -55,13 +55,13 @@ static int omap3_rom_rng_get_random(void *buf, unsigned int count) cancel_delayed_work_sync(&idle_work); if (rng_idle) { - r = clk_prepare_enable(rng_clk); + r = clk_enable(rng_clk); if (r) return r; r = omap3_rom_rng_call(0, 0, RNG_GEN_PRNG_HW_INIT); if (r != 0) { - clk_disable_unprepare(rng_clk); + clk_disable(rng_clk); pr_err("HW init failed: %d\n", r); return -EIO; } @@ -114,20 +114,32 @@ static int omap3_rom_rng_probe(struct platform_device *pdev) return PTR_ERR(rng_clk); } + ret = clk_prepare(rng_clk); + if (ret < 0) { + dev_err(&pdev->dev, "clk_prepare failed: %i\n", ret); + return ret; + } + /* Leave the RNG in reset state. */ - ret = clk_prepare_enable(rng_clk); + ret = clk_enable(rng_clk); if (ret) - return ret; + goto err_unprepare; omap3_rom_rng_idle(0); return hwrng_register(&omap3_rom_rng_ops); + +err_unprepare: + clk_unprepare(rng_clk); + + return ret; } static int omap3_rom_rng_remove(struct platform_device *pdev) { cancel_delayed_work_sync(&idle_work); hwrng_unregister(&omap3_rom_rng_ops); - clk_disable_unprepare(rng_clk); + clk_unprepare(rng_clk); + return 0; } -- 2.23.0