From a7d30f3f41cf40aad1c4557fa180fe320d5b7c74 Mon Sep 17 00:00:00 2001 From: Matti Vaittinen Date: Tue, 23 Mar 2021 15:58:28 +0200 Subject: [PATCH] watchdog: retu_wdt: Clean-up by using managed work init Few drivers implement remove call-back only for ensuring a delayed work gets cancelled prior driver removal. Clean-up these by switching to use devm_delayed_work_autocancel() instead. This change is compile-tested only. All testing is appreciated. Acked-by: Guenter Roeck Signed-off-by: Matti Vaittinen Link: https://lore.kernel.org/r/be299515fbee2c311162ca99ea0dbee933044b56.1616506559.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/retu_wdt.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/watchdog/retu_wdt.c b/drivers/watchdog/retu_wdt.c index 258dfcf9cbda..2b9017e1cd91 100644 --- a/drivers/watchdog/retu_wdt.c +++ b/drivers/watchdog/retu_wdt.c @@ -8,6 +8,7 @@ * Rewritten by Aaro Koskinen. */ +#include #include #include #include @@ -127,9 +128,12 @@ static int retu_wdt_probe(struct platform_device *pdev) wdev->rdev = rdev; wdev->dev = &pdev->dev; - INIT_DELAYED_WORK(&wdev->ping_work, retu_wdt_ping_work); + ret = devm_delayed_work_autocancel(&pdev->dev, &wdev->ping_work, + retu_wdt_ping_work); + if (ret) + return ret; - ret = watchdog_register_device(retu_wdt); + ret = devm_watchdog_register_device(&pdev->dev, retu_wdt); if (ret < 0) return ret; @@ -138,25 +142,11 @@ static int retu_wdt_probe(struct platform_device *pdev) else retu_wdt_ping_enable(wdev); - platform_set_drvdata(pdev, retu_wdt); - - return 0; -} - -static int retu_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdog = platform_get_drvdata(pdev); - struct retu_wdt_dev *wdev = watchdog_get_drvdata(wdog); - - watchdog_unregister_device(wdog); - cancel_delayed_work_sync(&wdev->ping_work); - return 0; } static struct platform_driver retu_wdt_driver = { .probe = retu_wdt_probe, - .remove = retu_wdt_remove, .driver = { .name = "retu-wdt", },