hwrng: bcm2835 - Obtain base register via resource

In preparation for consolidating bcm63xx-rng into bcm2835-rng, make sure
that we obtain the base register via platform_get_resource() since we
need to support the non-DT enabled MIPS-based BCM63xx DSL SoCs.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Florian Fainelli 2017-11-07 16:44:38 -08:00 коммит произвёл Herbert Xu
Родитель 9e054ec21e
Коммит 21bb0ef43c
1 изменённых файлов: 10 добавлений и 10 удалений

Просмотреть файл

@ -81,21 +81,23 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
void (*rng_setup)(void __iomem *base);
const struct of_device_id *rng_id;
void __iomem *rng_base;
struct resource *r;
int err;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
/* map peripheral */
rng_base = of_iomap(np, 0);
if (!rng_base) {
rng_base = devm_ioremap_resource(dev, r);
if (IS_ERR(rng_base)) {
dev_err(dev, "failed to remap rng regs");
return -ENODEV;
return PTR_ERR(rng_base);
}
bcm2835_rng_ops.priv = (unsigned long)rng_base;
rng_id = of_match_node(bcm2835_rng_of_match, np);
if (!rng_id) {
iounmap(rng_base);
if (!rng_id)
return -EINVAL;
}
/* Check for rng init function, execute it */
rng_setup = rng_id->data;
if (rng_setup)
@ -107,10 +109,9 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
/* register driver */
err = hwrng_register(&bcm2835_rng_ops);
if (err) {
if (err)
dev_err(dev, "hwrng registration failed\n");
iounmap(rng_base);
} else
else
dev_info(dev, "hwrng registered\n");
return err;
@ -125,7 +126,6 @@ static int bcm2835_rng_remove(struct platform_device *pdev)
/* unregister driver */
hwrng_unregister(&bcm2835_rng_ops);
iounmap(rng_base);
return 0;
}