From: Roland Stigge <stigge@antcom.de>
To: Wolfram Sang <w.sang@pengutronix.de>
Cc: linux-watchdog@vger.kernel.org, Wim Van Sebroeck <wim@iguana.be>
Subject: Re: [PATCH 3/4] watchdog: dev: don't enforce set_timeout()
Date: Thu, 02 Feb 2012 21:04:46 +0100 [thread overview]
Message-ID: <4F2AEC5E.8060704@antcom.de> (raw)
In-Reply-To: <1328204891-32551-4-git-send-email-w.sang@pengutronix.de>
On 02/02/2012 06:48 PM, Wolfram Sang wrote:
> Some watchdogs rewrite the timer on every ping, so they don't need a specific
> set_timeout callback. Allow the callback to be empty for such devices.
>
> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
> .../watchdog/convert_drivers_to_kernel_api.txt | 10 ++++++----
> Documentation/watchdog/watchdog-kernel-api.txt | 4 +++-
> drivers/watchdog/watchdog_dev.c | 11 ++++++-----
> 3 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/watchdog/convert_drivers_to_kernel_api.txt b/Documentation/watchdog/convert_drivers_to_kernel_api.txt
> index be8119b..25647a3 100644
> --- a/Documentation/watchdog/convert_drivers_to_kernel_api.txt
> +++ b/Documentation/watchdog/convert_drivers_to_kernel_api.txt
> @@ -51,10 +51,12 @@ Here is a overview of the functions and probably needed actions:
> set
>
> WDIOC_SETTIMEOUT:
> - Options in watchdog_info need to have WDIOF_SETTIMEOUT set
> - and a set_timeout-callback has to be defined. The core will also
> - do limit-checking, if min_timeout and max_timeout in the watchdog
> - device are set. All is optional.
> + Options in watchdog_info need to have WDIOF_SETTIMEOUT set. The core
> + will also do limit-checking, if min_timeout and max_timeout in the
> + watchdog device are set. By default, the timeout variable of the
> + watchdog device will simply get updated. Additionally, a
> + set_timeout-callback can be defined if further actions are needed
> + (e.g. hardware setup, more advanced checks). All is optional.
>
> WDIOC_GETTIMEOUT:
> No preparations needed
> diff --git a/Documentation/watchdog/watchdog-kernel-api.txt b/Documentation/watchdog/watchdog-kernel-api.txt
> index 4b93c28..dcf1cfe 100644
> --- a/Documentation/watchdog/watchdog-kernel-api.txt
> +++ b/Documentation/watchdog/watchdog-kernel-api.txt
> @@ -121,7 +121,9 @@ they are supported. These optional routines/operations are:
> value of the watchdog_device will be changed to the value that was just used
> to re-program the watchdog timer device.
> (Note: the WDIOF_SETTIMEOUT needs to be set in the options field of the
> - watchdog's info structure).
> + watchdog's info structure. If it is set, and no set_timeout function is
> + provided, only the update of the timeout value will happen. This is enough
> + if the ping of the watchdog will rewrite the timer anyway.)
> * ioctl: if this routine is present then it will be called first before we do
> our own internal ioctl call handling. This routine should return -ENOIOCTLCMD
> if a command is not supported. The parameters that are passed to the ioctl
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 1199da0..ec224b4 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -215,17 +215,18 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
> watchdog_ping(wdd);
> return 0;
> case WDIOC_SETTIMEOUT:
> - if ((wdd->ops->set_timeout == NULL) ||
> - !(wdd->info->options & WDIOF_SETTIMEOUT))
> + if (!(wdd->info->options & WDIOF_SETTIMEOUT))
> return -EOPNOTSUPP;
> if (get_user(val, p))
> return -EFAULT;
> if ((wdd->max_timeout != 0) &&
> (val < wdd->min_timeout || val > wdd->max_timeout))
> return -EINVAL;
> - err = wdd->ops->set_timeout(wdd, val);
> - if (err < 0)
> - return err;
> + if (wdd->ops->set_timeout) {
> + err = wdd->ops->set_timeout(wdd, val);
> + if (err < 0)
> + return err;
> + }
> wdd->timeout = val;
> /* If the watchdog is active then we send a keepalive ping
> * to make sure that the watchdog keep's running (and if
Tested-by: Roland Stigge <stigge@antcom.de>
next prev parent reply other threads:[~2012-02-02 20:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-02 17:48 [PATCH 0/4] pnx4008: convert to watchdog framework Wolfram Sang
2012-02-02 17:48 ` [PATCH 1/4] watchdog: pnx4008: cleanup resource handling using managed devices Wolfram Sang
2012-02-02 20:04 ` Roland Stigge
2012-02-02 17:48 ` [PATCH 2/4] watchdog: pnx4008: don't use __raw_-accessors Wolfram Sang
2012-02-02 20:04 ` Roland Stigge
2012-02-02 17:48 ` [PATCH 3/4] watchdog: dev: don't enforce set_timeout() Wolfram Sang
2012-02-02 20:04 ` Roland Stigge [this message]
2012-03-14 18:40 ` Wolfram Sang
2012-03-15 21:18 ` Wim Van Sebroeck
2012-02-02 17:48 ` [PATCH 4/4] watchdog: pnx4008: convert driver to use the watchdog framework Wolfram Sang
2012-02-02 20:04 ` Roland Stigge
2012-02-02 20:02 ` [PATCH 0/4] pnx4008: convert to " Roland Stigge
2012-02-02 20:23 ` Wolfram Sang
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=4F2AEC5E.8060704@antcom.de \
--to=stigge@antcom.de \
--cc=linux-watchdog@vger.kernel.org \
--cc=w.sang@pengutronix.de \
--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