watchdog: imx2_wdt: Drop .remove callback
Subsystems (2)
PATCH 1/1 watchdog: imx2_wdt: Drop .remove callback
.remove callback implementation doesn' call clk_disable_unprepare() which is buggy, actually, we can just use devm_watchdog_register_device() and devm_add_action_or_reset() to handle all necessary operations for remove action, then .remove callback can be dropped.
--- drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)
drivers/watchdog/imx2_wdt.c +10 -27
@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = { .max_register = 0x8, }; +static void imx2_wdt_action (void *data) +{ +clk_disable_unprepare (data); +} +static int __init imx2_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx2_wdt_action, wdev->clk); +if (ret) +return ret; +regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val &IMX2_WDT_WRSR_TOUT ?WDIOF_CARDRESET :0 ;
@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)*/ regmap_write (wdev->regmap,IMX2_WDT_WMCR ,0 ); - ret =watchdog_register_device (wdog); -if (ret) - goto disable_clk; - -dev_info (dev,"timeout %d sec (nowayout=%d)\n" , - wdog->timeout, nowayout); - -return 0 ; - -disable_clk: -clk_disable_unprepare (wdev->clk); -return ret; -} - -static int __exit imx2_wdt_remove(struct platform_device *pdev) -{ -struct watchdog_device *wdog =platform_get_drvdata (pdev); -struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); - -watchdog_unregister_device (wdog); - -if (imx2_wdt_is_running (wdev)) { -imx2_wdt_ping (wdog); -dev_crit (&pdev->dev,"Device removed: Expect reboot!\n" ); - } -return 0 ; +return devm_watchdog_register_device (dev, wdog); }static void imx2_wdt_shutdown (struct platform_device *pdev)
@@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = {MODULE_DEVICE_TABLE (of, imx2_wdt_dt_ids);static struct platform_driver imx2_wdt_driver = { - .remove =__exit_p (imx2_wdt_remove), .shutdown = imx2_wdt_shutdown, .driver = { .name =DRIVER_NAME ,
Signature · 1 line
2.7.4
Quoted 6 lines · Anson Huang
.remove callback implementation doesn' call
clk_disable_unprepare()which is buggy, actually, we can just usedevm_watchdog_register_device()anddevm_add_action_or_reset()to handle all necessary operations for remove action, then .remove callback can be dropped.Signed-off-by Anson Huang <[email protected]>
Quoted 74 lines
--- drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)drivers/watchdog/imx2_wdt.c +10
-27@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = { .max_register = 0x8, }; +static void imx2_wdt_action (void *data) +{ +clk_disable_unprepare (data); +} +static int __init imx2_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx2_wdt_action, wdev->clk); +if (ret) +return ret; +regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val &IMX2_WDT_WRSR_TOUT ?WDIOF_CARDRESET :0 ;@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)*/ regmap_write (wdev->regmap,IMX2_WDT_WMCR ,0 ); - ret =watchdog_register_device (wdog); -if (ret) - goto disable_clk; - -dev_info (dev,"timeout %d sec (nowayout=%d)\n" , - wdog->timeout, nowayout); - -return 0 ; - -disable_clk: -clk_disable_unprepare (wdev->clk); -return ret; -} - -static int __exit imx2_wdt_remove(struct platform_device *pdev) -{ -struct watchdog_device *wdog =platform_get_drvdata (pdev); -struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); - -watchdog_unregister_device (wdog); - -if (imx2_wdt_is_running (wdev)) { -imx2_wdt_ping (wdog); -dev_crit (&pdev->dev,"Device removed: Expect reboot!\n" ); - } -return 0 ; +return devm_watchdog_register_device (dev, wdog); }static void imx2_wdt_shutdown (struct platform_device *pdev)@@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = {MODULE_DEVICE_TABLE (of, imx2_wdt_dt_ids);static struct platform_driver imx2_wdt_driver = { - .remove =__exit_p (imx2_wdt_remove), .shutdown = imx2_wdt_shutdown, .driver = { .name =DRIVER_NAME ,
Quoted 15 lines · Anson Huang
.remove callback implementation doesn' call
clk_disable_unprepare()which is buggy, actually, we can just usedevm_watchdog_register_device()anddevm_add_action_or_reset()to handle all necessary operations for remove action, then .remove callback can be dropped.Signed-off-by Anson Huang <[email protected]>--- drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)drivers/watchdog/imx2_wdt.c +0
-0
drivers/watchdog/imx2_wdt.c static const struct regmap_config imx2_wdt_regmap_config = { · line 249
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +3
-0@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = { .max_register = 0x8, }; +static void imx2_wdt_action (void *data) +{ +clk_disable_unprepare (data);
Does this have the effect of stopping the watchdog? Maybe we can have a more expressive function name here (imx2_wdt_stop_clk or similar)?
Is there some watchdog core policy that tells if the watchdog should be stopped on unload?
Quoted 17 lines
drivers/watchdog/imx2_wdt.c +6
-0+} +static int __init imx2_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx2_wdt_action, wdev->clk); +if (ret) +return ret; +regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val &IMX2_WDT_WRSR_TOUT ?WDIOF_CARDRESET :0 ;
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 323
Quoted 9 lines
drivers/watchdog/imx2_wdt.c +0
-6@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)*/ regmap_write (wdev->regmap,IMX2_WDT_WMCR ,0 ); - ret =watchdog_register_device (wdog); -if (ret) - goto disable_clk; - -dev_info (dev,"timeout %d sec (nowayout=%d)\n" , - wdog->timeout, nowayout);
Does the core put this info in the kernel log? If not dropping it isn't obviously right enough to be done en passant.
Quoted 8 lines
drivers/watchdog/imx2_wdt.c +0
-8-return 0 ; - -disable_clk: -clk_disable_unprepare (wdev->clk); -return ret; -} - -static int __exit imx2_wdt_remove(struct platform_device *pdev)
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 342
Quoted 10 lines
drivers/watchdog/imx2_wdt.c +0
-10-{ -struct watchdog_device *wdog =platform_get_drvdata (pdev); -struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); - -watchdog_unregister_device (wdog); - -if (imx2_wdt_is_running (wdev)) { -imx2_wdt_ping (wdog); -dev_crit (&pdev->dev,"Device removed: Expect reboot!\n" ); - }
I also wonder about this one. This changes the timing behaviour and so IMHO shouldn't be done as a side effect of a cleanup patch.
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Hi, Uwe
Quoted 21 lines
Subject: Re: [PATCH] watchdog:
imx2_wdt: Drop .remove callbackdrivers/watchdog/imx2_wdt.c static const struct regmap_config
Quoted 17 lines · Anson Huang
.remove callback implementation doesn' call
clk_disable_unprepare()which is buggy, actually, we can just usedevm_watchdog_register_device()anddevm_add_action_or_reset()to handle all necessary operations for remove action, then .remove callback can be dropped.Signed-off-by Anson Huang <[email protected]>--- drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)drivers/watchdog/imx2_wdt.c +0
-0@@ -244,6 +244,11 @@ static const struct regmap_config
imx2_wdt_regmap_config= {
Quoted 8 lines
drivers/watchdog/imx2_wdt.c static const struct regmap_config imx2_wdt_regmap_config = { · line 249
Quoted 5 lines
drivers/watchdog/imx2_wdt.c +2
-0.max_register = 0x8, }; +static void imx2_wdt_action (void *data) { +clk_disable_unprepare (data);Does this have the effect of stopping the watchdog? Maybe we can have a more expressive function name here (
imx2_wdt_stop_clkor similar)?
This action is ONLY called when probe failed or device is removed, and if watchdog is running, the core driver will prevent it from being removed.
Quoted 3 lines
Is there some watchdog core policy that tells if the watchdog should be stopped on unload?
watchdog_stop_on_unregister() should be called in .probe function to make core policy stop the watchdog before removing it, but I think this driver does NOT call it, maybe I should add the API call, need Guenter to help confirm.
Quoted 23 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +2
-0+} +static int __init imx2_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct
platform_device*pdev)drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev)
Quoted 9 lines
drivers/watchdog/imx2_wdt.c +4
-0if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx2_wdt_action, wdev->clk); +if (ret) +return ret; +regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ?
WDIOF_CARDRESET: 0;drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct
Quoted 2 lines
drivers/watchdog/imx2_wdt.c +0
-0@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct
platform_device*pdev)Quoted 3 lines
drivers/watchdog/imx2_wdt.c +0
-0*/ regmap_write (wdev->regmap,IMX2_WDT_WMCR ,0 );
Quoted 9 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 323
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +0
-6- ret =watchdog_register_device (wdog); -if (ret) - goto disable_clk; - -dev_info (dev,"timeout %d sec (nowayout=%d)\n" , - wdog->timeout, nowayout);Does the core put this info in the kernel log? If not dropping it isn't obviously right enough to be done en passant.
This is just an info for user which I think NOT unnecessary, so I drop it in this patch as well.
Quoted 13 lines
Quoted 13 lines
drivers/watchdog/imx2_wdt.c +0
-12-return 0 ; - -disable_clk: -clk_disable_unprepare (wdev->clk); -return ret; -} - -static int __exit imx2_wdt_remove(struct platform_device *pdev) -{ -struct watchdog_device *wdog =platform_get_drvdata (pdev); -struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); - -watchdog_unregister_device (wdog);
Quoted 8 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 342
Quoted 5 lines
drivers/watchdog/imx2_wdt.c +0
-5- -if (imx2_wdt_is_running (wdev)) { -imx2_wdt_ping (wdog); -dev_crit (&pdev->dev,"Device removed: Expect reboot!\n" ); - }I also wonder about this one. This changes the timing behaviour and so IMHO shouldn't be done as a side effect of a cleanup patch.
Guenter has a comment of "use devm_watchdog_register_device(), and the watchdog subsystem should prevent removal if the watchdog is running ", so I thought no need to check the watchdog's status here, but after further check the core code of watchdog_cdev_unregister() function, I ONLY see it will check whether need to stop watchdog before unregister,
...
1083 if (watchdog_active(wdd) &&
1084 test_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status)) {
1085 watchdog_stop(wdd);
1086 }
Hi, Guenter
Do you think watchdog_stop_on_unregister() should be called in .probe function to
make watchdog stop before unregister?
Thanks,
Anson.
Guenter Roeck
maintainerQuoted 36 lines · Anson Huang
Hi, Uwe
Quoted 21 lines
Subject: Re: [PATCH] watchdog:
imx2_wdt: Drop .remove callbackdrivers/watchdog/imx2_wdt.c static const struct regmap_config
Quoted 17 lines · Anson Huang
.remove callback implementation doesn' call
clk_disable_unprepare()which is buggy, actually, we can just usedevm_watchdog_register_device()anddevm_add_action_or_reset()to handle all necessary operations for remove action, then .remove callback can be dropped.Signed-off-by Anson Huang <[email protected]>--- drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)drivers/watchdog/imx2_wdt.c +0
-0@@ -244,6 +244,11 @@ static const struct regmap_config
imx2_wdt_regmap_config= {Quoted 8 lines
drivers/watchdog/imx2_wdt.c static const struct regmap_config imx2_wdt_regmap_config = { · line 249
Quoted 5 lines
drivers/watchdog/imx2_wdt.c +2
-0.max_register = 0x8, }; +static void imx2_wdt_action (void *data) { +clk_disable_unprepare (data);Does this have the effect of stopping the watchdog? Maybe we can have a more expressive function name here (
imx2_wdt_stop_clkor similar)?This action is ONLY called when probe failed or device is removed, and if watchdog is running, the core driver will prevent it from being removed.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Is there some watchdog core policy that tells if the watchdog should be stopped on unload?
watchdog_stop_on_unregister()should be called in .probe function to make core policy stop the watchdog before removing it, but I think this driver does NOT call it, maybe I should add the API call, need Guenter to help confirm.
The driver doesn't have a stop function, which implies that the watchdog can not be stopped once started. Calling watchdog_stop_on_unregister() seems to be pointless.
That also implies that the watchdog can not be unloaded after it has been started since it can't be stopped. More on that below.
Quoted 58 lines
Quoted 23 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +2
-0+} +static int __init imx2_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct
platform_device*pdev)drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev)
Quoted 9 lines
drivers/watchdog/imx2_wdt.c +4
-0if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx2_wdt_action, wdev->clk); +if (ret) +return ret; +regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ?
WDIOF_CARDRESET: 0;drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct
Quoted 2 lines
drivers/watchdog/imx2_wdt.c +0
-0@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct
platform_device*pdev)Quoted 3 lines
drivers/watchdog/imx2_wdt.c +0
-0*/ regmap_write (wdev->regmap,IMX2_WDT_WMCR ,0 );Quoted 9 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 323
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +0
-6- ret =watchdog_register_device (wdog); -if (ret) - goto disable_clk; - -dev_info (dev,"timeout %d sec (nowayout=%d)\n" , - wdog->timeout, nowayout);Does the core put this info in the kernel log? If not dropping it isn't obviously right enough to be done en passant.
This is just an info for user which I think NOT unnecessary, so I drop it in this patch as well.
Quoted 13 lines
Quoted 13 lines
drivers/watchdog/imx2_wdt.c +0
-12-return 0 ; - -disable_clk: -clk_disable_unprepare (wdev->clk); -return ret; -} - -static int __exit imx2_wdt_remove(struct platform_device *pdev) -{ -struct watchdog_device *wdog =platform_get_drvdata (pdev); -struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); - -watchdog_unregister_device (wdog);Quoted 8 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 342
Quoted 5 lines
drivers/watchdog/imx2_wdt.c +0
-5- -if (imx2_wdt_is_running (wdev)) { -imx2_wdt_ping (wdog); -dev_crit (&pdev->dev,"Device removed: Expect reboot!\n" ); - }I also wonder about this one. This changes the timing behaviour and so IMHO shouldn't be done as a side effect of a cleanup patch.
Quoted 5 lines
Guenter has a comment of "use
devm_watchdog_register_device(), and the watchdog subsystem should prevent removal if the watchdog is running ", so I thought no need to check the watchdog's status here, but after further check the core code ofwatchdog_cdev_unregister()function, I ONLY see it will check whether need to stop watchdog before unregister,
I would suggest for someone to try and trigger this message, and let me know how you did it. If the watchdog is running, it should not be possible to unload the driver; attempts to unload it should result in -EBUSY. If it is possible to unload the driver, there is a bug in watchdog core which will need to get fixed.
Quoted 11 lines
...
1083 if (
watchdog_active(wdd)&&
1084test_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status)) {
1085watchdog_stop(wdd);
1086 }Hi, Guenter
Do you thinkwatchdog_stop_on_unregister()should be called in .probe function to
make watchdog stop before unregister?
How would you expect the watchdog core to stop the watchdog with no stop function in the driver ?
Thanks,
Guenter
Quoted 2 lines · Guenter Roeck
How would you expect the watchdog core to stop the watchdog with no stop function in the driver ?
I'm not 100% sure, but I think the situation is that you cannot stop the watchdog in the watchdog register range, but if you stop the clock it will never expire.
That's why I asked if the devm action callback stops the watchdog.
Didn't look into the details though ...
Best regards
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | https://www.pengutronix.de/ |
Guenter Roeck
maintainerQuoted 10 lines · Uwe Kleine-König
Quoted 2 lines · Guenter Roeck
How would you expect the watchdog core to stop the watchdog with no stop function in the driver ?
I'm not 100% sure, but I think the situation is that you cannot stop the watchdog in the watchdog register range, but if you stop the clock it will never expire.
That's why I asked if the devm action callback stops the watchdog.
Again, it should not be possible to unload the driver if the watchdog is running.
Guenter
Hi, Guenter
Quoted 134 lines
Subject: Re: [PATCH] watchdog:
imx2_wdt: Drop .remove callbackQuoted 36 lines · Anson Huang
Hi, Uwe
Quoted 21 lines
Subject: Re: [PATCH] watchdog:
imx2_wdt: Drop .remove callbackdrivers/watchdog/imx2_wdt.c static const struct regmap_config
Quoted 17 lines · Anson Huang
.remove callback implementation doesn' call
clk_disable_unprepare()which is buggy, actually, we can just usedevm_watchdog_register_device()anddevm_add_action_or_reset()to handle all necessary operations for remove action, then .remove callback can be dropped.Signed-off-by Anson Huang <[email protected]>--- drivers/watchdog/imx2_wdt.c | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-)(quoted diff) +0
-0
b/drivers/watchdog/imx2_wdt.cindex f8d58bf..1fe472f 100644drivers/watchdog/imx2_wdt.c +0
-0@@ -244,6 +244,11 @@ static const struct regmap_config
imx2_wdt_regmap_config= {Quoted 8 lines
drivers/watchdog/imx2_wdt.c static const struct regmap_config imx2_wdt_regmap_config = { · line 249
Quoted 5 lines
drivers/watchdog/imx2_wdt.c +2
-0.max_register = 0x8, }; +static void imx2_wdt_action (void *data) { +clk_disable_unprepare (data);Does this have the effect of stopping the watchdog? Maybe we can have a more expressive function name here (
imx2_wdt_stop_clkor similar)?This action is ONLY called when probe failed or device is removed, and if watchdog is running, the core driver will prevent it from being removed.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Is there some watchdog core policy that tells if the watchdog should be stopped on unload?
watchdog_stop_on_unregister()should be called in .probe function to make core policy stop the watchdog before removing it, but I think this driver does NOT call it, maybe I should add the API call, need Guenterto help confirm.
Quoted 1 line
The driver doesn't have a stop function, which implies that the watchdog can not be stopped once started. Calling
watchdog_stop_on_unregister()seems to be pointless.That also implies that the watchdog can not be unloaded after it has been started since it can't be stopped. More on that below.
Quoted 58 lines
Quoted 23 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +2
-0+} +static int __init imx2_wdt_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct
platform_device*pdev)drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev)
Quoted 9 lines
drivers/watchdog/imx2_wdt.c +4
-0if (ret)return ret; + ret =devm_add_action_or_reset (dev, imx2_wdt_action, wdev->clk); +if (ret) +return ret; +regmap_read (wdev->regmap,IMX2_WDT_WRSR , &val); wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ?
WDIOF_CARDRESET: 0;drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct
Quoted 2 lines
drivers/watchdog/imx2_wdt.c +0
-0@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct
platform_device*pdev)Quoted 3 lines
drivers/watchdog/imx2_wdt.c +0
-0*/ regmap_write (wdev->regmap,IMX2_WDT_WMCR ,0 );Quoted 9 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 323
Quoted 6 lines
drivers/watchdog/imx2_wdt.c +0
-6- ret =watchdog_register_device (wdog); -if (ret) - goto disable_clk; - -dev_info (dev,"timeout %d sec (nowayout=%d)\n" , - wdog->timeout, nowayout);Does the core put this info in the kernel log? If not dropping it isn't obviously right enough to be done en passant.
This is just an info for user which I think NOT unnecessary, so I drop it in this patch as well.
Quoted 13 lines
Quoted 13 lines
drivers/watchdog/imx2_wdt.c +0
-12-return 0 ; - -disable_clk: -clk_disable_unprepare (wdev->clk); -return ret; -} - -static int __exit imx2_wdt_remove(struct platform_device *pdev) -{ -struct watchdog_device *wdog =platform_get_drvdata (pdev); -struct imx2_wdt_device *wdev =watchdog_get_drvdata (wdog); - -watchdog_unregister_device (wdog);Quoted 8 lines
drivers/watchdog/imx2_wdt.c static int __init imx2_wdt_probe(struct platform_device *pdev) · line 342
Quoted 5 lines
drivers/watchdog/imx2_wdt.c +0
-5- -if (imx2_wdt_is_running (wdev)) { -imx2_wdt_ping (wdog); -dev_crit (&pdev->dev,"Device removed: Expect reboot!\n" ); - }I also wonder about this one. This changes the timing behaviour and so IMHO shouldn't be done as a side effect of a cleanup patch.
Quoted 1 line
Guenter has a comment of "use
devm_watchdog_register_device(), andthe
Quoted 6 lines
watchdog subsystem should prevent removal if the watchdog is running ", so I thought no need to check the watchdog's status here, but after further check the core code of
watchdog_cdev_unregister()function, I ONLY see it will check whether need to stop watchdog before unregister,I would suggest for someone to try and trigger this message, and let me know how you did it. If the watchdog is running, it should not be possible to unload the driver; attempts to unload it should result in
-EBUSY. If it is possible to unload the driver, there is a bug in watchdog core which will need to get fixed.Quoted 7 lines
...
1083 if (
watchdog_active(wdd)&&
1084test_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status)) {
1085watchdog_stop(wdd);
1086 }
Quoted 7 lines
Quoted 2 lines
Hi, Guenter
Do you thinkwatchdog_stop_on_unregister()should be calledin .probe
Quoted 2 lines
function to make watchdog stop before unregister?
How would you expect the watchdog core to stop the watchdog with no stop function in the driver ?
Now I understand your point, thanks for you detail explanation.
Thanks,
Anson