Commit 55dbe8f3 authored by Guenter Roeck's avatar Guenter Roeck

watchdog: asm9260_wdt: Use watchdog core to install restart handler

Use the infrastructure provided by the watchdog core to install
the restart handler.
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 3b72c41f
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/reboot.h>
#include <linux/reset.h> #include <linux/reset.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
...@@ -59,7 +58,6 @@ struct asm9260_wdt_priv { ...@@ -59,7 +58,6 @@ struct asm9260_wdt_priv {
struct clk *clk; struct clk *clk;
struct clk *clk_ahb; struct clk *clk_ahb;
struct reset_control *rst; struct reset_control *rst;
struct notifier_block restart_handler;
void __iomem *iobase; void __iomem *iobase;
int irq; int irq;
...@@ -172,15 +170,14 @@ static irqreturn_t asm9260_wdt_irq(int irq, void *devid) ...@@ -172,15 +170,14 @@ static irqreturn_t asm9260_wdt_irq(int irq, void *devid)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int asm9260_restart_handler(struct notifier_block *this, static int asm9260_restart(struct watchdog_device *wdd, unsigned long action,
unsigned long mode, void *cmd) void *data)
{ {
struct asm9260_wdt_priv *priv = struct asm9260_wdt_priv *priv = watchdog_get_drvdata(wdd);
container_of(this, struct asm9260_wdt_priv, restart_handler);
asm9260_wdt_sys_reset(priv); asm9260_wdt_sys_reset(priv);
return NOTIFY_DONE; return 0;
} }
static const struct watchdog_info asm9260_wdt_ident = { static const struct watchdog_info asm9260_wdt_ident = {
...@@ -196,6 +193,7 @@ static struct watchdog_ops asm9260_wdt_ops = { ...@@ -196,6 +193,7 @@ static struct watchdog_ops asm9260_wdt_ops = {
.get_timeleft = asm9260_wdt_gettimeleft, .get_timeleft = asm9260_wdt_gettimeleft,
.ping = asm9260_wdt_feed, .ping = asm9260_wdt_feed,
.set_timeout = asm9260_wdt_settimeout, .set_timeout = asm9260_wdt_settimeout,
.restart = asm9260_restart,
}; };
static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv) static int asm9260_wdt_get_dt_clks(struct asm9260_wdt_priv *priv)
...@@ -335,18 +333,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev) ...@@ -335,18 +333,14 @@ static int asm9260_wdt_probe(struct platform_device *pdev)
dev_warn(&pdev->dev, "failed to request IRQ\n"); dev_warn(&pdev->dev, "failed to request IRQ\n");
} }
watchdog_set_restart_priority(wdd, 128);
ret = watchdog_register_device(wdd); ret = watchdog_register_device(wdd);
if (ret) if (ret)
goto clk_off; goto clk_off;
platform_set_drvdata(pdev, priv); platform_set_drvdata(pdev, priv);
priv->restart_handler.notifier_call = asm9260_restart_handler;
priv->restart_handler.priority = 128;
ret = register_restart_handler(&priv->restart_handler);
if (ret)
dev_warn(&pdev->dev, "cannot register restart handler\n");
dev_info(&pdev->dev, "Watchdog enabled (timeout: %d sec, mode: %s)\n", dev_info(&pdev->dev, "Watchdog enabled (timeout: %d sec, mode: %s)\n",
wdd->timeout, mode_name[priv->mode]); wdd->timeout, mode_name[priv->mode]);
return 0; return 0;
...@@ -370,8 +364,6 @@ static int asm9260_wdt_remove(struct platform_device *pdev) ...@@ -370,8 +364,6 @@ static int asm9260_wdt_remove(struct platform_device *pdev)
asm9260_wdt_disable(&priv->wdd); asm9260_wdt_disable(&priv->wdd);
unregister_restart_handler(&priv->restart_handler);
watchdog_unregister_device(&priv->wdd); watchdog_unregister_device(&priv->wdd);
clk_disable_unprepare(priv->clk); clk_disable_unprepare(priv->clk);
......
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