Commit bd68ccb3 authored by Dmitry Eremin-Solenikov's avatar Dmitry Eremin-Solenikov Committed by Herbert Xu

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: default avatarDmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0200f3ec
...@@ -133,6 +133,12 @@ static int __init mod_init(void) ...@@ -133,6 +133,12 @@ static int __init mod_init(void)
pmbase &= 0x0000FF00; pmbase &= 0x0000FF00;
if (pmbase == 0) if (pmbase == 0)
goto out; 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_rng.priv = (unsigned long)pmbase;
amd_pdev = pdev; amd_pdev = pdev;
...@@ -141,6 +147,7 @@ static int __init mod_init(void) ...@@ -141,6 +147,7 @@ static int __init mod_init(void)
if (err) { if (err) {
printk(KERN_ERR PFX "RNG registering failed (%d)\n", printk(KERN_ERR PFX "RNG registering failed (%d)\n",
err); err);
release_region(pmbase + 0xF0, 8);
goto out; goto out;
} }
out: out:
...@@ -149,6 +156,8 @@ static int __init mod_init(void) ...@@ -149,6 +156,8 @@ static int __init mod_init(void)
static void __exit mod_exit(void) static void __exit mod_exit(void)
{ {
u32 pmbase = (unsigned long)amd_rng.priv;
release_region(pmbase + 0xF0, 8);
hwrng_unregister(&amd_rng); hwrng_unregister(&amd_rng);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment