]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/watchdog/tangox_wdt.c
Merge tag 'iio-fixes-for-4.17a' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / drivers / watchdog / tangox_wdt.c
index 202c4b9cc9212b779c9bc2145bbb9bac503c6cf6..b1de8297fa4001bf80494d59e7334ac0e70e56b5 100644 (file)
@@ -1,11 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  *  Copyright (C) 2015 Mans Rullgard <mans@mansr.com>
  *  SMP86xx/SMP87xx Watchdog driver
- *
- *  This program is free software; you can redistribute it and/or modify it
- *  under  the terms of the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the License, or (at your
- *  option) any later version.
  */
 
 #include <linux/bitops.h>
@@ -15,9 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
-#include <linux/notifier.h>
 #include <linux/platform_device.h>
-#include <linux/reboot.h>
 #include <linux/watchdog.h>
 
 #define DEFAULT_TIMEOUT 30
@@ -47,7 +41,6 @@ struct tangox_wdt_device {
        void __iomem *base;
        unsigned long clk_rate;
        struct clk *clk;
-       struct notifier_block restart;
 };
 
 static int tangox_wdt_set_timeout(struct watchdog_device *wdt,
@@ -96,24 +89,24 @@ static const struct watchdog_info tangox_wdt_info = {
        .identity = "tangox watchdog",
 };
 
+static int tangox_wdt_restart(struct watchdog_device *wdt,
+                             unsigned long action, void *data)
+{
+       struct tangox_wdt_device *dev = watchdog_get_drvdata(wdt);
+
+       writel(1, dev->base + WD_COUNTER);
+
+       return 0;
+}
+
 static const struct watchdog_ops tangox_wdt_ops = {
        .start          = tangox_wdt_start,
        .stop           = tangox_wdt_stop,
        .set_timeout    = tangox_wdt_set_timeout,
        .get_timeleft   = tangox_wdt_get_timeleft,
+       .restart        = tangox_wdt_restart,
 };
 
-static int tangox_wdt_restart(struct notifier_block *nb, unsigned long action,
-                             void *data)
-{
-       struct tangox_wdt_device *dev =
-               container_of(nb, struct tangox_wdt_device, restart);
-
-       writel(1, dev->base + WD_COUNTER);
-
-       return NOTIFY_DONE;
-}
-
 static int tangox_wdt_probe(struct platform_device *pdev)
 {
        struct tangox_wdt_device *dev;
@@ -174,18 +167,14 @@ static int tangox_wdt_probe(struct platform_device *pdev)
                tangox_wdt_start(&dev->wdt);
        }
 
+       watchdog_set_restart_priority(&dev->wdt, 128);
+
        err = watchdog_register_device(&dev->wdt);
        if (err)
                goto err;
 
        platform_set_drvdata(pdev, dev);
 
-       dev->restart.notifier_call = tangox_wdt_restart;
-       dev->restart.priority = 128;
-       err = register_restart_handler(&dev->restart);
-       if (err)
-               dev_warn(&pdev->dev, "failed to register restart handler\n");
-
        dev_info(&pdev->dev, "SMP86xx/SMP87xx watchdog registered\n");
 
        return 0;
@@ -202,7 +191,6 @@ static int tangox_wdt_remove(struct platform_device *pdev)
        tangox_wdt_stop(&dev->wdt);
        clk_disable_unprepare(dev->clk);
 
-       unregister_restart_handler(&dev->restart);
        watchdog_unregister_device(&dev->wdt);
 
        return 0;