Commit 168b5251adddb1554926cfb94f79a8a28bc6ebe5
1 parent
42747d712d
[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>
Showing 2 changed files with 21 additions and 56 deletions Side-by-side Diff
drivers/watchdog/bfin_wdt.c
... | ... | @@ -19,8 +19,6 @@ |
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> |
... | ... | @@ -309,26 +307,6 @@ |
309 | 307 | } |
310 | 308 | } |
311 | 309 | |
312 | -/** | |
313 | - * bfin_wdt_notify_sys - Notifier Handler | |
314 | - * @this: notifier block | |
315 | - * @code: notifier event | |
316 | - * @unused: unused | |
317 | - * | |
318 | - * Handles specific events, such as turning off the watchdog during a | |
319 | - * shutdown event. | |
320 | - */ | |
321 | -static int bfin_wdt_notify_sys(struct notifier_block *this, | |
322 | - unsigned long code, void *unused) | |
323 | -{ | |
324 | - stampit(); | |
325 | - | |
326 | - if (code == SYS_DOWN || code == SYS_HALT) | |
327 | - bfin_wdt_stop(); | |
328 | - | |
329 | - return NOTIFY_DONE; | |
330 | -} | |
331 | - | |
332 | 310 | #ifdef CONFIG_PM |
333 | 311 | static int state_before_suspend; |
334 | 312 | |
335 | 313 | |
336 | 314 | |
337 | 315 | |
... | ... | @@ -395,33 +373,21 @@ |
395 | 373 | WDIOF_MAGICCLOSE, |
396 | 374 | }; |
397 | 375 | |
398 | -static struct notifier_block bfin_wdt_notifier = { | |
399 | - .notifier_call = bfin_wdt_notify_sys, | |
400 | -}; | |
401 | - | |
402 | 376 | /** |
403 | 377 | * bfin_wdt_probe - Initialize module |
404 | 378 | * |
405 | - * Registers the misc device and notifier handler. Actual device | |
379 | + * Registers the misc device. Actual device | |
406 | 380 | * initialization is handled by bfin_wdt_open(). |
407 | 381 | */ |
408 | 382 | static int __devinit bfin_wdt_probe(struct platform_device *pdev) |
409 | 383 | { |
410 | 384 | int ret; |
411 | 385 | |
412 | - ret = register_reboot_notifier(&bfin_wdt_notifier); | |
413 | - if (ret) { | |
414 | - pr_devinit(KERN_ERR PFX | |
415 | - "cannot register reboot notifier (err=%d)\n", ret); | |
416 | - return ret; | |
417 | - } | |
418 | - | |
419 | 386 | ret = misc_register(&bfin_wdt_miscdev); |
420 | 387 | if (ret) { |
421 | 388 | pr_devinit(KERN_ERR PFX |
422 | 389 | "cannot register miscdev on minor=%d (err=%d)\n", |
423 | 390 | WATCHDOG_MINOR, ret); |
424 | - unregister_reboot_notifier(&bfin_wdt_notifier); | |
425 | 391 | return ret; |
426 | 392 | } |
427 | 393 | |
428 | 394 | |
429 | 395 | |
430 | 396 | |
... | ... | @@ -434,21 +400,33 @@ |
434 | 400 | /** |
435 | 401 | * bfin_wdt_remove - Initialize module |
436 | 402 | * |
437 | - * Unregisters the misc device and notifier handler. Actual device | |
403 | + * Unregisters the misc device. Actual device | |
438 | 404 | * deinitialization is handled by bfin_wdt_close(). |
439 | 405 | */ |
440 | 406 | static int __devexit bfin_wdt_remove(struct platform_device *pdev) |
441 | 407 | { |
442 | 408 | misc_deregister(&bfin_wdt_miscdev); |
443 | - unregister_reboot_notifier(&bfin_wdt_notifier); | |
444 | 409 | return 0; |
445 | 410 | } |
446 | 411 | |
412 | +/** | |
413 | + * bfin_wdt_shutdown - Soft Shutdown Handler | |
414 | + * | |
415 | + * Handles the soft shutdown event. | |
416 | + */ | |
417 | +static void bfin_wdt_shutdown(struct platform_device *pdev) | |
418 | +{ | |
419 | + stampit(); | |
420 | + | |
421 | + bfin_wdt_stop(); | |
422 | +} | |
423 | + | |
447 | 424 | static struct platform_device *bfin_wdt_device; |
448 | 425 | |
449 | 426 | static struct platform_driver bfin_wdt_driver = { |
450 | 427 | .probe = bfin_wdt_probe, |
451 | 428 | .remove = __devexit_p(bfin_wdt_remove), |
429 | + .shutdown = bfin_wdt_shutdown, | |
452 | 430 | .suspend = bfin_wdt_suspend, |
453 | 431 | .resume = bfin_wdt_resume, |
454 | 432 | .driver = { |
drivers/watchdog/txx9wdt.c
... | ... | @@ -13,7 +13,6 @@ |
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> |
... | ... | @@ -166,14 +165,6 @@ |
166 | 165 | } |
167 | 166 | } |
168 | 167 | |
169 | -static int txx9wdt_notify_sys(struct notifier_block *this, unsigned long code, | |
170 | - void *unused) | |
171 | -{ | |
172 | - if (code == SYS_DOWN || code == SYS_HALT) | |
173 | - txx9wdt_stop(); | |
174 | - return NOTIFY_DONE; | |
175 | -} | |
176 | - | |
177 | 168 | static const struct file_operations txx9wdt_fops = { |
178 | 169 | .owner = THIS_MODULE, |
179 | 170 | .llseek = no_llseek, |
... | ... | @@ -189,10 +180,6 @@ |
189 | 180 | .fops = &txx9wdt_fops, |
190 | 181 | }; |
191 | 182 | |
192 | -static struct notifier_block txx9wdt_notifier = { | |
193 | - .notifier_call = txx9wdt_notify_sys, | |
194 | -}; | |
195 | - | |
196 | 183 | static int __init txx9wdt_probe(struct platform_device *dev) |
197 | 184 | { |
198 | 185 | struct resource *res; |
199 | 186 | |
... | ... | @@ -221,13 +208,8 @@ |
221 | 208 | if (!txx9wdt_reg) |
222 | 209 | goto exit_busy; |
223 | 210 | |
224 | - ret = register_reboot_notifier(&txx9wdt_notifier); | |
225 | - if (ret) | |
226 | - goto exit; | |
227 | - | |
228 | 211 | ret = misc_register(&txx9wdt_miscdev); |
229 | 212 | if (ret) { |
230 | - unregister_reboot_notifier(&txx9wdt_notifier); | |
231 | 213 | goto exit; |
232 | 214 | } |
233 | 215 | |
234 | 216 | |
235 | 217 | |
... | ... | @@ -249,14 +231,19 @@ |
249 | 231 | static int __exit txx9wdt_remove(struct platform_device *dev) |
250 | 232 | { |
251 | 233 | misc_deregister(&txx9wdt_miscdev); |
252 | - unregister_reboot_notifier(&txx9wdt_notifier); | |
253 | 234 | clk_disable(txx9_imclk); |
254 | 235 | clk_put(txx9_imclk); |
255 | 236 | return 0; |
256 | 237 | } |
257 | 238 | |
239 | +static void txx9wdt_shutdown(struct platform_device *dev) | |
240 | +{ | |
241 | + txx9wdt_stop(); | |
242 | +} | |
243 | + | |
258 | 244 | static struct platform_driver txx9wdt_driver = { |
259 | 245 | .remove = __exit_p(txx9wdt_remove), |
246 | + .shutdown = txx9wdt_shutdown, | |
260 | 247 | .driver = { |
261 | 248 | .name = "txx9wdt", |
262 | 249 | .owner = THIS_MODULE, |