[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>

+21 -56
+15 -37
drivers/watchdog/bfin_wdt.c
··· 19 19 #include <linux/miscdevice.h> 20 20 #include <linux/watchdog.h> 21 21 #include <linux/fs.h> 22 - #include <linux/notifier.h> 23 - #include <linux/reboot.h> 24 22 #include <linux/init.h> 25 23 #include <linux/interrupt.h> 26 24 #include <linux/uaccess.h> ··· 307 309 } 308 310 } 309 311 310 - /** 311 - * bfin_wdt_notify_sys - Notifier Handler 312 - * @this: notifier block 313 - * @code: notifier event 314 - * @unused: unused 315 - * 316 - * Handles specific events, such as turning off the watchdog during a 317 - * shutdown event. 318 - */ 319 - static int bfin_wdt_notify_sys(struct notifier_block *this, 320 - unsigned long code, void *unused) 321 - { 322 - stampit(); 323 - 324 - if (code == SYS_DOWN || code == SYS_HALT) 325 - bfin_wdt_stop(); 326 - 327 - return NOTIFY_DONE; 328 - } 329 - 330 312 #ifdef CONFIG_PM 331 313 static int state_before_suspend; 332 314 ··· 373 395 WDIOF_MAGICCLOSE, 374 396 }; 375 397 376 - static struct notifier_block bfin_wdt_notifier = { 377 - .notifier_call = bfin_wdt_notify_sys, 378 - }; 379 - 380 398 /** 381 399 * bfin_wdt_probe - Initialize module 382 400 * 383 - * Registers the misc device and notifier handler. Actual device 401 + * Registers the misc device. Actual device 384 402 * initialization is handled by bfin_wdt_open(). 385 403 */ 386 404 static int __devinit bfin_wdt_probe(struct platform_device *pdev) 387 405 { 388 406 int ret; 389 407 390 - ret = register_reboot_notifier(&bfin_wdt_notifier); 391 - if (ret) { 392 - pr_devinit(KERN_ERR PFX 393 - "cannot register reboot notifier (err=%d)\n", ret); 394 - return ret; 395 - } 396 - 397 408 ret = misc_register(&bfin_wdt_miscdev); 398 409 if (ret) { 399 410 pr_devinit(KERN_ERR PFX 400 411 "cannot register miscdev on minor=%d (err=%d)\n", 401 412 WATCHDOG_MINOR, ret); 402 - unregister_reboot_notifier(&bfin_wdt_notifier); 403 413 return ret; 404 414 } 405 415 ··· 400 434 /** 401 435 * bfin_wdt_remove - Initialize module 402 436 * 403 - * Unregisters the misc device and notifier handler. Actual device 437 + * Unregisters the misc device. Actual device 404 438 * deinitialization is handled by bfin_wdt_close(). 405 439 */ 406 440 static int __devexit bfin_wdt_remove(struct platform_device *pdev) 407 441 { 408 442 misc_deregister(&bfin_wdt_miscdev); 409 - unregister_reboot_notifier(&bfin_wdt_notifier); 410 443 return 0; 444 + } 445 + 446 + /** 447 + * bfin_wdt_shutdown - Soft Shutdown Handler 448 + * 449 + * Handles the soft shutdown event. 450 + */ 451 + static void bfin_wdt_shutdown(struct platform_device *pdev) 452 + { 453 + stampit(); 454 + 455 + bfin_wdt_stop(); 411 456 } 412 457 413 458 static struct platform_device *bfin_wdt_device; ··· 426 449 static struct platform_driver bfin_wdt_driver = { 427 450 .probe = bfin_wdt_probe, 428 451 .remove = __devexit_p(bfin_wdt_remove), 452 + .shutdown = bfin_wdt_shutdown, 429 453 .suspend = bfin_wdt_suspend, 430 454 .resume = bfin_wdt_resume, 431 455 .driver = {
+6 -19
drivers/watchdog/txx9wdt.c
··· 13 13 #include <linux/miscdevice.h> 14 14 #include <linux/watchdog.h> 15 15 #include <linux/fs.h> 16 - #include <linux/reboot.h> 17 16 #include <linux/init.h> 18 17 #include <linux/uaccess.h> 19 18 #include <linux/platform_device.h> ··· 165 166 } 166 167 } 167 168 168 - static int txx9wdt_notify_sys(struct notifier_block *this, unsigned long code, 169 - void *unused) 170 - { 171 - if (code == SYS_DOWN || code == SYS_HALT) 172 - txx9wdt_stop(); 173 - return NOTIFY_DONE; 174 - } 175 - 176 169 static const struct file_operations txx9wdt_fops = { 177 170 .owner = THIS_MODULE, 178 171 .llseek = no_llseek, ··· 178 187 .minor = WATCHDOG_MINOR, 179 188 .name = "watchdog", 180 189 .fops = &txx9wdt_fops, 181 - }; 182 - 183 - static struct notifier_block txx9wdt_notifier = { 184 - .notifier_call = txx9wdt_notify_sys, 185 190 }; 186 191 187 192 static int __init txx9wdt_probe(struct platform_device *dev) ··· 208 221 if (!txx9wdt_reg) 209 222 goto exit_busy; 210 223 211 - ret = register_reboot_notifier(&txx9wdt_notifier); 212 - if (ret) 213 - goto exit; 214 - 215 224 ret = misc_register(&txx9wdt_miscdev); 216 225 if (ret) { 217 - unregister_reboot_notifier(&txx9wdt_notifier); 218 226 goto exit; 219 227 } 220 228 ··· 231 249 static int __exit txx9wdt_remove(struct platform_device *dev) 232 250 { 233 251 misc_deregister(&txx9wdt_miscdev); 234 - unregister_reboot_notifier(&txx9wdt_notifier); 235 252 clk_disable(txx9_imclk); 236 253 clk_put(txx9_imclk); 237 254 return 0; 238 255 } 239 256 257 + static void txx9wdt_shutdown(struct platform_device *dev) 258 + { 259 + txx9wdt_stop(); 260 + } 261 + 240 262 static struct platform_driver txx9wdt_driver = { 241 263 .remove = __exit_p(txx9wdt_remove), 264 + .shutdown = txx9wdt_shutdown, 242 265 .driver = { 243 266 .name = "txx9wdt", 244 267 .owner = THIS_MODULE,