Skip to contentSkip to conversation

nomadik hwrng: Add clock support

PATCH Superseded srinidhi kasagar 4 participants 4 messages May 11, 2010 – May 12, 2010 Hardware random number generator core

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nomadik hwrng: Add clock support

This adds the clock support to the Nomadik RNG driver

---
 drivers/char/hw_random/nomadik-rng.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/char/hw_random/nomadik-rng.c +17 -0
index a8b4c40..ae094c1 100644
@@ -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;
 }
 
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH 1/2 nomadik hwrng: Add clock support

Quoted 4 lines · srinidhi kasagar

This adds the clock support to the Nomadik RNG driver

Looks good to me. Herbert, please queue this.

Quoted 53 lines
---
 drivers/char/hw_random/nomadik-rng.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/char/hw_random/nomadik-rng.c +17 -0
index a8b4c40..ae094c1 100644
@@ -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;
 }
 
Signature · 1 line
Mathematics is the supreme nostalgia of our time.
#2 lore raw

PATCH 1/2 nomadik hwrng: Add clock support

Quoted 1 line

Looks good to me. Herbert, please queue this.

There are two details wrong, I hope Srinidhi sent V2 soon after this V1.

Quoted 1 line
Quoted 1 line

+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:

Quoted 6 lines

drivers/char/hw_random/nomadik-rng.c static int nmk_rng_probe(struct amba_device *dev, struct amba_id *id) · line 52

Quoted 6 lines
drivers/char/hw_random/nomadik-rng.c +6 -0
+	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

maintainer
#3 lore raw

PATCH 1/2 nomadik hwrng: Add clock support

Quoted 4 lines · Alessandro Rubini

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!

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt