watchdog: meson_wdt: fix register and callback of reboot notfiy
authorBo Yang <bo.yang@amlogic.com>
Fri, 7 Jul 2017 10:24:50 +0000 (18:24 +0800)
committerBo Yang <bo.yang@amlogic.com>
Sat, 8 Jul 2017 03:13:59 +0000 (20:13 -0700)
PD#147089: watchdog: meson_wdt: fix register and callback of reboot notify

The function register_reboot_notifier() use the wrong notifier_block
variable. So the container_of in the callback can't get the right pointer
of the struct.

The watchdog is disable in case of system down. If the kernel panic, the
reboot notify should ignore that.

Change-Id: I3fd21590808f4b380ddd54883db576e5c13c04a1
Signed-off-by: Bo Yang <bo.yang@amlogic.com>
drivers/amlogic/watchdog/meson_wdt.c

index c4f768b..b520618 100644 (file)
@@ -268,9 +268,10 @@ static int aml_wtd_reboot_notify(struct notifier_block *nb,
 {
        struct aml_wdt_dev *wdev;
 
-       wdev = container_of(nb, struct aml_wdt_dev, reboot_notifier);
-
-       disable_watchdog(wdev);
+       if (event == SYS_DOWN || event == SYS_HALT) {
+               wdev = container_of(nb, struct aml_wdt_dev, reboot_notifier);
+               disable_watchdog(wdev);
+       }
        pr_info("disable watchdog\n");
        return NOTIFY_OK;
 }
@@ -324,10 +325,10 @@ static int aml_wdt_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
-       wdev->reboot_notifier = aml_wdt_pm_notifier;
+       wdev->pm_notifier = aml_wdt_pm_notifier;
        wdev->reboot_notifier = aml_wdt_reboot_notifier;
-       register_pm_notifier(&aml_wdt_pm_notifier);
-       register_reboot_notifier(&aml_wdt_reboot_notifier);
+       register_pm_notifier(&wdev->pm_notifier);
+       register_reboot_notifier(&wdev->reboot_notifier);
        dev_info(wdev->dev, "AML Watchdog Timer probed done\n");
 
        return 0;