Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: mtk_wdt: add wdt shutdown callback to disable wdt if enabled

Without .shutdown(), watchdog might reset the system during power off.
For example, if watchdog's timeout is set to 30s, then it is reset to
zero by mtk_wdt_ping(). During power off, no app will ping watchdog,
but watchdog is still running and may trigger reset.

Signed-off-by: Greta Zhang <greta.zhang@mediatek.com>
Signed-off-by: Eddie Huang <eddie.huang@mediatek.com>
Acked-by: Matthias Brugger <matthias.bgg@gmail.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Greta Zhang and committed by
Wim Van Sebroeck
5724485b 9fab0692

+9
+9
drivers/watchdog/mtk_wdt.c
··· 210 210 return 0; 211 211 } 212 212 213 + static void mtk_wdt_shutdown(struct platform_device *pdev) 214 + { 215 + struct mtk_wdt_dev *mtk_wdt = platform_get_drvdata(pdev); 216 + 217 + if (watchdog_active(&mtk_wdt->wdt_dev)) 218 + mtk_wdt_stop(&mtk_wdt->wdt_dev); 219 + } 220 + 213 221 static int mtk_wdt_remove(struct platform_device *pdev) 214 222 { 215 223 struct mtk_wdt_dev *mtk_wdt = platform_get_drvdata(pdev); ··· 267 259 static struct platform_driver mtk_wdt_driver = { 268 260 .probe = mtk_wdt_probe, 269 261 .remove = mtk_wdt_remove, 262 + .shutdown = mtk_wdt_shutdown, 270 263 .driver = { 271 264 .name = DRV_NAME, 272 265 .pm = &mtk_wdt_pm_ops,