2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-17 01:34:00 +08:00

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 <linux@roeck-us.net>
Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/be299515fbee2c311162ca99ea0dbee933044b56.1616506559.git.matti.vaittinen@fi.rohmeurope.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Matti Vaittinen 2021-03-23 15:58:28 +02:00 committed by Greg Kroah-Hartman
parent b668801515
commit a7d30f3f41

View File

@ -8,6 +8,7 @@
* Rewritten by Aaro Koskinen.
*/
#include <linux/devm-helpers.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/device.h>
@ -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",
},