Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: minyard@acm.org
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
	linux-watchdog@vger.kernel.org,
	Corey Minyard <cminyard@mvista.com>
Subject: Re: [PATCH 05/10] watchdog: Export an interface to start the watchdog
Date: Tue, 30 Jun 2020 19:46:58 -0700
Message-ID: <20200701024658.GB84420@roeck-us.net> (raw)
In-Reply-To: <20200620174907.20229-6-minyard@acm.org>

On Sat, Jun 20, 2020 at 12:49:02PM -0500, minyard@acm.org wrote:
> From: Corey Minyard <cminyard@mvista.com>
> 
> This way a watchdog driver can start itself.

The watchdog driver can start itself prior to registration if
it wants to, like many other watchdog drivers already do. All the
driver needs to do is to call its own start function.
I do not see the need for this API.

Guenter

> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> ---
>  drivers/watchdog/watchdog_dev.c | 30 ++++++++++++++++++++++++++----
>  include/linux/watchdog.h        |  3 +++
>  2 files changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 6c423aed3f3c..752358df1606 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -253,7 +253,7 @@ static enum hrtimer_restart watchdog_timer_expired(struct hrtimer *timer)
>  }
>  
>  /*
> - *	watchdog_start: wrapper to start the watchdog.
> + *	_watchdog_start: wrapper to start the watchdog.
>   *	@wdd: the watchdog device to start
>   *
>   *	The caller must hold wd_data->lock.
> @@ -263,7 +263,7 @@ static enum hrtimer_restart watchdog_timer_expired(struct hrtimer *timer)
>   *	failure.
>   */
>  
> -static int watchdog_start(struct watchdog_device *wdd)
> +static int _watchdog_start(struct watchdog_device *wdd)
>  {
>  	struct watchdog_core_data *wd_data = wdd->wd_data;
>  	ktime_t started_at;
> @@ -289,6 +289,28 @@ static int watchdog_start(struct watchdog_device *wdd)
>  	return err;
>  }
>  
> +/*
> + *	watchdog_start: External interface to start the watchdog.
> + *	@wdd: the watchdog device to start
> + *
> + *	Start the watchdog if it is not active and mark it active.
> + *	This function returns zero on success or a negative errno code for
> + *	failure.
> + */
> +
> +int watchdog_start(struct watchdog_device *wdd)
> +{
> +	struct watchdog_core_data *wd_data = wdd->wd_data;
> +	int err;
> +
> +	mutex_lock(&wd_data->lock);
> +	err = _watchdog_start(wdd);
> +	mutex_unlock(&wd_data->lock);
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(watchdog_start);
> +
>  /*
>   *	watchdog_stop: wrapper to stop the watchdog.
>   *	@wdd: the watchdog device to stop
> @@ -837,7 +859,7 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
>  				break;
>  		}
>  		if (val & WDIOS_ENABLECARD)
> -			err = watchdog_start(wdd);
> +			err = _watchdog_start(wdd);
>  		break;
>  	case WDIOC_KEEPALIVE:
>  		if (!(wdd->info->options & WDIOF_KEEPALIVEPING)) {
> @@ -935,7 +957,7 @@ static int watchdog_open(struct inode *inode, struct file *file)
>  		goto out_clear;
>  	}
>  
> -	err = watchdog_start(wdd);
> +	err = _watchdog_start(wdd);
>  	if (err < 0)
>  		goto out_mod;
>  
> diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
> index 95396b644a9b..1eefae61215d 100644
> --- a/include/linux/watchdog.h
> +++ b/include/linux/watchdog.h
> @@ -205,6 +205,9 @@ static inline void *watchdog_get_drvdata(struct watchdog_device *wdd)
>  int watchdog_set_timeout(struct watchdog_device *wdd, unsigned int timeout);
>  int watchdog_set_pretimeout(struct watchdog_device *wdd, unsigned int timeout);
>  
> +/* Allow the driver to start the watchdog. */
> +int watchdog_start(struct watchdog_device *wdd);
> +
>  /* Use the following functions to report watchdog pretimeout event */
>  #if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_GOV)
>  void watchdog_notify_pretimeout(struct watchdog_device *wdd);
> -- 
> 2.17.1
> 

  reply index

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 17:48 [PATCH 00/10] Convert the IPMI watchdog to use " minyard
2020-06-20 17:48 ` [PATCH 01/10] watchdog: Ignore stop_on_reboot if no stop function minyard
2020-06-20 17:48 ` [PATCH 02/10] watchdog: Add read capability minyard
2020-06-20 17:49 ` [PATCH 03/10] watchdog: Add documentation for " minyard
2020-07-01  2:49   ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 04/10] watchdog: Add functions to set the timeout and pretimeout minyard
2020-07-01  2:45   ` Guenter Roeck
2020-06-20 17:49 ` [PATCH 05/10] watchdog: Export an interface to start the watchdog minyard
2020-07-01  2:46   ` Guenter Roeck [this message]
2020-06-20 17:49 ` [PATCH 06/10] ipmi:watchdog: Convert over to the watchdog framework minyard
2020-06-20 17:49 ` [PATCH 07/10] ipmi:watchdog: Allow the reboot timeout to be specified minyard
2020-06-20 17:49 ` [PATCH 08/10] watchdog: Add a way to extend the timeout on a reboot minyard
2020-06-20 17:49 ` [PATCH 09/10] ipmi:watchdog: Convert over to watchdog framework reboot handling minyard
2020-06-20 17:49 ` [PATCH 10/10] ipmi:watchdog: Add the op to get the current timeout minyard

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=20200701024658.GB84420@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=cminyard@mvista.com \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=minyard@acm.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

Linux-Watchdog Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-watchdog/0 linux-watchdog/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-watchdog linux-watchdog/ https://lore.kernel.org/linux-watchdog \
		linux-watchdog@vger.kernel.org
	public-inbox-index linux-watchdog

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-watchdog


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git