aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2011-04-27 15:21:15 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2011-05-04 01:13:15 -0400
commitbd68ccb390f0d91e26e6f3252ba457ee4e06974a (patch)
treea66d7a020af3596dc2f066a99f2fe9936dbb57d5 /drivers/char
parent0200f3ecc19660bebeabbcbaf212957fcf1dbf8f (diff)
hwrng: amd - manage resource allocation
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> Acked-by: Matt Mackall <mpm@selenic.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/amd-rng.c9
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 0d8c5788b8e4..c6af038682f1 100644
--- a/drivers/char/hw_random/amd-rng.c
+++ b/drivers/char/hw_random/amd-rng.c
@@ -133,6 +133,12 @@ found:
133 pmbase &= 0x0000FF00; 133 pmbase &= 0x0000FF00;
134 if (pmbase == 0) 134 if (pmbase == 0)
135 goto out; 135 goto out;
136 if (!request_region(pmbase + 0xF0, 8, "AMD HWRNG")) {
137 dev_err(&pdev->dev, "AMD HWRNG region 0x%x already in use!\n",
138 pmbase + 0xF0);
139 err = -EBUSY;
140 goto out;
141 }
136 amd_rng.priv = (unsigned long)pmbase; 142 amd_rng.priv = (unsigned long)pmbase;
137 amd_pdev = pdev; 143 amd_pdev = pdev;
138 144
@@ -141,6 +147,7 @@ found:
141 if (err) { 147 if (err) {
142 printk(KERN_ERR PFX "RNG registering failed (%d)\n", 148 printk(KERN_ERR PFX "RNG registering failed (%d)\n",
143 err); 149 err);
150 release_region(pmbase + 0xF0, 8);
144 goto out; 151 goto out;
145 } 152 }
146out: 153out:
@@ -149,6 +156,8 @@ out:
149 156
150static void __exit mod_exit(void) 157static void __exit mod_exit(void)
151{ 158{
159 u32 pmbase = (unsigned long)amd_rng.priv;
160 release_region(pmbase + 0xF0, 8);
152 hwrng_unregister(&amd_rng); 161 hwrng_unregister(&amd_rng);
153} 162}
154 163