public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: bcm2835_wdt: Switch to new sys-off handler API
@ 2026-03-02 18:08 Andrew Davis
  2026-03-02 19:37 ` Guenter Roeck
  2026-03-02 20:13 ` Florian Fainelli
  0 siblings, 2 replies; 3+ messages in thread
From: Andrew Davis @ 2026-03-02 18:08 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck, Florian Fainelli, Ray Jui,
	Scott Branden
  Cc: linux-watchdog, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Andrew Davis

Kernel now supports chained power-off handlers. Use
devm_register_sys_off_handler() that registers a power-off handler. Legacy
pm_power_off() will be removed once all drivers and archs are converted to
the new sys-off API.

Signed-off-by: Andrew Davis <afd@ti.com>
---
 drivers/watchdog/bcm2835_wdt.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/watchdog/bcm2835_wdt.c b/drivers/watchdog/bcm2835_wdt.c
index 9fcfee63905b9..6fd8b1b8e386a 100644
--- a/drivers/watchdog/bcm2835_wdt.c
+++ b/drivers/watchdog/bcm2835_wdt.c
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
+#include <linux/reboot.h>
 
 #define PM_RSTC				0x1c
 #define PM_RSTS				0x20
@@ -49,8 +50,6 @@ struct bcm2835_wdt {
 	spinlock_t		lock;
 };
 
-static struct bcm2835_wdt *bcm2835_power_off_wdt;
-
 static unsigned int heartbeat;
 static bool nowayout = WATCHDOG_NOWAYOUT;
 
@@ -150,9 +149,9 @@ static struct watchdog_device bcm2835_wdt_wdd = {
  * indicate to bootcode.bin not to reboot, then most of the chip will be
  * powered off.
  */
-static void bcm2835_power_off(void)
+static int bcm2835_power_off(struct sys_off_data *data)
 {
-	struct bcm2835_wdt *wdt = bcm2835_power_off_wdt;
+	struct bcm2835_wdt *wdt = data->cb_data;
 	u32 val;
 
 	/*
@@ -166,6 +165,8 @@ static void bcm2835_power_off(void)
 
 	/* Continue with normal reset mechanism */
 	__bcm2835_restart(wdt);
+
+	return NOTIFY_DONE;
 }
 
 static int bcm2835_wdt_probe(struct platform_device *pdev)
@@ -206,28 +207,17 @@ static int bcm2835_wdt_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
-	if (of_device_is_system_power_controller(pdev->dev.parent->of_node)) {
-		if (!pm_power_off) {
-			pm_power_off = bcm2835_power_off;
-			bcm2835_power_off_wdt = wdt;
-		} else {
-			dev_info(dev, "Poweroff handler already present!\n");
-		}
-	}
+	if (of_device_is_system_power_controller(pdev->dev.parent->of_node))
+		devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF,
+					      SYS_OFF_PRIO_DEFAULT,
+					      bcm2835_power_off, wdt);
 
 	dev_info(dev, "Broadcom BCM2835 watchdog timer");
 	return 0;
 }
 
-static void bcm2835_wdt_remove(struct platform_device *pdev)
-{
-	if (pm_power_off == bcm2835_power_off)
-		pm_power_off = NULL;
-}
-
 static struct platform_driver bcm2835_wdt_driver = {
 	.probe		= bcm2835_wdt_probe,
-	.remove		= bcm2835_wdt_remove,
 	.driver = {
 		.name =		"bcm2835-wdt",
 	},
-- 
2.39.2



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

* Re: [PATCH] watchdog: bcm2835_wdt: Switch to new sys-off handler API
  2026-03-02 18:08 [PATCH] watchdog: bcm2835_wdt: Switch to new sys-off handler API Andrew Davis
@ 2026-03-02 19:37 ` Guenter Roeck
  2026-03-02 20:13 ` Florian Fainelli
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-03-02 19:37 UTC (permalink / raw)
  To: Andrew Davis, Wim Van Sebroeck, Florian Fainelli, Ray Jui,
	Scott Branden
  Cc: linux-watchdog, linux-rpi-kernel, linux-arm-kernel, linux-kernel

On 3/2/26 10:08, Andrew Davis wrote:
> Kernel now supports chained power-off handlers. Use
> devm_register_sys_off_handler() that registers a power-off handler. Legacy
> pm_power_off() will be removed once all drivers and archs are converted to
> the new sys-off API.
> 
> Signed-off-by: Andrew Davis <afd@ti.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>



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

* Re: [PATCH] watchdog: bcm2835_wdt: Switch to new sys-off handler API
  2026-03-02 18:08 [PATCH] watchdog: bcm2835_wdt: Switch to new sys-off handler API Andrew Davis
  2026-03-02 19:37 ` Guenter Roeck
@ 2026-03-02 20:13 ` Florian Fainelli
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2026-03-02 20:13 UTC (permalink / raw)
  To: Andrew Davis, Wim Van Sebroeck, Guenter Roeck, Florian Fainelli,
	Ray Jui, Scott Branden
  Cc: linux-watchdog, linux-rpi-kernel, linux-arm-kernel, linux-kernel

On 3/2/26 10:08, Andrew Davis wrote:
> Kernel now supports chained power-off handlers. Use
> devm_register_sys_off_handler() that registers a power-off handler. Legacy
> pm_power_off() will be removed once all drivers and archs are converted to
> the new sys-off API.
> 
> Signed-off-by: Andrew Davis <afd@ti.com>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
-- 
Florian


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

end of thread, other threads:[~2026-03-02 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 18:08 [PATCH] watchdog: bcm2835_wdt: Switch to new sys-off handler API Andrew Davis
2026-03-02 19:37 ` Guenter Roeck
2026-03-02 20:13 ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox