Skip to content

Commit

Permalink
hwrng: amd - manage resource allocation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Eremin-Solenikov authored and Herbert Xu committed May 4, 2011
1 parent 0200f3e commit bd68ccb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/char/hw_random/amd-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ static int __init mod_init(void)
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;

Expand All @@ -141,6 +147,7 @@ static int __init mod_init(void)
if (err) {
printk(KERN_ERR PFX "RNG registering failed (%d)\n",
err);
release_region(pmbase + 0xF0, 8);
goto out;
}
out:
Expand All @@ -149,6 +156,8 @@ static int __init mod_init(void)

static void __exit mod_exit(void)
{
u32 pmbase = (unsigned long)amd_rng.priv;
release_region(pmbase + 0xF0, 8);
hwrng_unregister(&amd_rng);
}

Expand Down

0 comments on commit bd68ccb

Please sign in to comment.