From 1674fa1ab5f328ffd4fe692a64e25e29937018de Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Fri, 7 Jul 2017 18:24:50 +0800 Subject: [PATCH] watchdog: meson_wdt: fix register and callback of reboot notfiy 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 --- drivers/amlogic/watchdog/meson_wdt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/amlogic/watchdog/meson_wdt.c b/drivers/amlogic/watchdog/meson_wdt.c index c4f768b..b520618 100644 --- a/drivers/amlogic/watchdog/meson_wdt.c +++ b/drivers/amlogic/watchdog/meson_wdt.c @@ -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; -- 2.7.4