Re: [PATCH 2/7] watchdog: softdog: use watchdog core to init timeout value

2016-05-25 Thread Guenter Roeck
On Wed, May 25, 2016 at 08:37:44AM +0200, Wolfram Sang wrote:
> From: Wolfram Sang 
> 
> Error string and comment say we fall back to a default, but in reality
> we bailed out. Refactor the code to use the core helper which then
> matches the described behaviour. While updating the init message anyhow,
> shorten it while we are here; no need for versioning there as well and
> the name is already given via pr_fmt.
> 
> Signed-off-by: Wolfram Sang 

Reviewed-by: Guenter Roeck 

> ---
>  drivers/watchdog/softdog.c | 17 +
>  1 file changed, 5 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
> index 8bc0b164afc94b..a9ad27dd46502b 100644
> --- a/drivers/watchdog/softdog.c
> +++ b/drivers/watchdog/softdog.c
> @@ -111,22 +111,15 @@ static struct watchdog_device softdog_dev = {
>   .info = _info,
>   .ops = _ops,
>   .min_timeout = 1,
> - .max_timeout = 0x
> + .max_timeout = 65535,
> + .timeout = TIMER_MARGIN,
>  };
>  
>  static int __init watchdog_init(void)
>  {
>   int ret;
>  
> - /* Check that the soft_margin value is within it's range;
> -if not reset to the default */
> - if (soft_margin < 1 || soft_margin > 65535) {
> - pr_info("soft_margin must be 0 < soft_margin < 65536, using 
> %d\n",
> - TIMER_MARGIN);
> - return -EINVAL;
> - }
> - softdog_dev.timeout = soft_margin;
> -
> + watchdog_init_timeout(_dev, soft_margin, NULL);
>   watchdog_set_nowayout(_dev, nowayout);
>   watchdog_stop_on_reboot(_dev);
>  
> @@ -134,8 +127,8 @@ static int __init watchdog_init(void)
>   if (ret)
>   return ret;
>  
> - pr_info("Software Watchdog Timer: 0.08 initialized. soft_noboot=%d 
> soft_margin=%d sec soft_panic=%d (nowayout=%d)\n",
> - soft_noboot, soft_margin, soft_panic, nowayout);
> + pr_info("initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d 
> (nowayout=%d)\n",
> + soft_noboot, softdog_dev.timeout, soft_panic, nowayout);
>  
>   return 0;
>  }
> -- 
> 2.8.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] watchdog: softdog: use watchdog core to init timeout value

2016-05-25 Thread Wolfram Sang
From: Wolfram Sang 

Error string and comment say we fall back to a default, but in reality
we bailed out. Refactor the code to use the core helper which then
matches the described behaviour. While updating the init message anyhow,
shorten it while we are here; no need for versioning there as well and
the name is already given via pr_fmt.

Signed-off-by: Wolfram Sang 
---
 drivers/watchdog/softdog.c | 17 +
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c
index 8bc0b164afc94b..a9ad27dd46502b 100644
--- a/drivers/watchdog/softdog.c
+++ b/drivers/watchdog/softdog.c
@@ -111,22 +111,15 @@ static struct watchdog_device softdog_dev = {
.info = _info,
.ops = _ops,
.min_timeout = 1,
-   .max_timeout = 0x
+   .max_timeout = 65535,
+   .timeout = TIMER_MARGIN,
 };
 
 static int __init watchdog_init(void)
 {
int ret;
 
-   /* Check that the soft_margin value is within it's range;
-  if not reset to the default */
-   if (soft_margin < 1 || soft_margin > 65535) {
-   pr_info("soft_margin must be 0 < soft_margin < 65536, using 
%d\n",
-   TIMER_MARGIN);
-   return -EINVAL;
-   }
-   softdog_dev.timeout = soft_margin;
-
+   watchdog_init_timeout(_dev, soft_margin, NULL);
watchdog_set_nowayout(_dev, nowayout);
watchdog_stop_on_reboot(_dev);
 
@@ -134,8 +127,8 @@ static int __init watchdog_init(void)
if (ret)
return ret;
 
-   pr_info("Software Watchdog Timer: 0.08 initialized. soft_noboot=%d 
soft_margin=%d sec soft_panic=%d (nowayout=%d)\n",
-   soft_noboot, soft_margin, soft_panic, nowayout);
+   pr_info("initialized. soft_noboot=%d soft_margin=%d sec soft_panic=%d 
(nowayout=%d)\n",
+   soft_noboot, softdog_dev.timeout, soft_panic, nowayout);
 
return 0;
 }
-- 
2.8.1