Skip to content

Commit 78ca4d6

Browse files
jannauWim Van Sebroeck
authored andcommitted
watchdog: apple: Deactivate on suspend
The watchdog remains active after putting the system into suspend. Add PM callbacks to deactivate the watchdog on suspend an re-activate it on resume. Signed-off-by: Janne Grunau <[email protected]> Reviewed-by: Eric Curtin <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 49bd08b commit 78ca4d6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/watchdog/apple_wdt.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@ static int apple_wdt_probe(struct platform_device *pdev)
173173
if (!wdt->clk_rate)
174174
return -EINVAL;
175175

176+
platform_set_drvdata(pdev, wdt);
177+
176178
wdt->wdd.ops = &apple_wdt_ops;
177179
wdt->wdd.info = &apple_wdt_info;
178180
wdt->wdd.max_timeout = U32_MAX / wdt->clk_rate;
@@ -190,6 +192,28 @@ static int apple_wdt_probe(struct platform_device *pdev)
190192
return devm_watchdog_register_device(dev, &wdt->wdd);
191193
}
192194

195+
static int apple_wdt_resume(struct device *dev)
196+
{
197+
struct apple_wdt *wdt = dev_get_drvdata(dev);
198+
199+
if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd))
200+
apple_wdt_start(&wdt->wdd);
201+
202+
return 0;
203+
}
204+
205+
static int apple_wdt_suspend(struct device *dev)
206+
{
207+
struct apple_wdt *wdt = dev_get_drvdata(dev);
208+
209+
if (watchdog_active(&wdt->wdd) || watchdog_hw_running(&wdt->wdd))
210+
apple_wdt_stop(&wdt->wdd);
211+
212+
return 0;
213+
}
214+
215+
static DEFINE_SIMPLE_DEV_PM_OPS(apple_wdt_pm_ops, apple_wdt_suspend, apple_wdt_resume);
216+
193217
static const struct of_device_id apple_wdt_of_match[] = {
194218
{ .compatible = "apple,wdt" },
195219
{},
@@ -200,6 +224,7 @@ static struct platform_driver apple_wdt_driver = {
200224
.driver = {
201225
.name = "apple-watchdog",
202226
.of_match_table = apple_wdt_of_match,
227+
.pm = pm_sleep_ptr(&apple_wdt_pm_ops),
203228
},
204229
.probe = apple_wdt_probe,
205230
};

0 commit comments

Comments
 (0)