Commit 436867b6 authored by Anson Huang's avatar Anson Huang Committed by Wim Van Sebroeck

watchdog: imx2_wdt: Drop .remove callback

.remove callback implementation doesn' call clk_disable_unprepare() which
is buggy, actually, we can just use devm_watchdog_register_device() and
devm_add_action_or_reset() to handle all necessary operations for remove
action, then .remove callback can be dropped.
Signed-off-by: default avatarAnson Huang <Anson.Huang@nxp.com>
Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/1582512687-13312-1-git-send-email-Anson.Huang@nxp.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
parent 9232c806
...@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = { ...@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = {
.max_register = 0x8, .max_register = 0x8,
}; };
static void imx2_wdt_action(void *data)
{
clk_disable_unprepare(data);
}
static int __init imx2_wdt_probe(struct platform_device *pdev) static int __init imx2_wdt_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ...@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ret = devm_add_action_or_reset(dev, imx2_wdt_action, wdev->clk);
if (ret)
return ret;
regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val); regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0; wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
...@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) ...@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
*/ */
regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0); regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);
ret = watchdog_register_device(wdog); return devm_watchdog_register_device(dev, wdog);
if (ret)
goto disable_clk;
dev_info(dev, "timeout %d sec (nowayout=%d)\n",
wdog->timeout, nowayout);
return 0;
disable_clk:
clk_disable_unprepare(wdev->clk);
return ret;
}
static int __exit imx2_wdt_remove(struct platform_device *pdev)
{
struct watchdog_device *wdog = platform_get_drvdata(pdev);
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
watchdog_unregister_device(wdog);
if (imx2_wdt_is_running(wdev)) {
imx2_wdt_ping(wdog);
dev_crit(&pdev->dev, "Device removed: Expect reboot!\n");
}
return 0;
} }
static void imx2_wdt_shutdown(struct platform_device *pdev) static void imx2_wdt_shutdown(struct platform_device *pdev)
...@@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = { ...@@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = {
MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids); MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids);
static struct platform_driver imx2_wdt_driver = { static struct platform_driver imx2_wdt_driver = {
.remove = __exit_p(imx2_wdt_remove),
.shutdown = imx2_wdt_shutdown, .shutdown = imx2_wdt_shutdown,
.driver = { .driver = {
.name = DRIVER_NAME, .name = DRIVER_NAME,
......
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