From patchwork Tue Jun 12 21:07:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 164499 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 39465B6FBD for ; Wed, 13 Jun 2012 07:06:50 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SeYFZ-00009Q-HP; Tue, 12 Jun 2012 21:03:41 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SeYFW-00009L-Hh for linux-arm-kernel@merlin.infradead.org; Tue, 12 Jun 2012 21:03:38 +0000 Received: from zose-mta12.web4all.fr ([178.33.204.89]) by casper.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SeYFT-0005vC-S6 for linux-arm-kernel@lists.infradead.org; Tue, 12 Jun 2012 21:03:37 +0000 Received: from localhost (localhost [127.0.0.1]) by zose-mta12.web4all.fr (Postfix) with ESMTP id D87319087A; Tue, 12 Jun 2012 23:07:56 +0200 (CEST) X-Virus-Scanned: amavisd-new at zose1.web4all.fr Received: from zose-mta12.web4all.fr ([127.0.0.1]) by localhost (zose-mta12.web4all.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ise-4mGCCEcd; Tue, 12 Jun 2012 23:07:55 +0200 (CEST) Received: from zose-store12.web4all.fr (zose-store-12.w4a.fr [178.33.204.48]) by zose-mta12.web4all.fr (Postfix) with ESMTP id 6CB36904F3; Tue, 12 Jun 2012 23:07:55 +0200 (CEST) Date: Tue, 12 Jun 2012 23:07:47 +0200 (CEST) From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= To: Matt Mackall , Herbert Xu , Sascha Hauer , linux-arm-kernel@lists.infradead.org Message-ID: <1795608889.2533817.1339535267600.JavaMail.root@advansee.com> Subject: [PATCH] ARM: mxc-rnga: fix data_present API MIME-Version: 1.0 X-Originating-IP: [88.188.188.98] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Win)/7.2.0_GA_2669) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20120612_220336_213980_6C4FB637 X-CRM114-Status: UNSURE ( 8.81 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Alan Carvalho de Assis X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Cc: Matt Mackall Cc: Herbert Xu Cc: Sascha Hauer Cc: Alan Carvalho de Assis Cc: Signed-off-by: Benoît Thébaudeau --- .../drivers/char/hw_random/mxc-rnga.c | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git linux-next-HEAD-c90e5d2.orig/drivers/char/hw_random/mxc-rnga.c linux-next-HEAD-c90e5d2/drivers/char/hw_random/mxc-rnga.c index 187c6be..2924253 100644 --- linux-next-HEAD-c90e5d2.orig/drivers/char/hw_random/mxc-rnga.c +++ linux-next-HEAD-c90e5d2/drivers/char/hw_random/mxc-rnga.c @@ -24,6 +24,7 @@ #include #include #include +#include #include /* RNGA Registers */ @@ -60,16 +61,21 @@ static struct platform_device *rng_dev; -static int mxc_rnga_data_present(struct hwrng *rng) +static int mxc_rnga_data_present(struct hwrng *rng, int wait) { - int level; void __iomem *rng_base = (void __iomem *)rng->priv; - - /* how many random numbers is in FIFO? [0-16] */ - level = ((__raw_readl(rng_base + RNGA_STATUS) & - RNGA_STATUS_LEVEL_MASK) >> 8); - - return level > 0 ? 1 : 0; + int level, data, i; + + for (i = 0; i < 20; i++) { + /* how many random numbers is in FIFO? [0-16] */ + level = ((__raw_readl(rng_base + RNGA_STATUS) & + RNGA_STATUS_LEVEL_MASK) >> 8); + data = level > 0 ? 1 : 0; + if (data || !wait) + break; + udelay(10); + } + return data; } static int mxc_rnga_data_read(struct hwrng *rng, u32 * data)