watchdog: meson_gxbb_wdt: improve
Subsystems (2)
v2 cover watchdog: meson_gxbb_wdt: improve
Try to improve meson_gxbb_wdt driver to common view:
* Remove watchdog_stop_on_reboot (still can be activated by watchdog.stop_on_reboot=1) i think this driver configuration more useful becouse we can get reboot waranty for abnormal situations on shutdown stage
* Added timeout module param same as in other modules
* Added nowayout module param same as in other moduels
* Added missed watchdog_stop_on_unregister call
* Print watchdog success driver start status notification
Artem Lapkin (5):
watchdog: meson_gxbb_wdt: remove watchdog_stop_on_reboot
watchdog: meson_gxbb_wdt: add timeout module param
watchdog: meson_gxbb_wdt: add nowayout module param
watchdog: meson_gxbb_wdt: add stop_on_unregister
watchdog: meson_gxbb_wdt: add register device status notification
drivers/watchdog/meson_gxbb_wdt.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/5 watchdog: meson_gxbb_wdt: remove watchdog_stop_on_reboot
Remove watchdog_stop_on_reboot (still can be activated by watchdog.stop_on_reboot=1) i think this driver configuration more useful becouse we can get reboot waranty for abnormal situations on shutdown stage
--- drivers/watchdog/meson_gxbb_wdt.c | 1 - 1 file changed, 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +0 -1
@@ -186,7 +186,6 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)meson_gxbb_wdt_set_timeout (&data->wdt_dev, data->wdt_dev.timeout); -watchdog_stop_on_reboot (&data->wdt_dev);return devm_watchdog_register_device (dev, &data->wdt_dev); }
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH 1/5] watchdog: meson_gxbb_wdt: remove watchdog_stop_on_reboot
Quoted 4 lines · Artem Lapkin
Remove
watchdog_stop_on_reboot(still can be activated by watchdog.stop_on_reboot=1) i think this driver configuration more useful becouse we can get reboot waranty for abnormal situations on shutdown stage
This is personal opinion. Driver authors would have to agree.
Guenter
Quoted 18 lines
Signed-off-by Artem Lapkin <[email protected]>--- drivers/watchdog/meson_gxbb_wdt.c | 1 - 1 file changed, 1 deletion(-)drivers/watchdog/meson_gxbb_wdt.c +0
-1@@ -186,7 +186,6 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)meson_gxbb_wdt_set_timeout (&data->wdt_dev, data->wdt_dev.timeout); -watchdog_stop_on_reboot (&data->wdt_dev);return devm_watchdog_register_device (dev, &data->wdt_dev); }
PATCH v2 2/5 watchdog: meson_gxbb_wdt: add timeout module param
In reply to Artem LapkinAdded timeout module param same as in other modules
--- drivers/watchdog/meson_gxbb_wdt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +6 -1
@@ -29,6 +29,11 @@#define GXBB_WDT_TCNT_SETUP_MASK (BIT(16) - 1)#define GXBB_WDT_TCNT_CNT_SHIFT 16 +static unsigned int timeout =DEFAULT_TIMEOUT ; +module_param (timeout, uint,0 ); +MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds=" + __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +struct meson_gxbb_wdt {void __iomem *reg_base;struct watchdog_device wdt_dev;
@@ -174,7 +179,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) data->wdt_dev.ops = &meson_gxbb_wdt_ops; data->wdt_dev.max_hw_heartbeat_ms =GXBB_WDT_TCNT_SETUP_MASK ; data->wdt_dev.min_timeout =1 ; - data->wdt_dev.timeout =DEFAULT_TIMEOUT ; + data->wdt_dev.timeout = timeout;watchdog_set_drvdata (&data->wdt_dev, data);/* Setup with 1ms timebase */
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH 2/5] watchdog: meson_gxbb_wdt: add timeout module param
Quoted 24 lines · Artem Lapkin
Added timeout module param same as in other modules
Signed-off-by Artem Lapkin <[email protected]>--- drivers/watchdog/meson_gxbb_wdt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/watchdog/meson_gxbb_wdt.c +5
-0@@ -29,6 +29,11 @@#define GXBB_WDT_TCNT_SETUP_MASK (BIT(16) - 1)#define GXBB_WDT_TCNT_CNT_SHIFT 16 +static unsigned int timeout =DEFAULT_TIMEOUT ; +module_param (timeout, uint,0 ); +MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds=" + __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +struct meson_gxbb_wdt {void __iomem *reg_base;struct watchdog_device wdt_dev;
drivers/watchdog/meson_gxbb_wdt.c static int meson_gxbb_wdt_probe(struct platform_device *pdev) · line 182
Quoted 5 lines
drivers/watchdog/meson_gxbb_wdt.c +1
-1@@ -174,7 +179,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) data->wdt_dev.ops = &meson_gxbb_wdt_ops; data->wdt_dev.max_hw_heartbeat_ms =GXBB_WDT_TCNT_SETUP_MASK ; data->wdt_dev.min_timeout =1 ; - data->wdt_dev.timeout =DEFAULT_TIMEOUT ; + data->wdt_dev.timeout = timeout;
This is wrong. A timeout module parameter should be set with a call to watchdog_init_timeout(), the initial value should be 0, and data->wdt_dev.timeout should be kept as-is. This ensures that the module parameter is validated.
Guenter
Quoted 4 lines
drivers/watchdog/meson_gxbb_wdt.c +0
-0watchdog_set_drvdata (&data->wdt_dev, data);/* Setup with 1ms timebase */
PATCH v2 3/5 watchdog: meson_gxbb_wdt: add nowayout module param
In reply to Artem LapkinAdded nowayout module param same as in other moduels
--- drivers/watchdog/meson_gxbb_wdt.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/watchdog/meson_gxbb_wdt.c +6 -0
@@ -34,6 +34,11 @@ module_param(timeout, uint, 0); MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +static bool nowayout =WATCHDOG_NOWAYOUT ; +module_param (nowayout, bool,0 ); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started default=" + __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); +struct meson_gxbb_wdt {void __iomem *reg_base;struct watchdog_device wdt_dev;
@@ -190,6 +195,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) data->reg_base + GXBB_WDT_CTRL_REG);meson_gxbb_wdt_set_timeout (&data->wdt_dev, data->wdt_dev.timeout); +watchdog_set_nowayout (&data->wdt_dev, nowayout);return devm_watchdog_register_device (dev, &data->wdt_dev); }
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH 3/5] watchdog: meson_gxbb_wdt: add nowayout module param
Quoted 1 line · Artem Lapkin
Added nowayout module param same as in other moduels
Please use complete sentences and words, check your spelling (modules), and refrain from irrelevant statements such as "same as in other moduels".
"Add nowayout module parameter" is sufficient here.
Quoted 11 lines
Signed-off-by Artem Lapkin <[email protected]>--- drivers/watchdog/meson_gxbb_wdt.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/watchdog/meson_gxbb_wdt.c +0
-0
drivers/watchdog/meson_gxbb_wdt.c module_param(timeout, uint, 0); · line 39
Quoted 6 lines
drivers/watchdog/meson_gxbb_wdt.c +3
-0@@ -34,6 +34,11 @@ module_param(timeout, uint, 0); MODULE_PARM_DESC(timeout, "Watchdog heartbeat in seconds=" __MODULE_STRING(DEFAULT_TIMEOUT) ")"); +static bool nowayout =WATCHDOG_NOWAYOUT ; +module_param (nowayout, bool,0 ); +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started default="
'(' missing before 'default'
Quoted 14 lines
drivers/watchdog/meson_gxbb_wdt.c +3
-0+ __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); +struct meson_gxbb_wdt {void __iomem *reg_base;struct watchdog_device wdt_dev;@@ -190,6 +195,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev) data->reg_base + GXBB_WDT_CTRL_REG);meson_gxbb_wdt_set_timeout (&data->wdt_dev, data->wdt_dev.timeout); +watchdog_set_nowayout (&data->wdt_dev, nowayout);return devm_watchdog_register_device (dev, &data->wdt_dev); }
PATCH v2 4/5 watchdog: meson_gxbb_wdt: add stop_on_unregister
In reply to Artem LapkinAdded missed watchdog_stop_on_unregister call
--- drivers/watchdog/meson_gxbb_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/meson_gxbb_wdt.c +1 -0
@@ -196,6 +196,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)meson_gxbb_wdt_set_timeout (&data->wdt_dev, data->wdt_dev.timeout);watchdog_set_nowayout (&data->wdt_dev, nowayout); +watchdog_stop_on_unregister (&data->wdt_dev);return devm_watchdog_register_device (dev, &data->wdt_dev); }
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH 4/5] watchdog: meson_gxbb_wdt: add stop_on_unregister
Quoted 2 lines · Artem Lapkin
Added missed
watchdog_stop_on_unregistercall
This is again personal opinion and needs an acknowledgement by driver authors. It is only necessary if one wants to support that the watchdog is force-stopped by killing the watchdog daemon (which leaves the watchdog running) and subsequently unloading the driver. The call is not 'missing'; otherwise the core could just do it. For that reason it should not be added with the argument that it would be 'missing'. This will require a better argument. Why is that call needed ? What is the use case ?
Guenter
Quoted 18 lines
Signed-off-by Artem Lapkin <[email protected]>--- drivers/watchdog/meson_gxbb_wdt.c | 1 + 1 file changed, 1 insertion(+)drivers/watchdog/meson_gxbb_wdt.c +1
-0@@ -196,6 +196,7 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)meson_gxbb_wdt_set_timeout (&data->wdt_dev, data->wdt_dev.timeout);watchdog_set_nowayout (&data->wdt_dev, nowayout); +watchdog_stop_on_unregister (&data->wdt_dev);return devm_watchdog_register_device (dev, &data->wdt_dev); }
PATCH v2 5/5 watchdog: meson_gxbb_wdt: add register device status notification
In reply to Artem LapkinPrint watchdog success driver start status notification
--- drivers/watchdog/meson_gxbb_wdt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/watchdog/meson_gxbb_wdt.c +8 -1
@@ -198,7 +198,14 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)watchdog_set_nowayout (&data->wdt_dev, nowayout);watchdog_stop_on_unregister (&data->wdt_dev); -return devm_watchdog_register_device (dev, &data->wdt_dev); + ret =devm_watchdog_register_device (dev, &data->wdt_dev); +if (ret) +return ret; + +dev_info (dev,"Watchdog enabled (timeout=%d sec, nowayout=%d)" , + data->wdt_dev.timeout, nowayout); + +return ret; }static struct platform_driver meson_gxbb_wdt_driver = {
Signature · 1 line
2.25.1
Guenter Roeck
maintainerRe: [PATCH 5/5] watchdog: meson_gxbb_wdt: add register device status notification
Quoted 2 lines · Artem Lapkin
Print watchdog success driver start status notification
Another personal opinion: The driver author decided that the message is not needed (which matches my personal opinion). I'd rather see all those messages either go away or moved to the core. Either case, this one is
misleading: The watchdog is _not_ enabled. The watchdog driver is loaded, which is different.
Guenter
Quoted 26 lines
Signed-off-by Artem Lapkin <[email protected]>--- drivers/watchdog/meson_gxbb_wdt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)drivers/watchdog/meson_gxbb_wdt.c +8
-1@@ -198,7 +198,14 @@ static int meson_gxbb_wdt_probe(struct platform_device *pdev)watchdog_set_nowayout (&data->wdt_dev, nowayout);watchdog_stop_on_unregister (&data->wdt_dev); -return devm_watchdog_register_device (dev, &data->wdt_dev); + ret =devm_watchdog_register_device (dev, &data->wdt_dev); +if (ret) +return ret; + +dev_info (dev,"Watchdog enabled (timeout=%d sec, nowayout=%d)" , + data->wdt_dev.timeout, nowayout); + +return ret; }static struct platform_driver meson_gxbb_wdt_driver = {