From patchwork Tue Mar 7 14:14:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 9608983 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4BFDC604DD for ; Tue, 7 Mar 2017 14:16:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A3FC271E0 for ; Tue, 7 Mar 2017 14:16:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F33F2850D; Tue, 7 Mar 2017 14:16:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB60D28502 for ; Tue, 7 Mar 2017 14:16:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750780AbdCGOQc (ORCPT ); Tue, 7 Mar 2017 09:16:32 -0500 Received: from mail.free-electrons.com ([62.4.15.54]:58592 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755144AbdCGOQa (ORCPT ); Tue, 7 Mar 2017 09:16:30 -0500 Received: by mail.free-electrons.com (Postfix, from userid 110) id 5A09E2078A; Tue, 7 Mar 2017 15:15:15 +0100 (CET) Received: from localhost (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id 2ADF6207CF; Tue, 7 Mar 2017 15:15:05 +0100 (CET) From: Thomas Petazzoni To: Deepak Saxena , Matt Mackall , Herbert Xu Cc: linux-crypto@vger.kernel.org, romain.perier@collabora.com, Jason Cooper , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Nadav Haklai , Hanna Hawa , Yehuda Yitschak , Thomas Petazzoni Subject: [PATCH 4/4] hwrng: omap - move clock related code to omap_rng_probe() Date: Tue, 7 Mar 2017 15:14:49 +0100 Message-Id: <1488896089-17586-5-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488896089-17586-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1488896089-17586-1-git-send-email-thomas.petazzoni@free-electrons.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, the code that takes a reference to the clock and enables it is located inside of_get_omap_rng_device_details(), called only when probing through the Device Tree. However, there is nothing that makes this clock logic dependent on the Device Tree, so it makes more sense to have it in omap_rng_probe() directly. Moreover, we make sure to bail out if we can't enable the clock. Indeed, while the clock is optional, if a clock is present, we really want to succeed in enabling it. And we fix the error message to fit on one line, so that it is grep-friendly. Signed-off-by: Thomas Petazzoni --- drivers/char/hw_random/omap-rng.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/char/hw_random/omap-rng.c b/drivers/char/hw_random/omap-rng.c index b1ad125..74d11ae 100644 --- a/drivers/char/hw_random/omap-rng.c +++ b/drivers/char/hw_random/omap-rng.c @@ -398,16 +398,6 @@ static int of_get_omap_rng_device_details(struct omap_rng_dev *priv, return err; } - priv->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -EPROBE_DEFER) - return -EPROBE_DEFER; - if (!IS_ERR(priv->clk)) { - err = clk_prepare_enable(priv->clk); - if (err) - dev_err(&pdev->dev, "unable to enable the clk, " - "err = %d\n", err); - } - /* * On OMAP4, enabling the shutdown_oflo interrupt is * done in the interrupt mask register. There is no @@ -478,6 +468,18 @@ static int omap_rng_probe(struct platform_device *pdev) goto err_ioremap; } + priv->clk = devm_clk_get(&pdev->dev, NULL); + if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -EPROBE_DEFER) + return -EPROBE_DEFER; + if (!IS_ERR(priv->clk)) { + ret = clk_prepare_enable(priv->clk); + if (ret) { + dev_err(&pdev->dev, + "Unable to enable the clk: %d\n", ret); + goto err_register; + } + } + ret = (dev->of_node) ? of_get_omap_rng_device_details(priv, pdev) : get_omap_rng_device_details(priv); if (ret)