* [PATCH] watchdog: core: Make use of devm_register_reboot_notifier()
@ 2017-04-04 14:10 Andrey Smirnov
2017-04-04 15:47 ` Andy Shevchenko
2017-04-04 16:39 ` Guenter Roeck
0 siblings, 2 replies; 5+ messages in thread
From: Andrey Smirnov @ 2017-04-04 14:10 UTC (permalink / raw)
To: linux-watchdog
Cc: Andrey Smirnov, cphealy, linux-kernel, Wim Van Sebroeck,
Guenter Roeck, Andrew Morton
Save a bit of cleanup code by leveraging newly added
devm_register_reboot_notifier().
Cc: cphealy@gmail.com
Cc: linux-kernel@vger.kernel.org
Cc: Wim Van Sebroeck <wim@iguana.be>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
All:
This patch is a follow up to this thread
https://lkml.org/lkml/2017/3/20/671. I am not sure what's the best way
to manager cross-tree dependency here, so, if there's something to be
done, please let me know.
Thanks,
Andrey Smirnov
drivers/watchdog/watchdog_core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 74265b2..9d868f1 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -247,7 +247,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
- ret = register_reboot_notifier(&wdd->reboot_nb);
+ ret = devm_register_reboot_notifier(wdd->parent,
+ &wdd->reboot_nb);
if (ret) {
pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
wdd->id, ret);
@@ -302,9 +303,6 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
if (wdd->ops->restart)
unregister_restart_handler(&wdd->restart_nb);
- if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status))
- unregister_reboot_notifier(&wdd->reboot_nb);
-
watchdog_dev_unregister(wdd);
ida_simple_remove(&watchdog_ida, wdd->id);
}
--
2.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: core: Make use of devm_register_reboot_notifier()
2017-04-04 14:10 [PATCH] watchdog: core: Make use of devm_register_reboot_notifier() Andrey Smirnov
@ 2017-04-04 15:47 ` Andy Shevchenko
2017-04-04 16:51 ` Guenter Roeck
2017-04-04 16:39 ` Guenter Roeck
1 sibling, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2017-04-04 15:47 UTC (permalink / raw)
To: Andrey Smirnov
Cc: linux-watchdog, Chris Healy, linux-kernel, Wim Van Sebroeck,
Guenter Roeck, Andrew Morton
On Tue, Apr 4, 2017 at 5:10 PM, Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
> Save a bit of cleanup code by leveraging newly added
> devm_register_reboot_notifier().
> @@ -247,7 +247,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
> if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
> wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
>
> - ret = register_reboot_notifier(&wdd->reboot_nb);
> + ret = devm_register_reboot_notifier(wdd->parent,
> + &wdd->reboot_nb);
I'm not sure it's logically correct. Perhaps binding to the actual
watchdog device would be better.
Though, Guenter can correct me.
Could it be one line after all?
> if (ret) {
> pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
> wdd->id, ret);
> @@ -302,9 +303,6 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
> if (wdd->ops->restart)
> unregister_restart_handler(&wdd->restart_nb);
>
> - if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status))
> - unregister_reboot_notifier(&wdd->reboot_nb);
> -
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: core: Make use of devm_register_reboot_notifier()
2017-04-04 14:10 [PATCH] watchdog: core: Make use of devm_register_reboot_notifier() Andrey Smirnov
2017-04-04 15:47 ` Andy Shevchenko
@ 2017-04-04 16:39 ` Guenter Roeck
1 sibling, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2017-04-04 16:39 UTC (permalink / raw)
To: Andrey Smirnov, linux-watchdog
Cc: cphealy, linux-kernel, Wim Van Sebroeck, Andrew Morton
On 04/04/2017 07:10 AM, Andrey Smirnov wrote:
> Save a bit of cleanup code by leveraging newly added
> devm_register_reboot_notifier().
>
> Cc: cphealy@gmail.com
> Cc: linux-kernel@vger.kernel.org
> Cc: Wim Van Sebroeck <wim@iguana.be>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>
> All:
>
> This patch is a follow up to this thread
> https://lkml.org/lkml/2017/3/20/671. I am not sure what's the best way
> to manager cross-tree dependency here, so, if there's something to be
> done, please let me know.
>
> Thanks,
> Andrey Smirnov
>
> drivers/watchdog/watchdog_core.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
> index 74265b2..9d868f1 100644
> --- a/drivers/watchdog/watchdog_core.c
> +++ b/drivers/watchdog/watchdog_core.c
> @@ -247,7 +247,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
> if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
> wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
>
> - ret = register_reboot_notifier(&wdd->reboot_nb);
> + ret = devm_register_reboot_notifier(wdd->parent,
> + &wdd->reboot_nb);
I like the idea, but unfortunately wdd->parent can be NULL. Also, this would result
in the notifier being removed _after_ the watchdog device has been removed, which
would be bad as well.
Guenter
> if (ret) {
> pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
> wdd->id, ret);
> @@ -302,9 +303,6 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
> if (wdd->ops->restart)
> unregister_restart_handler(&wdd->restart_nb);
>
> - if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status))
> - unregister_reboot_notifier(&wdd->reboot_nb);
> -
> watchdog_dev_unregister(wdd);
> ida_simple_remove(&watchdog_ida, wdd->id);
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: core: Make use of devm_register_reboot_notifier()
2017-04-04 15:47 ` Andy Shevchenko
@ 2017-04-04 16:51 ` Guenter Roeck
2017-04-04 16:56 ` Andy Shevchenko
0 siblings, 1 reply; 5+ messages in thread
From: Guenter Roeck @ 2017-04-04 16:51 UTC (permalink / raw)
To: Andy Shevchenko, Andrey Smirnov
Cc: linux-watchdog, Chris Healy, linux-kernel, Wim Van Sebroeck,
Andrew Morton
On 04/04/2017 08:47 AM, Andy Shevchenko wrote:
> On Tue, Apr 4, 2017 at 5:10 PM, Andrey Smirnov <andrew.smirnov@gmail.com> wrote:
>> Save a bit of cleanup code by leveraging newly added
>> devm_register_reboot_notifier().
>
>> @@ -247,7 +247,8 @@ static int __watchdog_register_device(struct watchdog_device *wdd)
>> if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status)) {
>> wdd->reboot_nb.notifier_call = watchdog_reboot_notifier;
>>
>> - ret = register_reboot_notifier(&wdd->reboot_nb);
>
>> + ret = devm_register_reboot_notifier(wdd->parent,
>> + &wdd->reboot_nb);
>
> I'm not sure it's logically correct. Perhaps binding to the actual
> watchdog device would be better.
> Though, Guenter can correct me.
>
As mentioned in my other reply, it doesn't work since wdd->parent can be NULL.
It might be possible to move the code into watchdog_dev_register() and tie it
to the watchdog device, but I have not explored what that would require.
Guenter
> Could it be one line after all?
>
>> if (ret) {
>> pr_err("watchdog%d: Cannot register reboot notifier (%d)\n",
>> wdd->id, ret);
>> @@ -302,9 +303,6 @@ static void __watchdog_unregister_device(struct watchdog_device *wdd)
>> if (wdd->ops->restart)
>> unregister_restart_handler(&wdd->restart_nb);
>>
>> - if (test_bit(WDOG_STOP_ON_REBOOT, &wdd->status))
>> - unregister_reboot_notifier(&wdd->reboot_nb);
>> -
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] watchdog: core: Make use of devm_register_reboot_notifier()
2017-04-04 16:51 ` Guenter Roeck
@ 2017-04-04 16:56 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2017-04-04 16:56 UTC (permalink / raw)
To: Guenter Roeck
Cc: Andrey Smirnov, linux-watchdog, Chris Healy, linux-kernel,
Wim Van Sebroeck, Andrew Morton
On Tue, Apr 4, 2017 at 7:51 PM, Guenter Roeck <linux@roeck-us.net> wrote:
> On 04/04/2017 08:47 AM, Andy Shevchenko wrote:
>> On Tue, Apr 4, 2017 at 5:10 PM, Andrey Smirnov <andrew.smirnov@gmail.com>
>> wrote:
>>> + ret = devm_register_reboot_notifier(wdd->parent,
>>> + &wdd->reboot_nb);
>>
>>
>> I'm not sure it's logically correct. Perhaps binding to the actual
>> watchdog device would be better.
>> Though, Guenter can correct me.
>>
>
> As mentioned in my other reply, it doesn't work since wdd->parent can be
> NULL.
> It might be possible to move the code into watchdog_dev_register() and tie
> it
> to the watchdog device, but I have not explored what that would require.
I would rather add device pointer to watchdoig struct, though it's your call :-)
So, what you decide I'll agree with.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-04 16:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 14:10 [PATCH] watchdog: core: Make use of devm_register_reboot_notifier() Andrey Smirnov
2017-04-04 15:47 ` Andy Shevchenko
2017-04-04 16:51 ` Guenter Roeck
2017-04-04 16:56 ` Andy Shevchenko
2017-04-04 16:39 ` Guenter Roeck
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).