watchdog: mpc8xxx: use devm_ioremap_resource to map memory
This simplifies the error paths and device unbinding. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
f0ded83b96
commit
de5f71222b
1 changed files with 7 additions and 12 deletions
|
@ -142,8 +142,7 @@ static struct watchdog_device mpc8xxx_wdt_dev = {
|
||||||
static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
|
static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
const struct of_device_id *match;
|
struct resource *res;
|
||||||
struct device_node *np = ofdev->dev.of_node;
|
|
||||||
const struct mpc8xxx_wdt_type *wdt_type;
|
const struct mpc8xxx_wdt_type *wdt_type;
|
||||||
u32 freq = fsl_get_sys_freq();
|
u32 freq = fsl_get_sys_freq();
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
@ -156,15 +155,15 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
|
||||||
if (!freq || freq == -1)
|
if (!freq || freq == -1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
wd_base = of_iomap(np, 0);
|
res = platform_get_resource(ofdev, IORESOURCE_MEM, 0);
|
||||||
if (!wd_base)
|
wd_base = devm_ioremap_resource(&ofdev->dev, res);
|
||||||
return -ENOMEM;
|
if (IS_ERR(wd_base))
|
||||||
|
return PTR_ERR(wd_base);
|
||||||
|
|
||||||
enabled = in_be32(&wd_base->swcrr) & SWCRR_SWEN;
|
enabled = in_be32(&wd_base->swcrr) & SWCRR_SWEN;
|
||||||
if (!enabled && wdt_type->hw_enabled) {
|
if (!enabled && wdt_type->hw_enabled) {
|
||||||
pr_info("could not be enabled in software\n");
|
pr_info("could not be enabled in software\n");
|
||||||
ret = -ENOSYS;
|
return -ENOSYS;
|
||||||
goto err_unmap;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the timeout in seconds */
|
/* Calculate the timeout in seconds */
|
||||||
|
@ -177,7 +176,7 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
|
||||||
ret = watchdog_register_device(&mpc8xxx_wdt_dev);
|
ret = watchdog_register_device(&mpc8xxx_wdt_dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("cannot register watchdog device (err=%d)\n", ret);
|
pr_err("cannot register watchdog device (err=%d)\n", ret);
|
||||||
goto err_unmap;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d (%d seconds)\n",
|
pr_info("WDT driver for MPC8xxx initialized. mode:%s timeout=%d (%d seconds)\n",
|
||||||
|
@ -191,9 +190,6 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev)
|
||||||
if (enabled)
|
if (enabled)
|
||||||
mod_timer(&wdt_timer, jiffies);
|
mod_timer(&wdt_timer, jiffies);
|
||||||
return 0;
|
return 0;
|
||||||
err_unmap:
|
|
||||||
iounmap(wd_base);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mpc8xxx_wdt_remove(struct platform_device *ofdev)
|
static int mpc8xxx_wdt_remove(struct platform_device *ofdev)
|
||||||
|
@ -202,7 +198,6 @@ static int mpc8xxx_wdt_remove(struct platform_device *ofdev)
|
||||||
reset ? "reset" : "machine check exception");
|
reset ? "reset" : "machine check exception");
|
||||||
del_timer_sync(&wdt_timer);
|
del_timer_sync(&wdt_timer);
|
||||||
watchdog_unregister_device(&mpc8xxx_wdt_dev);
|
watchdog_unregister_device(&mpc8xxx_wdt_dev);
|
||||||
iounmap(wd_base);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue