aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hw_random/bcm2835-rng.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-11-07 16:44:41 -0800
committerHerbert Xu <herbert@gondor.apana.org.au>2017-11-29 16:43:44 +1100
commitec94bca7be6b29c1aebf2e1e95855ee6ca0d5d62 (patch)
tree22eff73ef690d437161463ec16d0a52c0c951670 /drivers/char/hw_random/bcm2835-rng.c
parenthwrng: bcm2835 - Move enabling to hwrng::init (diff)
downloadlinux-dev-ec94bca7be6b29c1aebf2e1e95855ee6ca0d5d62.tar.xz
linux-dev-ec94bca7be6b29c1aebf2e1e95855ee6ca0d5d62.zip
hwrng: bcm2835 - Implementation cleanup callback
We should be disabling the RNG in a hwrng::cleanup callback if we are not longer the system selected RNG, not wait until the device driver is removed. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char/hw_random/bcm2835-rng.c')
-rw-r--r--drivers/char/hw_random/bcm2835-rng.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index 82000a637504..4d0356110b1b 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -83,6 +83,14 @@ static int bcm2835_rng_init(struct hwrng *rng)
return 0;
}
+static void bcm2835_rng_cleanup(struct hwrng *rng)
+{
+ struct bcm2835_rng_priv *priv = to_rng_priv(rng);
+
+ /* disable rng hardware */
+ __raw_writel(0, priv->base + RNG_CTRL);
+}
+
static const struct of_device_id bcm2835_rng_of_match[] = {
{ .compatible = "brcm,bcm2835-rng"},
{ .compatible = "brcm,bcm-nsp-rng", .data = nsp_rng_init},
@@ -118,6 +126,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;
+ priv->rng.cleanup = bcm2835_rng_cleanup;
rng_id = of_match_node(bcm2835_rng_of_match, np);
if (!rng_id)
@@ -142,9 +151,6 @@ static int bcm2835_rng_remove(struct platform_device *pdev)
{
struct bcm2835_rng_priv *priv = platform_get_drvdata(pdev);
- /* disable rng hardware */
- __raw_writel(0, priv->base + RNG_CTRL);
-
/* unregister driver */
hwrng_unregister(&priv->rng);