Commit 88266917b518e2ca954d85983470592aaaf82993

Authored by Linus Torvalds

Merge git://www.linux-watchdog.org/linux-watchdog

* git://www.linux-watchdog.org/linux-watchdog:
  watchdog: omap_wdt.c: fix the WDIOC_GETBOOTSTATUS ioctl if not implemented.
  watchdog: new driver for VIA chipsets
  watchdog: ath79_wdt: flush register writes
  drivers/watchdog/lantiq_wdt.c: drop iounmap for devm_ allocated data
  watchdog: documentation: describe nowayout in coversion-guide
  watchdog: documentation: update index file
  watchdog: Convert wm831x driver to devm_kzalloc()
  watchdog: add nowayout helpers to Watchdog Timer Driver Kernel API
  watchdog: convert drivers/watchdog/* to use module_platform_driver()
  watchdog: Use DEFINE_SPINLOCK() for static spinlocks
  watchdog: Convert Wolfson drivers to module_platform_driver

Showing 39 changed files Side-by-side Diff

Documentation/watchdog/00-INDEX
1 1 00-INDEX
2 2 - this file.
  3 +convert_drivers_to_kernel_api.txt
  4 + - how-to for converting old watchdog drivers to the new kernel API.
3 5 hpwdt.txt
4 6 - information on the HP iLO2 NMI watchdog
5 7 pcwd-watchdog.txt
Documentation/watchdog/convert_drivers_to_kernel_api.txt
... ... @@ -163,6 +163,25 @@
163 163 +};
164 164  
165 165  
  166 +Handle the 'nowayout' feature
  167 +-----------------------------
  168 +
  169 +A few drivers use nowayout statically, i.e. there is no module parameter for it
  170 +and only CONFIG_WATCHDOG_NOWAYOUT determines if the feature is going to be
  171 +used. This needs to be converted by initializing the status variable of the
  172 +watchdog_device like this:
  173 +
  174 + .status = WATCHDOG_NOWAYOUT_INIT_STATUS,
  175 +
  176 +Most drivers, however, also allow runtime configuration of nowayout, usually
  177 +by adding a module parameter. The conversion for this would be something like:
  178 +
  179 + watchdog_set_nowayout(&s3c2410_wdd, nowayout);
  180 +
  181 +The module parameter itself needs to stay, everything else related to nowayout
  182 +can go, though. This will likely be some code in open(), close() or write().
  183 +
  184 +
166 185 Register the watchdog device
167 186 ----------------------------
168 187  
Documentation/watchdog/watchdog-kernel-api.txt
1 1 The Linux WatchDog Timer Driver Core kernel API.
2 2 ===============================================
3   -Last reviewed: 22-Jul-2011
  3 +Last reviewed: 29-Nov-2011
4 4  
5 5 Wim Van Sebroeck <wim@iguana.be>
6 6  
... ... @@ -141,6 +141,14 @@
141 141 (This bit should only be used by the WatchDog Timer Driver Core).
142 142 * WDOG_NO_WAY_OUT: this bit stores the nowayout setting for the watchdog.
143 143 If this bit is set then the watchdog timer will not be able to stop.
  144 +
  145 + To set the WDOG_NO_WAY_OUT status bit (before registering your watchdog
  146 + timer device) you can either:
  147 + * set it statically in your watchdog_device struct with
  148 + .status = WATCHDOG_NOWAYOUT_INIT_STATUS,
  149 + (this will set the value the same as CONFIG_WATCHDOG_NOWAYOUT) or
  150 + * use the following helper function:
  151 + static inline void watchdog_set_nowayout(struct watchdog_device *wdd, int nowayout)
144 152  
145 153 Note: The WatchDog Timer Driver Core supports the magic close feature and
146 154 the nowayout feature. To use the magic close feature you must set the
drivers/watchdog/Kconfig
... ... @@ -772,6 +772,19 @@
772 772  
773 773 Most people will say N.
774 774  
  775 +config VIA_WDT
  776 + tristate "VIA Watchdog Timer"
  777 + depends on X86
  778 + select WATCHDOG_CORE
  779 + ---help---
  780 + This is the driver for the hardware watchdog timer on VIA
  781 + southbridge chipset CX700, VX800/VX820 or VX855/VX875.
  782 +
  783 + To compile this driver as a module, choose M here; the module
  784 + will be called via_wdt.
  785 +
  786 + Most people will say N.
  787 +
775 788 config W83627HF_WDT
776 789 tristate "W83627HF/W83627DHG Watchdog Timer"
777 790 depends on X86
drivers/watchdog/Makefile
... ... @@ -99,6 +99,7 @@
99 99 obj-$(CONFIG_CPU5_WDT) += cpu5wdt.o
100 100 obj-$(CONFIG_SMSC_SCH311X_WDT) += sch311x_wdt.o
101 101 obj-$(CONFIG_SMSC37B787_WDT) += smsc37b787_wdt.o
  102 +obj-$(CONFIG_VIA_WDT) += via_wdt.o
102 103 obj-$(CONFIG_W83627HF_WDT) += w83627hf_wdt.o
103 104 obj-$(CONFIG_W83697HF_WDT) += w83697hf_wdt.o
104 105 obj-$(CONFIG_W83697UG_WDT) += w83697ug_wdt.o
drivers/watchdog/ar7_wdt.c
... ... @@ -70,8 +70,8 @@
70 70 };
71 71  
72 72 static unsigned long wdt_is_open;
73   -static spinlock_t wdt_lock;
74 73 static unsigned expect_close;
  74 +static DEFINE_SPINLOCK(wdt_lock);
75 75  
76 76 /* XXX currently fixed, allows max margin ~68.72 secs */
77 77 #define prescale_value 0xffff
... ... @@ -280,8 +280,6 @@
280 280 {
281 281 int rc;
282 282  
283   - spin_lock_init(&wdt_lock);
284   -
285 283 ar7_regs_wdt =
286 284 platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs");
287 285 if (!ar7_regs_wdt) {
... ... @@ -355,16 +353,5 @@
355 353 },
356 354 };
357 355  
358   -static int __init ar7_wdt_init(void)
359   -{
360   - return platform_driver_register(&ar7_wdt_driver);
361   -}
362   -
363   -static void __exit ar7_wdt_cleanup(void)
364   -{
365   - platform_driver_unregister(&ar7_wdt_driver);
366   -}
367   -
368   -module_init(ar7_wdt_init);
369   -module_exit(ar7_wdt_cleanup);
  356 +module_platform_driver(ar7_wdt_driver);
drivers/watchdog/ath79_wdt.c
... ... @@ -68,17 +68,23 @@
68 68 static inline void ath79_wdt_keepalive(void)
69 69 {
70 70 ath79_reset_wr(AR71XX_RESET_REG_WDOG, wdt_freq * timeout);
  71 + /* flush write */
  72 + ath79_reset_rr(AR71XX_RESET_REG_WDOG);
71 73 }
72 74  
73 75 static inline void ath79_wdt_enable(void)
74 76 {
75 77 ath79_wdt_keepalive();
76 78 ath79_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_FCR);
  79 + /* flush write */
  80 + ath79_reset_rr(AR71XX_RESET_REG_WDOG_CTRL);
77 81 }
78 82  
79 83 static inline void ath79_wdt_disable(void)
80 84 {
81 85 ath79_reset_wr(AR71XX_RESET_REG_WDOG_CTRL, WDOG_CTRL_ACTION_NONE);
  86 + /* flush write */
  87 + ath79_reset_rr(AR71XX_RESET_REG_WDOG_CTRL);
82 88 }
83 89  
84 90 static int ath79_wdt_set_timeout(int val)
drivers/watchdog/bcm63xx_wdt.c
... ... @@ -311,18 +311,7 @@
311 311 }
312 312 };
313 313  
314   -static int __init bcm63xx_wdt_init(void)
315   -{
316   - return platform_driver_register(&bcm63xx_wdt);
317   -}
318   -
319   -static void __exit bcm63xx_wdt_exit(void)
320   -{
321   - platform_driver_unregister(&bcm63xx_wdt);
322   -}
323   -
324   -module_init(bcm63xx_wdt_init);
325   -module_exit(bcm63xx_wdt_exit);
  314 +module_platform_driver(bcm63xx_wdt);
326 315  
327 316 MODULE_AUTHOR("Miguel Gaio <miguel.gaio@efixo.com>");
328 317 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
drivers/watchdog/cpu5wdt.c
... ... @@ -39,7 +39,7 @@
39 39 static int verbose;
40 40 static int port = 0x91;
41 41 static int ticks = 10000;
42   -static spinlock_t cpu5wdt_lock;
  42 +static DEFINE_SPINLOCK(cpu5wdt_lock);
43 43  
44 44 #define PFX "cpu5wdt: "
45 45  
... ... @@ -223,7 +223,6 @@
223 223 "port=0x%x, verbose=%i\n", port, verbose);
224 224  
225 225 init_completion(&cpu5wdt_device.stop);
226   - spin_lock_init(&cpu5wdt_lock);
227 226 cpu5wdt_device.queue = 0;
228 227 setup_timer(&cpu5wdt_device.timer, cpu5wdt_trigger, 0);
229 228 cpu5wdt_device.default_ticks = ticks;
drivers/watchdog/cpwd.c
... ... @@ -687,16 +687,5 @@
687 687 .remove = __devexit_p(cpwd_remove),
688 688 };
689 689  
690   -static int __init cpwd_init(void)
691   -{
692   - return platform_driver_register(&cpwd_driver);
693   -}
694   -
695   -static void __exit cpwd_exit(void)
696   -{
697   - platform_driver_unregister(&cpwd_driver);
698   -}
699   -
700   -module_init(cpwd_init);
701   -module_exit(cpwd_exit);
  690 +module_platform_driver(cpwd_driver);
drivers/watchdog/davinci_wdt.c
... ... @@ -271,18 +271,7 @@
271 271 .remove = __devexit_p(davinci_wdt_remove),
272 272 };
273 273  
274   -static int __init davinci_wdt_init(void)
275   -{
276   - return platform_driver_register(&platform_wdt_driver);
277   -}
278   -
279   -static void __exit davinci_wdt_exit(void)
280   -{
281   - platform_driver_unregister(&platform_wdt_driver);
282   -}
283   -
284   -module_init(davinci_wdt_init);
285   -module_exit(davinci_wdt_exit);
  274 +module_platform_driver(platform_wdt_driver);
286 275  
287 276 MODULE_AUTHOR("Texas Instruments");
288 277 MODULE_DESCRIPTION("DaVinci Watchdog Driver");
drivers/watchdog/dw_wdt.c
... ... @@ -358,17 +358,7 @@
358 358 },
359 359 };
360 360  
361   -static int __init dw_wdt_watchdog_init(void)
362   -{
363   - return platform_driver_register(&dw_wdt_driver);
364   -}
365   -module_init(dw_wdt_watchdog_init);
366   -
367   -static void __exit dw_wdt_watchdog_exit(void)
368   -{
369   - platform_driver_unregister(&dw_wdt_driver);
370   -}
371   -module_exit(dw_wdt_watchdog_exit);
  361 +module_platform_driver(dw_wdt_driver);
372 362  
373 363 MODULE_AUTHOR("Jamie Iles");
374 364 MODULE_DESCRIPTION("Synopsys DesignWare Watchdog Driver");
drivers/watchdog/eurotechwdt.c
... ... @@ -64,7 +64,7 @@
64 64 static unsigned long eurwdt_is_open;
65 65 static int eurwdt_timeout;
66 66 static char eur_expect_close;
67   -static spinlock_t eurwdt_lock;
  67 +static DEFINE_SPINLOCK(eurwdt_lock);
68 68  
69 69 /*
70 70 * You must set these - there is no sane way to probe for this board.
... ... @@ -445,8 +445,6 @@
445 445 "eurwdt: can't register reboot notifier (err=%d)\n", ret);
446 446 goto outreg;
447 447 }
448   -
449   - spin_lock_init(&eurwdt_lock);
450 448  
451 449 ret = misc_register(&eurwdt_miscdev);
452 450 if (ret) {
drivers/watchdog/ibmasr.c
... ... @@ -68,7 +68,7 @@
68 68 static unsigned int asr_type, asr_base, asr_length;
69 69 static unsigned int asr_read_addr, asr_write_addr;
70 70 static unsigned char asr_toggle_mask, asr_disable_mask;
71   -static spinlock_t asr_lock;
  71 +static DEFINE_SPINLOCK(asr_lock);
72 72  
73 73 static void __asr_toggle(void)
74 74 {
... ... @@ -385,8 +385,6 @@
385 385  
386 386 if (!asr_type)
387 387 return -ENODEV;
388   -
389   - spin_lock_init(&asr_lock);
390 388  
391 389 rc = asr_get_base_address();
392 390 if (rc)
drivers/watchdog/indydog.c
... ... @@ -28,7 +28,7 @@
28 28  
29 29 #define PFX "indydog: "
30 30 static unsigned long indydog_alive;
31   -static spinlock_t indydog_lock;
  31 +static DEFINE_SPINLOCK(indydog_lock);
32 32  
33 33 #define WATCHDOG_TIMEOUT 30 /* 30 sec default timeout */
34 34  
... ... @@ -184,8 +184,6 @@
184 184 static int __init watchdog_init(void)
185 185 {
186 186 int ret;
187   -
188   - spin_lock_init(&indydog_lock);
189 187  
190 188 ret = register_reboot_notifier(&indydog_notifier);
191 189 if (ret) {
drivers/watchdog/iop_wdt.c
... ... @@ -37,7 +37,7 @@
37 37 static int nowayout = WATCHDOG_NOWAYOUT;
38 38 static unsigned long wdt_status;
39 39 static unsigned long boot_status;
40   -static spinlock_t wdt_lock;
  40 +static DEFINE_SPINLOCK(wdt_lock);
41 41  
42 42 #define WDT_IN_USE 0
43 43 #define WDT_OK_TO_CLOSE 1
... ... @@ -225,9 +225,6 @@
225 225 static int __init iop_wdt_init(void)
226 226 {
227 227 int ret;
228   -
229   - spin_lock_init(&wdt_lock);
230   -
231 228  
232 229 /* check if the reset was caused by the watchdog timer */
233 230 boot_status = (read_rcsr() & IOP_RCSR_WDT) ? WDIOF_CARDRESET : 0;
drivers/watchdog/ixp2000_wdt.c
... ... @@ -32,7 +32,7 @@
32 32 static int nowayout = WATCHDOG_NOWAYOUT;
33 33 static unsigned int heartbeat = 60; /* (secs) Default is 1 minute */
34 34 static unsigned long wdt_status;
35   -static spinlock_t wdt_lock;
  35 +static DEFINE_SPINLOCK(wdt_lock);
36 36  
37 37 #define WDT_IN_USE 0
38 38 #define WDT_OK_TO_CLOSE 1
... ... @@ -189,7 +189,6 @@
189 189 return -EIO;
190 190 }
191 191 wdt_tick_rate = (*IXP2000_T1_CLD * HZ) / 256;
192   - spin_lock_init(&wdt_lock);
193 192 return misc_register(&ixp2000_wdt_miscdev);
194 193 }
195 194  
drivers/watchdog/ixp4xx_wdt.c
... ... @@ -181,7 +181,6 @@
181 181  
182 182 return -ENODEV;
183 183 }
184   - spin_lock_init(&wdt_lock);
185 184 boot_status = (*IXP4XX_OSST & IXP4XX_OSST_TIMER_WARM_RESET) ?
186 185 WDIOF_CARDRESET : 0;
187 186 ret = misc_register(&ixp4xx_wdt_miscdev);
drivers/watchdog/jz4740_wdt.c
... ... @@ -295,18 +295,7 @@
295 295 },
296 296 };
297 297  
298   -
299   -static int __init jz4740_wdt_init(void)
300   -{
301   - return platform_driver_register(&jz4740_wdt_driver);
302   -}
303   -module_init(jz4740_wdt_init);
304   -
305   -static void __exit jz4740_wdt_exit(void)
306   -{
307   - platform_driver_unregister(&jz4740_wdt_driver);
308   -}
309   -module_exit(jz4740_wdt_exit);
  298 +module_platform_driver(jz4740_wdt_driver);
310 299  
311 300 MODULE_AUTHOR("Paul Cercueil <paul@crapouillou.net>");
312 301 MODULE_DESCRIPTION("jz4740 Watchdog Driver");
drivers/watchdog/ks8695_wdt.c
... ... @@ -42,7 +42,7 @@
42 42  
43 43  
44 44 static unsigned long ks8695wdt_busy;
45   -static spinlock_t ks8695_lock;
  45 +static DEFINE_SPINLOCK(ks8695_lock);
46 46  
47 47 /* ......................................................................... */
48 48  
... ... @@ -288,7 +288,6 @@
288 288  
289 289 static int __init ks8695_wdt_init(void)
290 290 {
291   - spin_lock_init(&ks8695_lock);
292 291 /* Check that the heartbeat value is within range;
293 292 if not reset to the default */
294 293 if (ks8695_wdt_settimeout(wdt_time)) {
drivers/watchdog/lantiq_wdt.c
... ... @@ -222,9 +222,6 @@
222 222 {
223 223 misc_deregister(&ltq_wdt_miscdev);
224 224  
225   - if (ltq_wdt_membase)
226   - iounmap(ltq_wdt_membase);
227   -
228 225 return 0;
229 226 }
230 227  
drivers/watchdog/max63xx_wdt.c
... ... @@ -364,18 +364,7 @@
364 364 },
365 365 };
366 366  
367   -static int __init max63xx_wdt_init(void)
368   -{
369   - return platform_driver_register(&max63xx_wdt_driver);
370   -}
371   -
372   -static void __exit max63xx_wdt_exit(void)
373   -{
374   - platform_driver_unregister(&max63xx_wdt_driver);
375   -}
376   -
377   -module_init(max63xx_wdt_init);
378   -module_exit(max63xx_wdt_exit);
  367 +module_platform_driver(max63xx_wdt_driver);
379 368  
380 369 MODULE_AUTHOR("Marc Zyngier <maz@misterjones.org>");
381 370 MODULE_DESCRIPTION("max63xx Watchdog Driver");
drivers/watchdog/mtx-1_wdt.c
... ... @@ -253,18 +253,7 @@
253 253 .driver.owner = THIS_MODULE,
254 254 };
255 255  
256   -static int __init mtx1_wdt_init(void)
257   -{
258   - return platform_driver_register(&mtx1_wdt_driver);
259   -}
260   -
261   -static void __exit mtx1_wdt_exit(void)
262   -{
263   - platform_driver_unregister(&mtx1_wdt_driver);
264   -}
265   -
266   -module_init(mtx1_wdt_init);
267   -module_exit(mtx1_wdt_exit);
  256 +module_platform_driver(mtx1_wdt_driver);
268 257  
269 258 MODULE_AUTHOR("Michael Stickel, Florian Fainelli");
270 259 MODULE_DESCRIPTION("Driver for the MTX-1 watchdog");
drivers/watchdog/nuc900_wdt.c
... ... @@ -334,18 +334,7 @@
334 334 },
335 335 };
336 336  
337   -static int __init nuc900_wdt_init(void)
338   -{
339   - return platform_driver_register(&nuc900wdt_driver);
340   -}
341   -
342   -static void __exit nuc900_wdt_exit(void)
343   -{
344   - platform_driver_unregister(&nuc900wdt_driver);
345   -}
346   -
347   -module_init(nuc900_wdt_init);
348   -module_exit(nuc900_wdt_exit);
  337 +module_platform_driver(nuc900wdt_driver);
349 338  
350 339 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
351 340 MODULE_DESCRIPTION("Watchdog driver for NUC900");
drivers/watchdog/of_xilinx_wdt.c
... ... @@ -414,18 +414,7 @@
414 414 },
415 415 };
416 416  
417   -static int __init xwdt_init(void)
418   -{
419   - return platform_driver_register(&xwdt_driver);
420   -}
421   -
422   -static void __exit xwdt_exit(void)
423   -{
424   - platform_driver_unregister(&xwdt_driver);
425   -}
426   -
427   -module_init(xwdt_init);
428   -module_exit(xwdt_exit);
  417 +module_platform_driver(xwdt_driver);
429 418  
430 419 MODULE_AUTHOR("Alejandro Cabrera <aldaya@gmail.com>");
431 420 MODULE_DESCRIPTION("Xilinx Watchdog driver");
drivers/watchdog/omap_wdt.c
... ... @@ -55,7 +55,7 @@
55 55 MODULE_PARM_DESC(timer_margin, "initial watchdog timeout (in seconds)");
56 56  
57 57 static unsigned int wdt_trgr_pattern = 0x1234;
58   -static spinlock_t wdt_lock;
  58 +static DEFINE_SPINLOCK(wdt_lock);
59 59  
60 60 struct omap_wdt_dev {
61 61 void __iomem *base; /* physical */
... ... @@ -232,6 +232,7 @@
232 232 if (cpu_is_omap24xx())
233 233 return put_user(omap_prcm_get_reset_sources(),
234 234 (int __user *)arg);
  235 + return put_user(0, (int __user *)arg);
235 236 case WDIOC_KEEPALIVE:
236 237 pm_runtime_get_sync(wdev->dev);
237 238 spin_lock(&wdt_lock);
... ... @@ -437,19 +438,7 @@
437 438 },
438 439 };
439 440  
440   -static int __init omap_wdt_init(void)
441   -{
442   - spin_lock_init(&wdt_lock);
443   - return platform_driver_register(&omap_wdt_driver);
444   -}
445   -
446   -static void __exit omap_wdt_exit(void)
447   -{
448   - platform_driver_unregister(&omap_wdt_driver);
449   -}
450   -
451   -module_init(omap_wdt_init);
452   -module_exit(omap_wdt_exit);
  441 +module_platform_driver(omap_wdt_driver);
453 442  
454 443 MODULE_AUTHOR("George G. Davis");
455 444 MODULE_LICENSE("GPL");
drivers/watchdog/orion_wdt.c
... ... @@ -41,7 +41,7 @@
41 41 static unsigned int wdt_max_duration; /* (seconds) */
42 42 static unsigned int wdt_tclk;
43 43 static unsigned long wdt_status;
44   -static spinlock_t wdt_lock;
  44 +static DEFINE_SPINLOCK(wdt_lock);
45 45  
46 46 static void orion_wdt_ping(void)
47 47 {
... ... @@ -294,19 +294,7 @@
294 294 },
295 295 };
296 296  
297   -static int __init orion_wdt_init(void)
298   -{
299   - spin_lock_init(&wdt_lock);
300   - return platform_driver_register(&orion_wdt_driver);
301   -}
302   -
303   -static void __exit orion_wdt_exit(void)
304   -{
305   - platform_driver_unregister(&orion_wdt_driver);
306   -}
307   -
308   -module_init(orion_wdt_init);
309   -module_exit(orion_wdt_exit);
  297 +module_platform_driver(orion_wdt_driver);
310 298  
311 299 MODULE_AUTHOR("Sylver Bruneau <sylver.bruneau@googlemail.com>");
312 300 MODULE_DESCRIPTION("Orion Processor Watchdog");
drivers/watchdog/pnx4008_wdt.c
... ... @@ -334,18 +334,7 @@
334 334 .remove = __devexit_p(pnx4008_wdt_remove),
335 335 };
336 336  
337   -static int __init pnx4008_wdt_init(void)
338   -{
339   - return platform_driver_register(&platform_wdt_driver);
340   -}
341   -
342   -static void __exit pnx4008_wdt_exit(void)
343   -{
344   - platform_driver_unregister(&platform_wdt_driver);
345   -}
346   -
347   -module_init(pnx4008_wdt_init);
348   -module_exit(pnx4008_wdt_exit);
  337 +module_platform_driver(platform_wdt_driver);
349 338  
350 339 MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
351 340 MODULE_DESCRIPTION("PNX4008 Watchdog Driver");
drivers/watchdog/rc32434_wdt.c
... ... @@ -332,18 +332,7 @@
332 332 }
333 333 };
334 334  
335   -static int __init rc32434_wdt_init(void)
336   -{
337   - return platform_driver_register(&rc32434_wdt_driver);
338   -}
339   -
340   -static void __exit rc32434_wdt_exit(void)
341   -{
342   - platform_driver_unregister(&rc32434_wdt_driver);
343   -}
344   -
345   -module_init(rc32434_wdt_init);
346   -module_exit(rc32434_wdt_exit);
  335 +module_platform_driver(rc32434_wdt_driver);
347 336  
348 337 MODULE_AUTHOR("Ondrej Zajicek <santiago@crfreenet.org>,"
349 338 "Florian Fainelli <florian@openwrt.org>");
drivers/watchdog/rdc321x_wdt.c
... ... @@ -293,18 +293,7 @@
293 293 },
294 294 };
295 295  
296   -static int __init rdc321x_wdt_init(void)
297   -{
298   - return platform_driver_register(&rdc321x_wdt_driver);
299   -}
300   -
301   -static void __exit rdc321x_wdt_exit(void)
302   -{
303   - platform_driver_unregister(&rdc321x_wdt_driver);
304   -}
305   -
306   -module_init(rdc321x_wdt_init);
307   -module_exit(rdc321x_wdt_exit);
  296 +module_platform_driver(rdc321x_wdt_driver);
308 297  
309 298 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
310 299 MODULE_DESCRIPTION("RDC321x watchdog driver");
drivers/watchdog/riowd.c
... ... @@ -247,16 +247,5 @@
247 247 .remove = __devexit_p(riowd_remove),
248 248 };
249 249  
250   -static int __init riowd_init(void)
251   -{
252   - return platform_driver_register(&riowd_driver);
253   -}
254   -
255   -static void __exit riowd_exit(void)
256   -{
257   - platform_driver_unregister(&riowd_driver);
258   -}
259   -
260   -module_init(riowd_init);
261   -module_exit(riowd_exit);
  250 +module_platform_driver(riowd_driver);
drivers/watchdog/s3c2410_wdt.c
... ... @@ -378,6 +378,8 @@
378 378 "cannot start\n");
379 379 }
380 380  
  381 + watchdog_set_nowayout(&s3c2410_wdd, nowayout);
  382 +
381 383 ret = watchdog_register_device(&s3c2410_wdd);
382 384 if (ret) {
383 385 dev_err(dev, "cannot register watchdog (%d)\n", ret);
drivers/watchdog/stmp3xxx_wdt.c
... ... @@ -272,18 +272,7 @@
272 272 .resume = stmp3xxx_wdt_resume,
273 273 };
274 274  
275   -static int __init stmp3xxx_wdt_init(void)
276   -{
277   - return platform_driver_register(&platform_wdt_driver);
278   -}
279   -
280   -static void __exit stmp3xxx_wdt_exit(void)
281   -{
282   - return platform_driver_unregister(&platform_wdt_driver);
283   -}
284   -
285   -module_init(stmp3xxx_wdt_init);
286   -module_exit(stmp3xxx_wdt_exit);
  275 +module_platform_driver(platform_wdt_driver);
287 276  
288 277 MODULE_DESCRIPTION("STMP3XXX Watchdog Driver");
289 278 MODULE_LICENSE("GPL");
drivers/watchdog/ts72xx_wdt.c
... ... @@ -506,17 +506,7 @@
506 506 },
507 507 };
508 508  
509   -static __init int ts72xx_wdt_init(void)
510   -{
511   - return platform_driver_register(&ts72xx_wdt_driver);
512   -}
513   -module_init(ts72xx_wdt_init);
514   -
515   -static __exit void ts72xx_wdt_exit(void)
516   -{
517   - platform_driver_unregister(&ts72xx_wdt_driver);
518   -}
519   -module_exit(ts72xx_wdt_exit);
  509 +module_platform_driver(ts72xx_wdt_driver);
520 510  
521 511 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@iki.fi>");
522 512 MODULE_DESCRIPTION("TS-72xx SBC Watchdog");
drivers/watchdog/twl4030_wdt.c
... ... @@ -256,17 +256,7 @@
256 256 },
257 257 };
258 258  
259   -static int __devinit twl4030_wdt_init(void)
260   -{
261   - return platform_driver_register(&twl4030_wdt_driver);
262   -}
263   -module_init(twl4030_wdt_init);
264   -
265   -static void __devexit twl4030_wdt_exit(void)
266   -{
267   - platform_driver_unregister(&twl4030_wdt_driver);
268   -}
269   -module_exit(twl4030_wdt_exit);
  259 +module_platform_driver(twl4030_wdt_driver);
270 260  
271 261 MODULE_AUTHOR("Nokia Corporation");
272 262 MODULE_LICENSE("GPL");
drivers/watchdog/via_wdt.c
  1 +/*
  2 + * VIA Chipset Watchdog Driver
  3 + *
  4 + * Copyright (C) 2011 Sigfox
  5 + * License terms: GNU General Public License (GPL) version 2
  6 + * Author: Marc Vertes <marc.vertes@sigfox.com>
  7 + * Based on a preliminary version from Harald Welte <HaraldWelte@viatech.com>
  8 + * Timer code by Wim Van Sebroeck <wim@iguana.be>
  9 + *
  10 + * Caveat: PnP must be enabled in BIOS to allow full access to watchdog
  11 + * control registers. If not, the watchdog must be configured in BIOS manually.
  12 + */
  13 +#include <linux/device.h>
  14 +#include <linux/io.h>
  15 +#include <linux/jiffies.h>
  16 +#include <linux/module.h>
  17 +#include <linux/pci.h>
  18 +#include <linux/timer.h>
  19 +#include <linux/watchdog.h>
  20 +
  21 +/* Configuration registers relative to the pci device */
  22 +#define VIA_WDT_MMIO_BASE 0xe8 /* MMIO region base address */
  23 +#define VIA_WDT_CONF 0xec /* watchdog enable state */
  24 +
  25 +/* Relevant bits for the VIA_WDT_CONF register */
  26 +#define VIA_WDT_CONF_ENABLE 0x01 /* 1: enable watchdog */
  27 +#define VIA_WDT_CONF_MMIO 0x02 /* 1: enable watchdog MMIO */
  28 +
  29 +/*
  30 + * The MMIO region contains the watchog control register and the
  31 + * hardware timer counter.
  32 + */
  33 +#define VIA_WDT_MMIO_LEN 8 /* MMIO region length in bytes */
  34 +#define VIA_WDT_CTL 0 /* MMIO addr+0: state/control reg. */
  35 +#define VIA_WDT_COUNT 4 /* MMIO addr+4: timer counter reg. */
  36 +
  37 +/* Bits for the VIA_WDT_CTL register */
  38 +#define VIA_WDT_RUNNING 0x01 /* 0: stop, 1: running */
  39 +#define VIA_WDT_FIRED 0x02 /* 1: restarted by expired watchdog */
  40 +#define VIA_WDT_PWROFF 0x04 /* 0: reset, 1: poweroff */
  41 +#define VIA_WDT_DISABLED 0x08 /* 1: timer is disabled */
  42 +#define VIA_WDT_TRIGGER 0x80 /* 1: start a new countdown */
  43 +
  44 +/* Hardware heartbeat in seconds */
  45 +#define WDT_HW_HEARTBEAT 1
  46 +
  47 +/* Timer heartbeat (500ms) */
  48 +#define WDT_HEARTBEAT (HZ/2) /* should be <= ((WDT_HW_HEARTBEAT*HZ)/2) */
  49 +
  50 +/* User space timeout in seconds */
  51 +#define WDT_TIMEOUT_MAX 1023 /* approx. 17 min. */
  52 +#define WDT_TIMEOUT 60
  53 +static int timeout = WDT_TIMEOUT;
  54 +module_param(timeout, int, 0);
  55 +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds, between 1 and 1023 "
  56 + "(default = " __MODULE_STRING(WDT_TIMEOUT) ")");
  57 +
  58 +static int nowayout = WATCHDOG_NOWAYOUT;
  59 +module_param(nowayout, int, 0);
  60 +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started "
  61 + "(default = " __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
  62 +
  63 +static struct watchdog_device wdt_dev;
  64 +static struct resource wdt_res;
  65 +static void __iomem *wdt_mem;
  66 +static unsigned int mmio;
  67 +static void wdt_timer_tick(unsigned long data);
  68 +static DEFINE_TIMER(timer, wdt_timer_tick, 0, 0);
  69 + /* The timer that pings the watchdog */
  70 +static unsigned long next_heartbeat; /* the next_heartbeat for the timer */
  71 +
  72 +static inline void wdt_reset(void)
  73 +{
  74 + unsigned int ctl = readl(wdt_mem);
  75 +
  76 + writel(ctl | VIA_WDT_TRIGGER, wdt_mem);
  77 +}
  78 +
  79 +/*
  80 + * Timer tick: the timer will make sure that the watchdog timer hardware
  81 + * is being reset in time. The conditions to do this are:
  82 + * 1) the watchog timer has been started and /dev/watchdog is open
  83 + * and there is still time left before userspace should send the
  84 + * next heartbeat/ping. (note: the internal heartbeat is much smaller
  85 + * then the external/userspace heartbeat).
  86 + * 2) the watchdog timer has been stopped by userspace.
  87 + */
  88 +static void wdt_timer_tick(unsigned long data)
  89 +{
  90 + if (time_before(jiffies, next_heartbeat) ||
  91 + (!test_bit(WDOG_ACTIVE, &wdt_dev.status))) {
  92 + wdt_reset();
  93 + mod_timer(&timer, jiffies + WDT_HEARTBEAT);
  94 + } else
  95 + pr_crit("I will reboot your machine !\n");
  96 +}
  97 +
  98 +static int wdt_ping(struct watchdog_device *wdd)
  99 +{
  100 + /* calculate when the next userspace timeout will be */
  101 + next_heartbeat = jiffies + timeout * HZ;
  102 + return 0;
  103 +}
  104 +
  105 +static int wdt_start(struct watchdog_device *wdd)
  106 +{
  107 + unsigned int ctl = readl(wdt_mem);
  108 +
  109 + writel(timeout, wdt_mem + VIA_WDT_COUNT);
  110 + writel(ctl | VIA_WDT_RUNNING | VIA_WDT_TRIGGER, wdt_mem);
  111 + wdt_ping(wdd);
  112 + mod_timer(&timer, jiffies + WDT_HEARTBEAT);
  113 + return 0;
  114 +}
  115 +
  116 +static int wdt_stop(struct watchdog_device *wdd)
  117 +{
  118 + unsigned int ctl = readl(wdt_mem);
  119 +
  120 + writel(ctl & ~VIA_WDT_RUNNING, wdt_mem);
  121 + return 0;
  122 +}
  123 +
  124 +static int wdt_set_timeout(struct watchdog_device *wdd,
  125 + unsigned int new_timeout)
  126 +{
  127 + if (new_timeout < 1 || new_timeout > WDT_TIMEOUT_MAX)
  128 + return -EINVAL;
  129 + writel(new_timeout, wdt_mem + VIA_WDT_COUNT);
  130 + timeout = new_timeout;
  131 + return 0;
  132 +}
  133 +
  134 +static const struct watchdog_info wdt_info = {
  135 + .identity = "VIA watchdog",
  136 + .options = WDIOF_CARDRESET |
  137 + WDIOF_SETTIMEOUT |
  138 + WDIOF_MAGICCLOSE |
  139 + WDIOF_KEEPALIVEPING,
  140 +};
  141 +
  142 +static const struct watchdog_ops wdt_ops = {
  143 + .owner = THIS_MODULE,
  144 + .start = wdt_start,
  145 + .stop = wdt_stop,
  146 + .ping = wdt_ping,
  147 + .set_timeout = wdt_set_timeout,
  148 +};
  149 +
  150 +static struct watchdog_device wdt_dev = {
  151 + .info = &wdt_info,
  152 + .ops = &wdt_ops,
  153 +};
  154 +
  155 +static int __devinit wdt_probe(struct pci_dev *pdev,
  156 + const struct pci_device_id *ent)
  157 +{
  158 + unsigned char conf;
  159 + int ret = -ENODEV;
  160 +
  161 + if (pci_enable_device(pdev)) {
  162 + dev_err(&pdev->dev, "cannot enable PCI device\n");
  163 + return -ENODEV;
  164 + }
  165 +
  166 + /*
  167 + * Allocate a MMIO region which contains watchdog control register
  168 + * and counter, then configure the watchdog to use this region.
  169 + * This is possible only if PnP is properly enabled in BIOS.
  170 + * If not, the watchdog must be configured in BIOS manually.
  171 + */
  172 + if (allocate_resource(&iomem_resource, &wdt_res, VIA_WDT_MMIO_LEN,
  173 + 0xf0000000, 0xffffff00, 0xff, NULL, NULL)) {
  174 + dev_err(&pdev->dev, "MMIO allocation failed\n");
  175 + goto err_out_disable_device;
  176 + }
  177 +
  178 + pci_write_config_dword(pdev, VIA_WDT_MMIO_BASE, wdt_res.start);
  179 + pci_read_config_byte(pdev, VIA_WDT_CONF, &conf);
  180 + conf |= VIA_WDT_CONF_ENABLE | VIA_WDT_CONF_MMIO;
  181 + pci_write_config_byte(pdev, VIA_WDT_CONF, conf);
  182 +
  183 + pci_read_config_dword(pdev, VIA_WDT_MMIO_BASE, &mmio);
  184 + if (mmio) {
  185 + dev_info(&pdev->dev, "VIA Chipset watchdog MMIO: %x\n", mmio);
  186 + } else {
  187 + dev_err(&pdev->dev, "MMIO setting failed. Check BIOS.\n");
  188 + goto err_out_resource;
  189 + }
  190 +
  191 + if (!request_mem_region(mmio, VIA_WDT_MMIO_LEN, "via_wdt")) {
  192 + dev_err(&pdev->dev, "MMIO region busy\n");
  193 + goto err_out_resource;
  194 + }
  195 +
  196 + wdt_mem = ioremap(mmio, VIA_WDT_MMIO_LEN);
  197 + if (wdt_mem == NULL) {
  198 + dev_err(&pdev->dev, "cannot remap VIA wdt MMIO registers\n");
  199 + goto err_out_release;
  200 + }
  201 +
  202 + wdt_dev.timeout = timeout;
  203 + watchdog_set_nowayout(&wdt_dev, nowayout);
  204 + if (readl(wdt_mem) & VIA_WDT_FIRED)
  205 + wdt_dev.bootstatus |= WDIOF_CARDRESET;
  206 +
  207 + ret = watchdog_register_device(&wdt_dev);
  208 + if (ret)
  209 + goto err_out_iounmap;
  210 +
  211 + /* start triggering, in case of watchdog already enabled by BIOS */
  212 + mod_timer(&timer, jiffies + WDT_HEARTBEAT);
  213 + return 0;
  214 +
  215 +err_out_iounmap:
  216 + iounmap(wdt_mem);
  217 +err_out_release:
  218 + release_mem_region(mmio, VIA_WDT_MMIO_LEN);
  219 +err_out_resource:
  220 + release_resource(&wdt_res);
  221 +err_out_disable_device:
  222 + pci_disable_device(pdev);
  223 + return ret;
  224 +}
  225 +
  226 +static void __devexit wdt_remove(struct pci_dev *pdev)
  227 +{
  228 + watchdog_unregister_device(&wdt_dev);
  229 + del_timer(&timer);
  230 + iounmap(wdt_mem);
  231 + release_mem_region(mmio, VIA_WDT_MMIO_LEN);
  232 + release_resource(&wdt_res);
  233 + pci_disable_device(pdev);
  234 +}
  235 +
  236 +DEFINE_PCI_DEVICE_TABLE(wdt_pci_table) = {
  237 + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700) },
  238 + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX800) },
  239 + { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VX855) },
  240 + { 0 }
  241 +};
  242 +
  243 +static struct pci_driver wdt_driver = {
  244 + .name = "via_wdt",
  245 + .id_table = wdt_pci_table,
  246 + .probe = wdt_probe,
  247 + .remove = __devexit_p(wdt_remove),
  248 +};
  249 +
  250 +static int __init wdt_init(void)
  251 +{
  252 + if (timeout < 1 || timeout > WDT_TIMEOUT_MAX)
  253 + timeout = WDT_TIMEOUT;
  254 + return pci_register_driver(&wdt_driver);
  255 +}
  256 +
  257 +static void __exit wdt_exit(void)
  258 +{
  259 + pci_unregister_driver(&wdt_driver);
  260 +}
  261 +
  262 +module_init(wdt_init);
  263 +module_exit(wdt_exit);
  264 +
  265 +MODULE_AUTHOR("Marc Vertes");
  266 +MODULE_DESCRIPTION("Driver for watchdog timer on VIA chipset");
  267 +MODULE_LICENSE("GPL");
drivers/watchdog/wm831x_wdt.c
... ... @@ -199,7 +199,8 @@
199 199 if (reg & WM831X_WDOG_DEBUG)
200 200 dev_warn(wm831x->dev, "Watchdog is paused\n");
201 201  
202   - driver_data = kzalloc(sizeof(*driver_data), GFP_KERNEL);
  202 + driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data),
  203 + GFP_KERNEL);
203 204 if (!driver_data) {
204 205 dev_err(wm831x->dev, "Unable to alloacate watchdog device\n");
205 206 ret = -ENOMEM;
206 207  
... ... @@ -213,11 +214,9 @@
213 214  
214 215 wm831x_wdt->info = &wm831x_wdt_info;
215 216 wm831x_wdt->ops = &wm831x_wdt_ops;
  217 + watchdog_set_nowayout(wm831x_wdt, nowayout);
216 218 watchdog_set_drvdata(wm831x_wdt, driver_data);
217 219  
218   - if (nowayout)
219   - wm831x_wdt->status |= WDOG_NO_WAY_OUT;
220   -
221 220 reg = wm831x_reg_read(wm831x, WM831X_WATCHDOG);
222 221 reg &= WM831X_WDOG_TO_MASK;
223 222 for (i = 0; i < ARRAY_SIZE(wm831x_wdt_cfgs); i++)
... ... @@ -252,7 +251,7 @@
252 251 dev_err(wm831x->dev,
253 252 "Failed to request update GPIO: %d\n",
254 253 ret);
255   - goto err_alloc;
  254 + goto err;
256 255 }
257 256  
258 257 ret = gpio_direction_output(pdata->update_gpio, 0);
... ... @@ -294,8 +293,6 @@
294 293 err_gpio:
295 294 if (driver_data->update_gpio)
296 295 gpio_free(driver_data->update_gpio);
297   -err_alloc:
298   - kfree(driver_data);
299 296 err:
300 297 return ret;
301 298 }
... ... @@ -320,17 +317,7 @@
320 317 },
321 318 };
322 319  
323   -static int __init wm831x_wdt_init(void)
324   -{
325   - return platform_driver_register(&wm831x_wdt_driver);
326   -}
327   -module_init(wm831x_wdt_init);
328   -
329   -static void __exit wm831x_wdt_exit(void)
330   -{
331   - platform_driver_unregister(&wm831x_wdt_driver);
332   -}
333   -module_exit(wm831x_wdt_exit);
  320 +module_platform_driver(wm831x_wdt_driver);
334 321  
335 322 MODULE_AUTHOR("Mark Brown");
336 323 MODULE_DESCRIPTION("WM831x Watchdog");
drivers/watchdog/wm8350_wdt.c
... ... @@ -311,17 +311,7 @@
311 311 },
312 312 };
313 313  
314   -static int __init wm8350_wdt_init(void)
315   -{
316   - return platform_driver_register(&wm8350_wdt_driver);
317   -}
318   -module_init(wm8350_wdt_init);
319   -
320   -static void __exit wm8350_wdt_exit(void)
321   -{
322   - platform_driver_unregister(&wm8350_wdt_driver);
323   -}
324   -module_exit(wm8350_wdt_exit);
  314 +module_platform_driver(wm8350_wdt_driver);
325 315  
326 316 MODULE_AUTHOR("Mark Brown");
327 317 MODULE_DESCRIPTION("WM8350 Watchdog");
include/linux/watchdog.h
... ... @@ -53,11 +53,7 @@
53 53  
54 54 #ifdef __KERNEL__
55 55  
56   -#ifdef CONFIG_WATCHDOG_NOWAYOUT
57   -#define WATCHDOG_NOWAYOUT 1
58   -#else
59   -#define WATCHDOG_NOWAYOUT 0
60   -#endif
  56 +#include <linux/bitops.h>
61 57  
62 58 struct watchdog_ops;
63 59 struct watchdog_device;
... ... @@ -121,6 +117,21 @@
121 117 #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
122 118 #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
123 119 };
  120 +
  121 +#ifdef CONFIG_WATCHDOG_NOWAYOUT
  122 +#define WATCHDOG_NOWAYOUT 1
  123 +#define WATCHDOG_NOWAYOUT_INIT_STATUS (1 << WDOG_NO_WAY_OUT)
  124 +#else
  125 +#define WATCHDOG_NOWAYOUT 0
  126 +#define WATCHDOG_NOWAYOUT_INIT_STATUS 0
  127 +#endif
  128 +
  129 +/* Use the following function to set the nowayout feature */
  130 +static inline void watchdog_set_nowayout(struct watchdog_device *wdd, int nowayout)
  131 +{
  132 + if (nowayout)
  133 + set_bit(WDOG_NO_WAY_OUT, &wdd->status);
  134 +}
124 135  
125 136 /* Use the following functions to manipulate watchdog driver specific data */
126 137 static inline void watchdog_set_drvdata(struct watchdog_device *wdd, void *data)