linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Curtis Klein <curtis.klein@hpe.com>, wim@linux-watchdog.org
Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] watchdog: only run driver set_pretimeout op if device supports it
Date: Sun, 27 Jun 2021 08:01:04 -0700	[thread overview]
Message-ID: <42547712-88c9-b432-f049-f2db8447739d@roeck-us.net> (raw)
In-Reply-To: <1624751265-24785-1-git-send-email-curtis.klein@hpe.com>

On 6/26/21 4:47 PM, Curtis Klein wrote:
> Some watchdog devices might conditionally support pretimeouts (e.g. if
> an interrupt is exposed for the device) but some watchdog drivers might
> still define the set_pretimeout operation (e.g. the mtk_wdt driver) and
> indicate support at runtime through the WDIOF_PRETIMEOUT flag. If the
> kernel is compiled with CONFIG_WATCHDOG_HRTIMER_PRETIMEOUT enabled,
> watchdog_set_pretimeout would run the driver specific set_pretimeout
> even if WDIOF_PRETIMEOUT is not set which might have unintended
> consequences.
> 
> So this change checks that the device flags and only runs the driver
> operation if pretimeouts are supported.
> 
> Signed-off-by: Curtis Klein <curtis.klein@hpe.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>   drivers/watchdog/watchdog_dev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 3bab324..5bf795c 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -401,7 +401,7 @@ static int watchdog_set_pretimeout(struct watchdog_device *wdd,
>   	if (watchdog_pretimeout_invalid(wdd, timeout))
>   		return -EINVAL;
>   
> -	if (wdd->ops->set_pretimeout)
> +	if (wdd->ops->set_pretimeout && (wdd->info->options & WDIOF_PRETIMEOUT))
>   		err = wdd->ops->set_pretimeout(wdd, timeout);
>   	else
>   		wdd->pretimeout = timeout;
> 


      reply	other threads:[~2021-06-27 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-26 23:47 [PATCH] watchdog: only run driver set_pretimeout op if device supports it Curtis Klein
2021-06-27 15:01 ` Guenter Roeck [this message]

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=42547712-88c9-b432-f049-f2db8447739d@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=curtis.klein@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@linux-watchdog.org \
    /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;
as well as URLs for NNTP newsgroup(s).