Commit da28caaa authored by PrasannaKumar Muralidharan's avatar PrasannaKumar Muralidharan Committed by Herbert Xu

hwrng: pasemi - Migrate to managed API

Use devm_ioremap and devm_hwrng_register instead of ioremap and
hwrng_register. This removes unregistering and error handling code.

Changes in v2:
Remove hardcoded resource size in ioremap, use resource struct obtained
by calling platform_get_resource.

Removing hardcoded resource size was suggested by LABBE Corentin.

CC: Darren Stevens <darren@stevens-zone.net>
Suggested-by: default avatarLABBE Corentin <clabbe.montjoie@gmail.com>
Signed-off-by: default avatarPrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent b4587456
...@@ -95,42 +95,20 @@ static struct hwrng pasemi_rng = { ...@@ -95,42 +95,20 @@ static struct hwrng pasemi_rng = {
.data_read = pasemi_rng_data_read, .data_read = pasemi_rng_data_read,
}; };
static int rng_probe(struct platform_device *ofdev) static int rng_probe(struct platform_device *pdev)
{ {
void __iomem *rng_regs; void __iomem *rng_regs;
struct device_node *rng_np = ofdev->dev.of_node; struct resource *res;
struct resource res;
int err = 0;
err = of_address_to_resource(rng_np, 0, &res); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (err) rng_regs = devm_ioremap_resource(&pdev->dev, res);
return -ENODEV; if (IS_ERR(rng_regs))
return PTR_ERR(rng_regs);
rng_regs = ioremap(res.start, 0x100);
if (!rng_regs)
return -ENOMEM;
pasemi_rng.priv = (unsigned long)rng_regs; pasemi_rng.priv = (unsigned long)rng_regs;
pr_info("Registering PA Semi RNG\n"); pr_info("Registering PA Semi RNG\n");
return devm_hwrng_register(&pdev->dev, &pasemi_rng);
err = hwrng_register(&pasemi_rng);
if (err)
iounmap(rng_regs);
return err;
}
static int rng_remove(struct platform_device *dev)
{
void __iomem *rng_regs = (void __iomem *)pasemi_rng.priv;
hwrng_unregister(&pasemi_rng);
iounmap(rng_regs);
return 0;
} }
static const struct of_device_id rng_match[] = { static const struct of_device_id rng_match[] = {
...@@ -146,7 +124,6 @@ static struct platform_driver rng_driver = { ...@@ -146,7 +124,6 @@ static struct platform_driver rng_driver = {
.of_match_table = rng_match, .of_match_table = rng_match,
}, },
.probe = rng_probe, .probe = rng_probe,
.remove = rng_remove,
}; };
module_platform_driver(rng_driver); module_platform_driver(rng_driver);
......
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