Linux RTC
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Harald Geyer <harald@ccbib.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>,
	Wim Van Sebroeck <wim@iguana.be>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-watchdog@vger.kernel.org, rtc-linux@googlegroups.com,
	Wolfram Sang <wsa@the-dreams.de>,
	kernel@pengutronix.de, Fabio Estevam <festevam@gmail.com>
Subject: [rtc-linux] Re: [PATCHv3 1/2] watchdog: stmp3xxx: Stop the watchdog on system halt
Date: Thu, 26 Nov 2015 08:10:11 +0100	[thread overview]
Message-ID: <20151126071011.GL19888@pengutronix.de> (raw)
In-Reply-To: <1444220352-20548-1-git-send-email-harald@ccbib.org>

Hello,

On Wed, Oct 07, 2015 at 12:19:11PM +0000, Harald Geyer wrote:
> This allows the system to actually halt even if userspace forgot to
> disable the watchdog first. Old behaviour was that the watchdog forced
> the system to boot again.
>=20
> Signed-off-by: Harald Geyer <harald@ccbib.org>
> ---
> Changes since v2:
> * split this out as a separate patch
>=20
>  drivers/watchdog/stmp3xxx_rtc_wdt.c |   28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
>=20
> diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3=
xxx_rtc_wdt.c
> index 3ee6128..e09a01f 100644
> --- a/drivers/watchdog/stmp3xxx_rtc_wdt.c
> +++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c
> @@ -14,6 +14,8 @@
>  #include <linux/watchdog.h>
>  #include <linux/platform_device.h>
>  #include <linux/stmp3xxx_rtc_wdt.h>
> +#include <linux/notifier.h>
> +#include <linux/reboot.h>
> =20
>  #define WDOG_TICK_RATE 1000 /* 1 kHz clock */
>  #define STMP3XXX_DEFAULT_TIMEOUT 19
> @@ -69,6 +71,28 @@ static struct watchdog_device stmp3xxx_wdd =3D {
>  	.status =3D WATCHDOG_NOWAYOUT_INIT_STATUS,
>  };
> =20
> +static int wdt_notify_sys(struct notifier_block *nb, unsigned long code,
> +			  void *unused)
> +{
> +	struct device *dev =3D watchdog_get_drvdata(&stmp3xxx_wdd);
> +	struct stmp3xxx_wdt_pdata *pdata =3D dev_get_platdata(dev);
> +
> +	switch (code) {
> +	case SYS_DOWN:	/* keep enabled, system might crash while going down */
> +		break;
> +	case SYS_HALT:  /* allow the system to actually halt */

<nitpick>
You used a tab before the comment "keep enabled ...", but spaces for
"allow the system ...".
</nitpick>

> +	case SYS_POWER_OFF:
> +		wdt_stop(&stmp3xxx_wdd);
> +		break;
> +	}
> +
> +	return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block wdt_notifier =3D {
> +	.notifier_call  =3D wdt_notify_sys,

s/  / /

> +};
> +
>  static int stmp3xxx_wdt_probe(struct platform_device *pdev)
>  {
>  	int ret;
> @@ -84,6 +108,9 @@ static int stmp3xxx_wdt_probe(struct platform_device *=
pdev)
>  		return ret;
>  	}
> =20
> +	if (register_reboot_notifier(&wdt_notifier))
> +		dev_warn(&pdev->dev, "cannot register reboot notifier\n");

OK, you don't fail when registering the notifier fails, but ...

>  	dev_info(&pdev->dev, "initialized watchdog with heartbeat %ds\n",
>  			stmp3xxx_wdd.timeout);
>  	return 0;
> @@ -91,6 +118,7 @@ static int stmp3xxx_wdt_probe(struct platform_device *=
pdev)
> =20
>  static int stmp3xxx_wdt_remove(struct platform_device *pdev)
>  {
> +	unregister_reboot_notifier(&wdt_notifier);

... I think it's not ok to unconditionally unregister it then, is it?
(Looking at how unregister_reboot_notifier is implemented it might work
as intended, but if that's only by chance I wouldn't rely on it.)

Best regards
Uwe

>  	watchdog_unregister_device(&stmp3xxx_wdd);
>  	return 0;
>  }
> --=20
> 1.7.10.4
>=20
>=20
>=20

--=20
Pengutronix e.K.                           | Uwe Kleine-K=C3=B6nig         =
   |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

--=20
--=20
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---=20
You received this message because you are subscribed to the Google Groups "=
rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

  parent reply	other threads:[~2015-11-26  7:10 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-07 12:19 [rtc-linux] [PATCHv3 1/2] watchdog: stmp3xxx: Stop the watchdog on system halt Harald Geyer
2015-10-07 12:19 ` [rtc-linux] [PATCH 2/2] watchdog: stmp3xxx: Implement GETBOOTSTATUS Harald Geyer
2015-11-26  9:25   ` [rtc-linux] " Uwe Kleine-König
2015-11-26 13:39     ` Harald Geyer
2015-11-26 16:39       ` Uwe Kleine-König
2015-11-26 23:28         ` Harald Geyer
2015-11-27 10:02       ` Uwe Kleine-König
2015-11-27 10:44         ` Uwe Kleine-König
2015-11-29 10:41           ` Harald Geyer
2015-11-29 11:41             ` Uwe Kleine-König
2015-11-27 14:45         ` Alexandre Belloni
2015-11-25 22:12 ` [rtc-linux] Re: [PATCHv3,1/2] watchdog: stmp3xxx: Stop the watchdog on system halt Guenter Roeck
2015-11-26  7:10 ` Uwe Kleine-König [this message]
2015-11-26  9:38   ` [rtc-linux] Re: [PATCHv3 1/2] " Harald Geyer

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=20151126071011.GL19888@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=festevam@gmail.com \
    --cc=harald@ccbib.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=rtc-linux@googlegroups.com \
    --cc=wim@iguana.be \
    --cc=wsa@the-dreams.de \
    /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