Commit 6e9b5e76 authored by PrasannaKumar Muralidharan's avatar PrasannaKumar Muralidharan Committed by Herbert Xu
Browse files

hwrng: geode - Migrate to managed API



Use devm_ioremap and devm_hwrng_register instead of ioremap and
hwrng_register. This removes error handling code. Also moved code around
by removing goto statements. This improves code readability.
Signed-off-by: default avatarPrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 94879fa8
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <asm/io.h> #include <asm/io.h>
#define PFX KBUILD_MODNAME ": "
#define GEODE_RNG_DATA_REG 0x50 #define GEODE_RNG_DATA_REG 0x50
#define GEODE_RNG_STATUS_REG 0x54 #define GEODE_RNG_STATUS_REG 0x54
...@@ -85,7 +82,6 @@ static struct hwrng geode_rng = { ...@@ -85,7 +82,6 @@ static struct hwrng geode_rng = {
static int __init mod_init(void) static int __init mod_init(void)
{ {
int err = -ENODEV;
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
const struct pci_device_id *ent; const struct pci_device_id *ent;
void __iomem *mem; void __iomem *mem;
...@@ -93,43 +89,27 @@ static int __init mod_init(void) ...@@ -93,43 +89,27 @@ static int __init mod_init(void)
for_each_pci_dev(pdev) { for_each_pci_dev(pdev) {
ent = pci_match_id(pci_tbl, pdev); ent = pci_match_id(pci_tbl, pdev);
if (ent) if (ent) {
goto found; rng_base = pci_resource_start(pdev, 0);
} if (rng_base == 0)
/* Device not found. */ return -ENODEV;
goto out;
mem = devm_ioremap(&pdev->dev, rng_base, 0x58);
found: if (IS_ERR(mem))
rng_base = pci_resource_start(pdev, 0); return PTR_ERR(mem);
if (rng_base == 0) geode_rng.priv = (unsigned long)mem;
goto out;
err = -ENOMEM; pr_info("AMD Geode RNG detected\n");
mem = ioremap(rng_base, 0x58); return devm_hwrng_register(&pdev->dev, &geode_rng);
if (!mem) }
goto out;
geode_rng.priv = (unsigned long)mem;
pr_info("AMD Geode RNG detected\n");
err = hwrng_register(&geode_rng);
if (err) {
pr_err(PFX "RNG registering failed (%d)\n",
err);
goto err_unmap;
} }
out:
return err;
err_unmap: /* Device not found. */
iounmap(mem); return -ENODEV;
goto out;
} }
static void __exit mod_exit(void) static void __exit mod_exit(void)
{ {
void __iomem *mem = (void __iomem *)geode_rng.priv;
hwrng_unregister(&geode_rng);
iounmap(mem);
} }
module_init(mod_init); module_init(mod_init);
......
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