mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] hwrng: manage resource allocation in amd driver
@ 2011-04-27 19:21 Dmitry Eremin-Solenikov
  2011-04-27 19:21 ` [PATCH 2/2] hwrnd: enable AMD hw rnd driver for Maple PPC boards Dmitry Eremin-Solenikov
  2011-04-28 19:51 ` [PATCH 1/2] hwrng: manage resource allocation in amd driver Matt Mackall
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Eremin-Solenikov @ 2011-04-27 19:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: Matt Mackall, Herbert Xu

As amd driver doesn't bind to PCI device, we'd better manage reource
allocation on our own to disallow (possible) conflicts.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 drivers/char/hw_random/amd-rng.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
index 0d8c578..c6af038 100644
--- a/drivers/char/hw_random/amd-rng.c
+++ b/drivers/char/hw_random/amd-rng.c
@@ -133,6 +133,12 @@ found:
 	pmbase &= 0x0000FF00;
 	if (pmbase == 0)
 		goto out;
+	if (!request_region(pmbase + 0xF0, 8, "AMD HWRNG")) {
+		dev_err(&pdev->dev, "AMD HWRNG region 0x%x already in use!\n",
+			pmbase + 0xF0);
+		err = -EBUSY;
+		goto out;
+	}
 	amd_rng.priv = (unsigned long)pmbase;
 	amd_pdev = pdev;
 
@@ -141,6 +147,7 @@ found:
 	if (err) {
 		printk(KERN_ERR PFX "RNG registering failed (%d)\n",
 		       err);
+		release_region(pmbase + 0xF0, 8);
 		goto out;
 	}
 out:
@@ -149,6 +156,8 @@ out:
 
 static void __exit mod_exit(void)
 {
+	u32 pmbase = (unsigned long)amd_rng.priv;
+	release_region(pmbase + 0xF0, 8);
 	hwrng_unregister(&amd_rng);
 }
 
-- 
1.7.4.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-04  5:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 19:21 [PATCH 1/2] hwrng: manage resource allocation in amd driver Dmitry Eremin-Solenikov
2011-04-27 19:21 ` [PATCH 2/2] hwrnd: enable AMD hw rnd driver for Maple PPC boards Dmitry Eremin-Solenikov
2011-04-28 19:51 ` [PATCH 1/2] hwrng: manage resource allocation in amd driver Matt Mackall
2011-05-04  5:13   ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome