public inbox for linux-watchdog@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Radu Rendec <rrendec@arista.com>
Cc: Wim Van Sebroeck <wim@iguana.be>, linux-watchdog@vger.kernel.org
Subject: Re: [3/3] watchdog: i6300esb: do not hardcode heartbeat limits
Date: Sun, 22 Oct 2017 10:09:47 -0700	[thread overview]
Message-ID: <20171022170947.GA6997@roeck-us.net> (raw)
In-Reply-To: <20171016182528.3244-3-rrendec@arista.com>

On Mon, Oct 16, 2017 at 07:25:28PM +0100, Radu Rendec wrote:
> The minimum, maximum and default values for the watchdog heartbeat
> (timeout) were hardcoded in several places (including module parameter
> description and warning message for invalid module parameter value).
> 
> This patch adds macros for the aforementioned values and replaces all
> occurences of hardcoded values by these macros.
> 
> Signed-off-by: Radu Rendec <rrendec@arista.com>
> ---
>  drivers/watchdog/i6300esb.c | 24 +++++++++++++++---------
>  1 file changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/watchdog/i6300esb.c b/drivers/watchdog/i6300esb.c
> index 855b4f80ad09..68d76512b08f 100644
> --- a/drivers/watchdog/i6300esb.c
> +++ b/drivers/watchdog/i6300esb.c
> @@ -82,12 +82,16 @@ static int cards_found;
>  
>  /* module parameters */
>  /* 30 sec default heartbeat (1 < heartbeat < 2*1023) */
> -#define WATCHDOG_HEARTBEAT 30
> -static int heartbeat = WATCHDOG_HEARTBEAT;  /* in seconds */
> +#define ESB_HEARTBEAT_MIN 1
> +#define ESB_HEARTBEAT_MAX 2046
> +#define ESB_HEARTBEAT_DEFAULT 30
> +static int heartbeat = ESB_HEARTBEAT_DEFAULT;  /* in seconds */

Ah, I just noticed. This defeats watchdog_init_timeout().

In patch 1, the timeout in struct watchdog_device to the default,
and set this variable to 0. watchdog_init_timeout() will then overwrite
the default (which is set in struct watchdog_device) with the module
parameter if the module parameter is set to a value != 0.

Thanks,
Guenter

>  module_param(heartbeat, int, 0);
>  MODULE_PARM_DESC(heartbeat,
> -		"Watchdog heartbeat in seconds. (1<heartbeat<2046, default="
> -				__MODULE_STRING(WATCHDOG_HEARTBEAT) ")");
> +	"Watchdog heartbeat in seconds. ("
> +	__MODULE_STRING(ESB_HEARTBEAT_MIN) "<heartbeat<"
> +	__MODULE_STRING(ESB_HEARTBEAT_MAX) ", default="
> +	__MODULE_STRING(ESB_HEARTBEAT_DEFAULT) ")");
>  
>  static bool nowayout = WATCHDOG_NOWAYOUT;
>  module_param(nowayout, bool, 0);
> @@ -325,17 +329,19 @@ static int esb_probe(struct pci_dev *pdev,
>  
>  	/* Check that the heartbeat value is within it's range;
>  	   if not reset to the default */
> -	if (heartbeat < 0x1 || heartbeat > 2 * 0x03ff) {
> -		heartbeat = WATCHDOG_HEARTBEAT;
> -		pr_info("heartbeat value must be 1<heartbeat<2046, using %d\n",
> +	if (heartbeat < ESB_HEARTBEAT_MIN || heartbeat > ESB_HEARTBEAT_MAX) {
> +		heartbeat = ESB_HEARTBEAT_DEFAULT;
> +		pr_info("heartbeat value must be "
> +			__MODULE_STRING(ESB_HEARTBEAT_MIN) "<heartbeat<"
> +			__MODULE_STRING(ESB_HEARTBEAT_MAX) ", using %d\n",
>  			heartbeat);
>  	}
>  
>  	/* Initialize the watchdog and make sure it does not run */
>  	edev->wdd.info = &esb_info;
>  	edev->wdd.ops = &esb_ops;
> -	edev->wdd.min_timeout = 1;
> -	edev->wdd.max_timeout = 2 * 0x03ff;
> +	edev->wdd.min_timeout = ESB_HEARTBEAT_MIN;
> +	edev->wdd.max_timeout = ESB_HEARTBEAT_MAX;
>  	watchdog_init_timeout(&edev->wdd, heartbeat, NULL);
>  	watchdog_set_nowayout(&edev->wdd, nowayout);
>  	esb_initdevice(edev);

  reply	other threads:[~2017-10-22 17:09 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-16 18:25 [PATCH 1/3] watchdog: i6300esb: use the watchdog subsystem Radu Rendec
2017-10-16 18:25 ` [PATCH 2/3] watchdog: i6300esb: support multiple devices Radu Rendec
2017-10-22 17:05   ` [2/3] " Guenter Roeck
2017-10-16 18:25 ` [PATCH 3/3] watchdog: i6300esb: do not hardcode heartbeat limits Radu Rendec
2017-10-22 17:09   ` Guenter Roeck [this message]
2017-10-25 15:39     ` [PATCH v2 1/4] watchdog: i6300esb: use the watchdog subsystem Radu Rendec
2017-10-25 20:51       ` Guenter Roeck
2017-10-25 15:39     ` [PATCH v2 2/4] watchdog: i6300esb: support multiple devices Radu Rendec
2017-10-25 20:55       ` Guenter Roeck
2017-10-26 11:35         ` Radu Rendec
2017-10-26 13:51           ` Guenter Roeck
2017-10-26 16:10             ` [PATCH v3 1/4] watchdog: i6300esb: use the watchdog subsystem Radu Rendec
2017-10-27  1:03               ` Guenter Roeck
2017-10-26 16:10             ` [PATCH v3 2/4] watchdog: i6300esb: support multiple devices Radu Rendec
2017-10-27  1:02               ` Guenter Roeck
2017-10-27  1:04               ` Guenter Roeck
2017-10-26 16:10             ` [PATCH v3 3/4] watchdog: i6300esb: do not hardcode heartbeat limits Radu Rendec
2017-10-27  1:04               ` Guenter Roeck
2017-10-26 16:10             ` [PATCH v3 4/4] watchdog: i6300esb: remove info message and version number Radu Rendec
2017-10-27  1:05               ` Guenter Roeck
2017-10-27 10:58                 ` Radu Rendec
2017-10-25 15:39     ` [PATCH v2 3/4] watchdog: i6300esb: do not hardcode heartbeat limits Radu Rendec
2017-10-25 20:56       ` Guenter Roeck
2017-10-25 15:39     ` [PATCH v2 4/4] watchdog: i6300esb: bump version to 0.6 Radu Rendec
2017-10-25 20:57       ` Guenter Roeck
2017-10-22 17:02 ` [1/3] watchdog: i6300esb: use the watchdog subsystem Guenter Roeck

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=20171022170947.GA6997@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=rrendec@arista.com \
    --cc=wim@iguana.be \
    /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