All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] [PATCH] change reboot_notifier to platform-shutdown method.
@ 2010-01-19 21:22 Wim Van Sebroeck
  2010-01-19 22:48 ` Mike Frysinger
  0 siblings, 1 reply; 2+ messages in thread
From: Wim Van Sebroeck @ 2010-01-19 21:22 UTC (permalink / raw)
  To: Mike Frysinger, H Hartley Sweeten, Andrew Morton, Thierry Reding,
	uclinux-dist-devel, linux-kernel, Alan Cox

Hi All,

Can you give comments and test?

Thanks in advance,
Wim.

commit 31088dc041e929453f307f34a90dd8cecacf2fa8
Author: Wim Van Sebroeck <wim@iguana.be>
Date:   Sat Dec 26 19:13:00 2009 +0000

    [WATCHDOG] change reboot_notifier to platform-shutdown method.
    
    Platform device drivers can use the .shutdown method to handle soft
    shutdown's instead of reboot_notifier's.
    
    Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

diff --git a/drivers/watchdog/bfin_wdt.c b/drivers/watchdog/bfin_wdt.c
index 6ce2022..5a73d73 100644
--- a/drivers/watchdog/bfin_wdt.c
+++ b/drivers/watchdog/bfin_wdt.c
@@ -20,8 +20,6 @@
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/fs.h>
-#include <linux/notifier.h>
-#include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/uaccess.h>
@@ -308,26 +306,6 @@ static long bfin_wdt_ioctl(struct file *file,
 	}
 }
 
-/**
- *	bfin_wdt_notify_sys - Notifier Handler
- *	@this: notifier block
- *	@code: notifier event
- *	@unused: unused
- *
- *	Handles specific events, such as turning off the watchdog during a
- *	shutdown event.
- */
-static int bfin_wdt_notify_sys(struct notifier_block *this,
-					unsigned long code, void *unused)
-{
-	stampit();
-
-	if (code == SYS_DOWN || code == SYS_HALT)
-		bfin_wdt_stop();
-
-	return NOTIFY_DONE;
-}
-
 #ifdef CONFIG_PM
 static int state_before_suspend;
 
@@ -394,33 +372,21 @@ static const struct watchdog_info bfin_wdt_info = {
 		    WDIOF_MAGICCLOSE,
 };
 
-static struct notifier_block bfin_wdt_notifier = {
-	.notifier_call = bfin_wdt_notify_sys,
-};
-
 /**
  *	bfin_wdt_probe - Initialize module
  *
- *	Registers the misc device and notifier handler.  Actual device
+ *	Registers the misc device.  Actual device
  *	initialization is handled by bfin_wdt_open().
  */
 static int __devinit bfin_wdt_probe(struct platform_device *pdev)
 {
 	int ret;
 
-	ret = register_reboot_notifier(&bfin_wdt_notifier);
-	if (ret) {
-		pr_devinit(KERN_ERR PFX
-			"cannot register reboot notifier (err=%d)\n", ret);
-		return ret;
-	}
-
 	ret = misc_register(&bfin_wdt_miscdev);
 	if (ret) {
 		pr_devinit(KERN_ERR PFX
 			"cannot register miscdev on minor=%d (err=%d)\n",
 				WATCHDOG_MINOR, ret);
-		unregister_reboot_notifier(&bfin_wdt_notifier);
 		return ret;
 	}
 
@@ -433,21 +399,33 @@ static int __devinit bfin_wdt_probe(struct platform_device *pdev)
 /**
  *	bfin_wdt_remove - Initialize module
  *
- *	Unregisters the misc device and notifier handler.  Actual device
+ *	Unregisters the misc device.  Actual device
  *	deinitialization is handled by bfin_wdt_close().
  */
 static int __devexit bfin_wdt_remove(struct platform_device *pdev)
 {
 	misc_deregister(&bfin_wdt_miscdev);
-	unregister_reboot_notifier(&bfin_wdt_notifier);
 	return 0;
 }
 
+/**
+ *	bfin_wdt_shutdown - Soft Shutdown Handler
+ *
+ *	Handles the soft shutdown event.
+ */
+static void bfin_wdt_shutdown(struct platform_device *pdev)
+{
+	stampit();
+
+	bfin_wdt_stop();
+}
+
 static struct platform_device *bfin_wdt_device;
 
 static struct platform_driver bfin_wdt_driver = {
 	.probe     = bfin_wdt_probe,
 	.remove    = __devexit_p(bfin_wdt_remove),
+	.shutdown  = bfin_wdt_shutdown,
 	.suspend   = bfin_wdt_suspend,
 	.resume    = bfin_wdt_resume,
 	.driver    = {
diff --git a/drivers/watchdog/txx9wdt.c b/drivers/watchdog/txx9wdt.c
index 364cfee..bcfd572 100644
--- a/drivers/watchdog/txx9wdt.c
+++ b/drivers/watchdog/txx9wdt.c
@@ -13,7 +13,6 @@
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/fs.h>
-#include <linux/reboot.h>
 #include <linux/init.h>
 #include <linux/uaccess.h>
 #include <linux/platform_device.h>
@@ -167,14 +166,6 @@ static long txx9wdt_ioctl(struct file *file, unsigned int cmd,
 	}
 }
 
-static int txx9wdt_notify_sys(struct notifier_block *this, unsigned long code,
-	void *unused)
-{
-	if (code == SYS_DOWN || code == SYS_HALT)
-		txx9wdt_stop();
-	return NOTIFY_DONE;
-}
-
 static const struct file_operations txx9wdt_fops = {
 	.owner		=	THIS_MODULE,
 	.llseek		=	no_llseek,
@@ -190,10 +181,6 @@ static struct miscdevice txx9wdt_miscdev = {
 	.fops	=	&txx9wdt_fops,
 };
 
-static struct notifier_block txx9wdt_notifier = {
-	.notifier_call = txx9wdt_notify_sys,
-};
-
 static int __init txx9wdt_probe(struct platform_device *dev)
 {
 	struct resource *res;
@@ -222,13 +209,8 @@ static int __init txx9wdt_probe(struct platform_device *dev)
 	if (!txx9wdt_reg)
 		goto exit_busy;
 
-	ret = register_reboot_notifier(&txx9wdt_notifier);
-	if (ret)
-		goto exit;
-
 	ret = misc_register(&txx9wdt_miscdev);
 	if (ret) {
-		unregister_reboot_notifier(&txx9wdt_notifier);
 		goto exit;
 	}
 
@@ -250,14 +232,19 @@ exit:
 static int __exit txx9wdt_remove(struct platform_device *dev)
 {
 	misc_deregister(&txx9wdt_miscdev);
-	unregister_reboot_notifier(&txx9wdt_notifier);
 	clk_disable(txx9_imclk);
 	clk_put(txx9_imclk);
 	return 0;
 }
 
+static void txx9wdt_shutdown(struct platform_device *dev)
+{
+	txx9wdt_stop();
+}
+
 static struct platform_driver txx9wdt_driver = {
 	.remove = __exit_p(txx9wdt_remove),
+	.shutdown = txx9wdt_shutdown,
 	.driver = {
 		.name = "txx9wdt",
 		.owner = THIS_MODULE,

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

* Re: [RFC] [PATCH] change reboot_notifier to platform-shutdown method.
  2010-01-19 21:22 [RFC] [PATCH] change reboot_notifier to platform-shutdown method Wim Van Sebroeck
@ 2010-01-19 22:48 ` Mike Frysinger
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2010-01-19 22:48 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: H Hartley Sweeten, Andrew Morton, Thierry Reding,
	uclinux-dist-devel, linux-kernel, Alan Cox

On Tue, Jan 19, 2010 at 16:22, Wim Van Sebroeck wrote:
>    [WATCHDOG] change reboot_notifier to platform-shutdown method.
>
>    Platform device drivers can use the .shutdown method to handle soft
>    shutdown's instead of reboot_notifier's.
>
> --- a/drivers/watchdog/bfin_wdt.c
> +++ b/drivers/watchdog/bfin_wdt.c

seems to work fine on my Blackfin boards:
root:/> dmesg -n 8
root:/> reboot
bfin_wdt_write:222: here i am
bfin_wdt_keepalive:88: here i am
bfin_wdt_release:196: here i am
bfin_wdt_stop:100: here i am
bfin_wdt_shutdown:418: here i am
bfin_wdt_stop:100: here i am
Restarting system.�

and i like things that shrink code:
-   1792     176      20    1988     7c4 drivers/watchdog/bfin_wdt.o
+   1676     164      20    1860     744 drivers/watchdog/bfin_wdt.o

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-mike

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

end of thread, other threads:[~2010-01-19 22:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-19 21:22 [RFC] [PATCH] change reboot_notifier to platform-shutdown method Wim Van Sebroeck
2010-01-19 22:48 ` Mike Frysinger

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.