[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171102010408.27736-4-f.fainelli@gmail.com>
Date: Wed, 1 Nov 2017 18:03:59 -0700
From: Florian Fainelli <f.fainelli@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Florian Fainelli <f.fainelli@...il.com>,
Matt Mackall <mpm@...enic.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Ray Jui <rjui@...adcom.com>,
Scott Branden <sbranden@...adcom.com>,
bcm-kernel-feedback-list@...adcom.com (maintainer:BROADCOM
BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...),
Eric Anholt <eric@...olt.net>,
Stefan Wahren <stefan.wahren@...e.com>,
PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>,
Russell King <rmk+kernel@...linux.org.uk>,
Krzysztof Kozlowski <krzk@...nel.org>,
Harald Freudenberger <freude@...ux.vnet.ibm.com>,
Sean Wang <sean.wang@...iatek.com>,
Martin Kaiser <martin@...ser.cx>,
Steffen Trumtrar <s.trumtrar@...gutronix.de>,
linux-crypto@...r.kernel.org (open list:HARDWARE RANDOM NUMBER
GENERATOR CORE),
devicetree@...r.kernel.org (open list:OPEN FIRMWARE AND FLATTENED
DEVICE TREE BINDINGS),
linux-rpi-kernel@...ts.infradead.org (moderated list:BROADCOM BCM2835
ARM ARCHITECTURE),
linux-arm-kernel@...ts.infradead.org (moderated list:BROADCOM BCM2835
ARM ARCHITECTURE)
Subject: [PATCH 03/12] hwrng: bcm2835-rng: Move enabling to hwrng::init
We should be moving the enabling of the HWRNG into a hwrng::init
callback since we can be disabled and enabled every time a different
hwrng is selected in the system.
Signed-off-by: Florian Fainelli <f.fainelli@...il.com>
---
drivers/char/hw_random/bcm2835-rng.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index 0d72147ab45b..82000a637504 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -72,6 +72,17 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
return num_words * sizeof(u32);
}
+static int bcm2835_rng_init(struct hwrng *rng)
+{
+ struct bcm2835_rng_priv *priv = to_rng_priv(rng);
+
+ /* set warm-up count & enable */
+ __raw_writel(RNG_WARMUP_COUNT, priv->base + RNG_STATUS);
+ __raw_writel(RNG_RBGEN, priv->base + RNG_CTRL);
+
+ return 0;
+}
+
static const struct of_device_id bcm2835_rng_of_match[] = {
{ .compatible = "brcm,bcm2835-rng"},
{ .compatible = "brcm,bcm-nsp-rng", .data = nsp_rng_init},
@@ -105,6 +116,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
}
priv->rng.name = "bcm2835-rng";
+ priv->rng.init = bcm2835_rng_init;
priv->rng.read = bcm2835_rng_read;
rng_id = of_match_node(bcm2835_rng_of_match, np);
@@ -116,10 +128,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
if (rng_setup)
rng_setup(priv->base);
- /* set warm-up count & enable */
- __raw_writel(RNG_WARMUP_COUNT, priv->base + RNG_STATUS);
- __raw_writel(RNG_RBGEN, priv->base + RNG_CTRL);
-
/* register driver */
err = hwrng_register(&priv->rng);
if (err)
--
2.9.3
Powered by blists - more mailing lists