Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 331314
b: refs/heads/master
c: 665d92f
h: refs/heads/master
v: v3
  • Loading branch information
Paul Walmsley committed Sep 23, 2012
1 parent 867ed31 commit 43418b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 02666360c92af7885c47163f936b58dc86213a53
refs/heads/master: 665d92fa85b5cb4c0a3f36524ac6cc8f9e3d9c2d
35 changes: 9 additions & 26 deletions trunk/drivers/char/hw_random/omap-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/random.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/platform_device.h>
#include <linux/hw_random.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/pm_runtime.h>

#include <asm/io.h>

Expand All @@ -50,12 +50,10 @@
/**
* struct omap_rng_private_data - RNG IP block-specific data
* @base: virtual address of the beginning of the RNG IP block registers
* @clk: RNG clock
* @mem_res: struct resource * for the IP block registers physical memory
*/
struct omap_rng_private_data {
void __iomem *base;
struct clk *clk;
struct resource *mem_res;
};

Expand Down Expand Up @@ -122,17 +120,6 @@ static int __devinit omap_rng_probe(struct platform_device *pdev)
omap_rng_ops.priv = (unsigned long)priv;
dev_set_drvdata(&pdev->dev, priv);

if (cpu_is_omap24xx()) {
priv->clk = clk_get(&pdev->dev, "ick");
if (IS_ERR(priv->clk)) {
dev_err(&pdev->dev, "Could not get rng_ick\n");
ret = PTR_ERR(priv->clk);
return ret;
} else {
clk_enable(priv->clk);
}
}

priv->mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!priv->mem_res) {
ret = -ENOENT;
Expand All @@ -146,26 +133,24 @@ static int __devinit omap_rng_probe(struct platform_device *pdev)
}
dev_set_drvdata(&pdev->dev, priv);

pm_runtime_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev);

ret = hwrng_register(&omap_rng_ops);
if (ret)
goto err_register;

dev_info(&pdev->dev, "OMAP Random Number Generator ver. %02x\n",
omap_rng_read_reg(priv, RNG_REV_REG));


omap_rng_write_reg(priv, RNG_MASK_REG, 0x1);

return 0;

err_register:
priv->base = NULL;
pm_runtime_disable(&pdev->dev);
err_ioremap:
if (cpu_is_omap24xx()) {
clk_disable(priv->clk);
clk_put(priv->clk);
}

kfree(priv);

return ret;
Expand All @@ -179,12 +164,8 @@ static int __exit omap_rng_remove(struct platform_device *pdev)

omap_rng_write_reg(priv, RNG_MASK_REG, 0x0);

iounmap(priv->base);

if (cpu_is_omap24xx()) {
clk_disable(priv->clk);
clk_put(priv->clk);
}
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);

release_mem_region(priv->mem_res->start, resource_size(priv->mem_res));

Expand All @@ -200,6 +181,7 @@ static int omap_rng_suspend(struct device *dev)
struct omap_rng_private_data *priv = dev_get_drvdata(dev);

omap_rng_write_reg(priv, RNG_MASK_REG, 0x0);
pm_runtime_put_sync(dev);

return 0;
}
Expand All @@ -208,6 +190,7 @@ static int omap_rng_resume(struct device *dev)
{
struct omap_rng_private_data *priv = dev_get_drvdata(dev);

pm_runtime_get_sync(dev);
omap_rng_write_reg(priv, RNG_MASK_REG, 0x1);

return 0;
Expand Down

0 comments on commit 43418b0

Please sign in to comment.