* [PATCH 1/2] nomadik hwrng: Add clock support
@ 2010-05-11 6:55 srinidhi kasagar
2010-05-12 20:47 ` Matt Mackall
2010-05-12 21:08 ` Alessandro Rubini
0 siblings, 2 replies; 4+ messages in thread
From: srinidhi kasagar @ 2010-05-11 6:55 UTC (permalink / raw)
To: linux-arm-kernel
This adds the clock support to the Nomadik RNG driver
Signed-off-by: srinidhi kasagar <srinidhi.kasagar@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
---
drivers/char/hw_random/nomadik-rng.c | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c
index a8b4c40..ae094c1 100644
--- a/drivers/char/hw_random/nomadik-rng.c
+++ b/drivers/char/hw_random/nomadik-rng.c
@@ -15,6 +15,10 @@
#include <linux/amba/bus.h>
#include <linux/hw_random.h>
#include <linux/io.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+
+struct clk *rng_clk;
static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
{
@@ -40,6 +44,15 @@ static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id)
void __iomem *base;
int ret;
+ rng_clk = clk_get(&dev->dev, NULL);
+ if (IS_ERR(rng_clk)) {
+ dev_err(&dev->dev, "could not get rng clock\n");
+ ret = PTR_ERR(rng_clk);
+ return ret;
+ }
+
+ clk_enable(rng_clk);
+
ret = amba_request_regions(dev, dev->dev.init_name);
if (ret)
return ret;
@@ -57,6 +70,8 @@ out_unmap:
iounmap(base);
out_release:
amba_release_regions(dev);
+ clk_disable(rng_clk);
+ clk_put(rng_clk);
return ret;
}
@@ -66,6 +81,8 @@ static int nmk_rng_remove(struct amba_device *dev)
hwrng_unregister(&nmk_rng);
iounmap(base);
amba_release_regions(dev);
+ clk_disable(rng_clk);
+ clk_put(rng_clk);
return 0;
}
--
1.6.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/2] nomadik hwrng: Add clock support
2010-05-11 6:55 [PATCH 1/2] nomadik hwrng: Add clock support srinidhi kasagar
@ 2010-05-12 20:47 ` Matt Mackall
2010-05-12 21:08 ` Alessandro Rubini
1 sibling, 0 replies; 4+ messages in thread
From: Matt Mackall @ 2010-05-12 20:47 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 2010-05-11 at 12:25 +0530, srinidhi kasagar wrote:
> This adds the clock support to the Nomadik RNG driver
>
> Signed-off-by: srinidhi kasagar <srinidhi.kasagar@stericsson.com>
> Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Looks good to me. Herbert, please queue this.
Acked-by: Matt Mackall <mpm@selenic.com>
> ---
> drivers/char/hw_random/nomadik-rng.c | 17 +++++++++++++++++
> 1 files changed, 17 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/char/hw_random/nomadik-rng.c b/drivers/char/hw_random/nomadik-rng.c
> index a8b4c40..ae094c1 100644
> --- a/drivers/char/hw_random/nomadik-rng.c
> +++ b/drivers/char/hw_random/nomadik-rng.c
> @@ -15,6 +15,10 @@
> #include <linux/amba/bus.h>
> #include <linux/hw_random.h>
> #include <linux/io.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +
> +struct clk *rng_clk;
>
> static int nmk_rng_read(struct hwrng *rng, void *data, size_t max, bool wait)
> {
> @@ -40,6 +44,15 @@ static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id)
> void __iomem *base;
> int ret;
>
> + rng_clk = clk_get(&dev->dev, NULL);
> + if (IS_ERR(rng_clk)) {
> + dev_err(&dev->dev, "could not get rng clock\n");
> + ret = PTR_ERR(rng_clk);
> + return ret;
> + }
> +
> + clk_enable(rng_clk);
> +
> ret = amba_request_regions(dev, dev->dev.init_name);
> if (ret)
> return ret;
> @@ -57,6 +70,8 @@ out_unmap:
> iounmap(base);
> out_release:
> amba_release_regions(dev);
> + clk_disable(rng_clk);
> + clk_put(rng_clk);
> return ret;
> }
>
> @@ -66,6 +81,8 @@ static int nmk_rng_remove(struct amba_device *dev)
> hwrng_unregister(&nmk_rng);
> iounmap(base);
> amba_release_regions(dev);
> + clk_disable(rng_clk);
> + clk_put(rng_clk);
> return 0;
> }
>
--
Mathematics is the supreme nostalgia of our time.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] nomadik hwrng: Add clock support
2010-05-11 6:55 [PATCH 1/2] nomadik hwrng: Add clock support srinidhi kasagar
2010-05-12 20:47 ` Matt Mackall
@ 2010-05-12 21:08 ` Alessandro Rubini
2010-05-12 22:15 ` Herbert Xu
1 sibling, 1 reply; 4+ messages in thread
From: Alessandro Rubini @ 2010-05-12 21:08 UTC (permalink / raw)
To: linux-arm-kernel
> Looks good to me. Herbert, please queue this.
There are two details wrong, I hope Srinidhi sent V2 soon after this V1.
>> +struct clk *rng_clk;
This should be static.
The other problem is that there is no clock associated to this device,
it is only added by the later 2/2 patch. So the rng stops working
with this patch alone, with this error:
>> + rng_clk = clk_get(&dev->dev, NULL);
>> + if (IS_ERR(rng_clk)) {
>> + dev_err(&dev->dev, "could not get rng clock\n");
>> + ret = PTR_ERR(rng_clk);
>> + return ret;
>> + }
I think the two patches must be split differently. However, it's just
two minor details, so I am not against applying as-is, if the relevant
maintainer chooses to.
Thanks
/alessandro
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] nomadik hwrng: Add clock support
2010-05-12 21:08 ` Alessandro Rubini
@ 2010-05-12 22:15 ` Herbert Xu
0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2010-05-12 22:15 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, May 12, 2010 at 11:08:46PM +0200, Alessandro Rubini wrote:
>
> I think the two patches must be split differently. However, it's just
> two minor details, so I am not against applying as-is, if the relevant
> maintainer chooses to.
I think resplitting them should be done as bisectibility is pretty
important.
Thanks!
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-12 22:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-11 6:55 [PATCH 1/2] nomadik hwrng: Add clock support srinidhi kasagar
2010-05-12 20:47 ` Matt Mackall
2010-05-12 21:08 ` Alessandro Rubini
2010-05-12 22:15 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).