linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: a.zummo@towertech.it, alexandre.belloni@bootlin.com,
	linux-rtc@vger.kernel.org, linux-watchdog@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] rtc: ds1307: provide an indication that the watchdog has fired
Date: Sun, 26 Jul 2020 20:15:41 -0700	[thread overview]
Message-ID: <20200727031541.GA53573@roeck-us.net> (raw)
In-Reply-To: <20200726231306.734-1-chris.packham@alliedtelesis.co.nz>

On Mon, Jul 27, 2020 at 11:13:06AM +1200, Chris Packham wrote:
> There's not much feedback when the ds1388 watchdog fires. Generally it
> yanks on the reset line and the board reboots. Capture the fact that the
> watchdog has fired in the past so that userspace can retrieve it via
> WDIOC_GETBOOTSTATUS. This should help distinguish a watchdog triggered
> reset from a power interruption.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> Changes in v2:
> - Set bootstatus to WDIOF_CARDRESET and let userspace decide what to do with
>   the information.
> 
>  drivers/rtc/rtc-ds1307.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index 49702942bb08..209736db510d 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -868,6 +868,14 @@ static int ds1388_wdt_start(struct watchdog_device *wdt_dev)
>  	struct ds1307 *ds1307 = watchdog_get_drvdata(wdt_dev);
>  	u8 regs[2];
>  	int ret;
> +	int val;
> +
> +	ret = regmap_read(ds1307->regmap, DS1388_REG_FLAG, &val);
> +	if (ret)
> +		return ret;
> +
> +	if (val & DS1388_BIT_WF)
> +		wdt_dev->bootstatus = WDIOF_CARDRESET;

This should be done during probe, ie in ds1307_wdt_register().

Guenter

>  
>  	ret = regmap_update_bits(ds1307->regmap, DS1388_REG_FLAG,
>  				 DS1388_BIT_WF, 0);
> -- 
> 2.27.0
> 

      reply	other threads:[~2020-07-27  3:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-26 23:13 [PATCH v2] rtc: ds1307: provide an indication that the watchdog has fired Chris Packham
2020-07-27  3:15 ` 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=20200727031541.GA53573@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.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).