From: Guenter Roeck <linux@roeck-us.net>
To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>,
Hans de Goede <hdegoede@redhat.com>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
linux-watchdog@vger.kernel.org
Subject: Re: [RFC RESEND PATCH v2 8/8] watchdog: retu_wdt: Clean-up by using managed work init
Date: Mon, 22 Mar 2021 07:05:45 -0700 [thread overview]
Message-ID: <20210322140545.GC140507@roeck-us.net> (raw)
In-Reply-To: <5f1a80d6f88d12b23dbb864e3201fe720cd9bb74.1616395565.git.matti.vaittinen@fi.rohmeurope.com>
On Mon, Mar 22, 2021 at 09:38:37AM +0200, Matti Vaittinen wrote:
> 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.
>
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Acked-by: Guenter Roeck <linux@roeck-us.net>
> ---
> 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 <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",
> },
> --
> 2.25.4
>
>
> --
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
>
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =]
next prev parent reply other threads:[~2021-03-22 14:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 7:41 [RFC RESEND PATCH v2 0/8] Add managed version of delayed work init Matti Vaittinen
2021-03-22 7:36 ` [RFC RESEND PATCH v2 1/8] workqueue: Add resource " Matti Vaittinen
2021-03-22 7:36 ` [RFC RESEND PATCH v2 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
2021-03-22 7:38 ` [RFC RESEND PATCH v2 8/8] watchdog: retu_wdt: Clean-up by using managed work init Matti Vaittinen
2021-03-22 14:05 ` Guenter Roeck [this message]
2021-03-23 12:43 ` [RFC RESEND PATCH v2 0/8] Add managed version of delayed " Greg KH
2021-03-23 13:16 ` Vaittinen, Matti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210322140545.GC140507@roeck-us.net \
--to=linux@roeck-us.net \
--cc=gregkh@linuxfoundation.org \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=matti.vaittinen@fi.rohmeurope.com \
--cc=mazziesaccount@gmail.com \
--cc=wim@linux-watchdog.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).