Linux-Watchdog Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] rtc: ds1307: provide an indication that the watchdog has fired
@ 2020-07-24  4:50 Chris Packham
  2020-07-24 14:32 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Chris Packham @ 2020-07-24  4:50 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni
  Cc: linux-rtc, linux-watchdog, linux-kernel, Chris Packham

There's not much feedback when the ds1388 watchdog fires. Generally it
yanks on the reset line and the board reboots. To provide some feedback
indicate that the watchdog has fired in the past. This should help
distinguish a watchdog triggered reset from a power interruption.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
 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..431b1a50c483 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)
+		dev_notice(ds1307->dev, "detected watchdog alarm flag\n");
 
 	ret = regmap_update_bits(ds1307->regmap, DS1388_REG_FLAG,
 				 DS1388_BIT_WF, 0);
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: ds1307: provide an indication that the watchdog has fired
  2020-07-24  4:50 [PATCH] rtc: ds1307: provide an indication that the watchdog has fired Chris Packham
@ 2020-07-24 14:32 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-07-24 14:32 UTC (permalink / raw)
  To: Chris Packham, a.zummo, alexandre.belloni
  Cc: linux-rtc, linux-watchdog, linux-kernel

On 7/23/20 9:50 PM, Chris Packham wrote:
> There's not much feedback when the ds1388 watchdog fires. Generally it
> yanks on the reset line and the board reboots. To provide some feedback
> indicate that the watchdog has fired in the past. This should help
> distinguish a watchdog triggered reset from a power interruption.
> 
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>  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..431b1a50c483 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)
> +		dev_notice(ds1307->dev, "detected watchdog alarm flag\n");
>  
>  	ret = regmap_update_bits(ds1307->regmap, DS1388_REG_FLAG,
>  				 DS1388_BIT_WF, 0);
> 

This should be reported with WDIOC_GETBOOTSTATUS / WDIOF_CARDRESET,
not as log message when starting the watchdog.

Guenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24  4:50 [PATCH] rtc: ds1307: provide an indication that the watchdog has fired Chris Packham
2020-07-24 14:32 ` Guenter Roeck

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