From: Guenter Roeck <linux@roeck-us.net>
To: Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>,
Hans de Goede <hansg@kernel.org>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>,
linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] devres: add managed timer shutdown helper
Date: Wed, 4 Nov 2026 15:23:18 -0800 [thread overview]
Message-ID: <6d490e67-82a2-44b0-be16-3aa46e7c0430@roeck-us.net> (raw)
In-Reply-To: <CADZg-m3Mnk_QJ44HrH4SkCm+pN5QteeQv8zY9Q7EE7RQv65O8A@mail.gmail.com>
On 11/4/26 15:03, Kirtikumar Anandrao Ramchandani wrote:
> Provide a devres action for initialized timers. The action calls
> timer_shutdown_sync(), draining the callback and rejecting later rearming
> before device-managed storage is released.
>
> Use devm_add_action_or_reset() so a failed action registration shuts the
> timer down immediately.
>
> Signed-off-by: Kirtikumar Anandrao Ramchandani <kirtiar15502@gmail.com>
I see no benefit in this patch. The calling code now calls
devm_timer_autoshutdown() instead of devm_add_action_or_reset().
That does not really make a difference. Sure, we could add similar
code for every instance of devm_add_action_or_reset() in the kernel,
but what would be the point ?
Guenter
> ---
> include/linux/devm-helpers.h | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/include/linux/devm-helpers.h b/include/linux/devm-helpers.h
> index 708ca9131..ffe8b68b7 100644
> --- a/include/linux/devm-helpers.h
> +++ b/include/linux/devm-helpers.h
> @@ -24,8 +24,33 @@
> */
>
> #include <linux/device.h>
> +#include <linux/timer.h>
> #include <linux/workqueue.h>
>
> +static inline void devm_timer_shutdown(void *res)
> +{
> + timer_shutdown_sync(res);
> +}
> +
> +/**
> + * devm_timer_autoshutdown - Shut down an initialized timer on resource release
> + * @dev: Device whose lifetime the timer is bound to
> + * @timer: Initialized timer to shut down
> + *
> + * Register a timer_shutdown_sync() action. Register this action before
> + * arming the timer, and after resources that its callback may access.
> + * The timer is shut down immediately if action registration fails.
> + *
> + * The callback's resources must remain live until shutdown completes. Any
> + * independent user of the timer must stop before the timer's storage is
> + * released. Devres actions run in reverse registration order.
> + */
> +static inline int devm_timer_autoshutdown(struct device *dev,
> + struct timer_list *timer)
> +{
> + return devm_add_action_or_reset(dev, devm_timer_shutdown, timer);
> +}
> +
> static inline void devm_delayed_work_drop(void *res)
> {
> cancel_delayed_work_sync(res);
prev parent reply other threads:[~2026-11-04 23:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 23:03 Kirtikumar Anandrao Ramchandani
2026-11-04 23:23 ` Guenter Roeck [this message]
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=6d490e67-82a2-44b0-be16-3aa46e7c0430@roeck-us.net \
--to=linux@roeck-us.net \
--cc=hansg@kernel.org \
--cc=kirtiar15502@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
/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
all inboxes | Powered by JetHome®