wdrtas.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*
  2. * FIXME: add wdrtas_get_status and wdrtas_get_boot_status as soon as
  3. * RTAS calls are available
  4. */
  5. /*
  6. * RTAS watchdog driver
  7. *
  8. * (C) Copyright IBM Corp. 2005
  9. * device driver to exploit watchdog RTAS functions
  10. *
  11. * Authors : Utz Bacher <utz.bacher@de.ibm.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2, or (at your option)
  16. * any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26. */
  27. #include <linux/config.h>
  28. #include <linux/fs.h>
  29. #include <linux/init.h>
  30. #include <linux/kernel.h>
  31. #include <linux/miscdevice.h>
  32. #include <linux/module.h>
  33. #include <linux/notifier.h>
  34. #include <linux/reboot.h>
  35. #include <linux/types.h>
  36. #include <linux/watchdog.h>
  37. #include <asm/rtas.h>
  38. #include <asm/uaccess.h>
  39. #define WDRTAS_MAGIC_CHAR 42
  40. #define WDRTAS_SUPPORTED_MASK (WDIOF_SETTIMEOUT | \
  41. WDIOF_MAGICCLOSE)
  42. MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
  43. MODULE_DESCRIPTION("RTAS watchdog driver");
  44. MODULE_LICENSE("GPL");
  45. MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
  46. MODULE_ALIAS_MISCDEV(TEMP_MINOR);
  47. #ifdef CONFIG_WATCHDOG_NOWAYOUT
  48. static int wdrtas_nowayout = 1;
  49. #else
  50. static int wdrtas_nowayout = 0;
  51. #endif
  52. static atomic_t wdrtas_miscdev_open = ATOMIC_INIT(0);
  53. static char wdrtas_expect_close = 0;
  54. static int wdrtas_interval;
  55. #define WDRTAS_THERMAL_SENSOR 3
  56. static int wdrtas_token_get_sensor_state;
  57. #define WDRTAS_SURVEILLANCE_IND 9000
  58. static int wdrtas_token_set_indicator;
  59. #define WDRTAS_SP_SPI 28
  60. static int wdrtas_token_get_sp;
  61. static int wdrtas_token_event_scan;
  62. #define WDRTAS_DEFAULT_INTERVAL 300
  63. #define WDRTAS_LOGBUFFER_LEN 128
  64. static char wdrtas_logbuffer[WDRTAS_LOGBUFFER_LEN];
  65. /*** watchdog access functions */
  66. /**
  67. * wdrtas_set_interval - sets the watchdog interval
  68. * @interval: new interval
  69. *
  70. * returns 0 on success, <0 on failures
  71. *
  72. * wdrtas_set_interval sets the watchdog keepalive interval by calling the
  73. * RTAS function set-indicator (surveillance). The unit of interval is
  74. * seconds.
  75. */
  76. static int
  77. wdrtas_set_interval(int interval)
  78. {
  79. long result;
  80. static int print_msg = 10;
  81. /* rtas uses minutes */
  82. interval = (interval + 59) / 60;
  83. result = rtas_call(wdrtas_token_set_indicator, 3, 1, NULL,
  84. WDRTAS_SURVEILLANCE_IND, 0, interval);
  85. if ( (result < 0) && (print_msg) ) {
  86. printk(KERN_ERR "wdrtas: setting the watchdog to %i "
  87. "timeout failed: %li\n", interval, result);
  88. print_msg--;
  89. }
  90. return result;
  91. }
  92. /**
  93. * wdrtas_get_interval - returns the current watchdog interval
  94. * @fallback_value: value (in seconds) to use, if the RTAS call fails
  95. *
  96. * returns the interval
  97. *
  98. * wdrtas_get_interval returns the current watchdog keepalive interval
  99. * as reported by the RTAS function ibm,get-system-parameter. The unit
  100. * of the return value is seconds.
  101. */
  102. static int
  103. wdrtas_get_interval(int fallback_value)
  104. {
  105. long result;
  106. char value[4];
  107. result = rtas_call(wdrtas_token_get_sp, 3, 1, NULL,
  108. WDRTAS_SP_SPI, (void *)__pa(&value), 4);
  109. if ( (value[0] != 0) || (value[1] != 2) || (value[3] != 0) ||
  110. (result < 0) ) {
  111. printk(KERN_WARNING "wdrtas: could not get sp_spi watchdog "
  112. "timeout (%li). Continuing\n", result);
  113. return fallback_value;
  114. }
  115. /* rtas uses minutes */
  116. return ((int)value[2]) * 60;
  117. }
  118. /**
  119. * wdrtas_timer_start - starts watchdog
  120. *
  121. * wdrtas_timer_start starts the watchdog by calling the RTAS function
  122. * set-interval (surveillance)
  123. */
  124. static void
  125. wdrtas_timer_start(void)
  126. {
  127. wdrtas_set_interval(wdrtas_interval);
  128. }
  129. /**
  130. * wdrtas_timer_stop - stops watchdog
  131. *
  132. * wdrtas_timer_stop stops the watchdog timer by calling the RTAS function
  133. * set-interval (surveillance)
  134. */
  135. static void
  136. wdrtas_timer_stop(void)
  137. {
  138. wdrtas_set_interval(0);
  139. }
  140. /**
  141. * wdrtas_log_scanned_event - logs an event we received during keepalive
  142. *
  143. * wdrtas_log_scanned_event prints a message to the log buffer dumping
  144. * the results of the last event-scan call
  145. */
  146. static void
  147. wdrtas_log_scanned_event(void)
  148. {
  149. int i;
  150. for (i = 0; i < WDRTAS_LOGBUFFER_LEN; i += 16)
  151. printk(KERN_INFO "wdrtas: dumping event (line %i/%i), data = "
  152. "%02x %02x %02x %02x %02x %02x %02x %02x "
  153. "%02x %02x %02x %02x %02x %02x %02x %02x\n",
  154. (i / 16) + 1, (WDRTAS_LOGBUFFER_LEN / 16),
  155. wdrtas_logbuffer[i + 0], wdrtas_logbuffer[i + 1],
  156. wdrtas_logbuffer[i + 2], wdrtas_logbuffer[i + 3],
  157. wdrtas_logbuffer[i + 4], wdrtas_logbuffer[i + 5],
  158. wdrtas_logbuffer[i + 6], wdrtas_logbuffer[i + 7],
  159. wdrtas_logbuffer[i + 8], wdrtas_logbuffer[i + 9],
  160. wdrtas_logbuffer[i + 10], wdrtas_logbuffer[i + 11],
  161. wdrtas_logbuffer[i + 12], wdrtas_logbuffer[i + 13],
  162. wdrtas_logbuffer[i + 14], wdrtas_logbuffer[i + 15]);
  163. }
  164. /**
  165. * wdrtas_timer_keepalive - resets watchdog timer to keep system alive
  166. *
  167. * wdrtas_timer_keepalive restarts the watchdog timer by calling the
  168. * RTAS function event-scan and repeats these calls as long as there are
  169. * events available. All events will be dumped.
  170. */
  171. static void
  172. wdrtas_timer_keepalive(void)
  173. {
  174. long result;
  175. do {
  176. result = rtas_call(wdrtas_token_event_scan, 4, 1, NULL,
  177. RTAS_EVENT_SCAN_ALL_EVENTS, 0,
  178. (void *)__pa(wdrtas_logbuffer),
  179. WDRTAS_LOGBUFFER_LEN);
  180. if (result < 0)
  181. printk(KERN_ERR "wdrtas: event-scan failed: %li\n",
  182. result);
  183. if (result == 0)
  184. wdrtas_log_scanned_event();
  185. } while (result == 0);
  186. }
  187. /**
  188. * wdrtas_get_temperature - returns current temperature
  189. *
  190. * returns temperature or <0 on failures
  191. *
  192. * wdrtas_get_temperature returns the current temperature in Fahrenheit. It
  193. * uses the RTAS call get-sensor-state, token 3 to do so
  194. */
  195. static int
  196. wdrtas_get_temperature(void)
  197. {
  198. long result;
  199. int temperature = 0;
  200. result = rtas_call(wdrtas_token_get_sensor_state, 2, 2,
  201. (void *)__pa(&temperature),
  202. WDRTAS_THERMAL_SENSOR, 0);
  203. if (result < 0)
  204. printk(KERN_WARNING "wdrtas: reading the thermal sensor "
  205. "faild: %li\n", result);
  206. else
  207. temperature = ((temperature * 9) / 5) + 32; /* fahrenheit */
  208. return temperature;
  209. }
  210. /**
  211. * wdrtas_get_status - returns the status of the watchdog
  212. *
  213. * returns a bitmask of defines WDIOF_... as defined in
  214. * include/linux/watchdog.h
  215. */
  216. static int
  217. wdrtas_get_status(void)
  218. {
  219. return 0; /* TODO */
  220. }
  221. /**
  222. * wdrtas_get_boot_status - returns the reason for the last boot
  223. *
  224. * returns a bitmask of defines WDIOF_... as defined in
  225. * include/linux/watchdog.h, indicating why the watchdog rebooted the system
  226. */
  227. static int
  228. wdrtas_get_boot_status(void)
  229. {
  230. return 0; /* TODO */
  231. }
  232. /*** watchdog API and operations stuff */
  233. /* wdrtas_write - called when watchdog device is written to
  234. * @file: file structure
  235. * @buf: user buffer with data
  236. * @len: amount to data written
  237. * @ppos: position in file
  238. *
  239. * returns the number of successfully processed characters, which is always
  240. * the number of bytes passed to this function
  241. *
  242. * wdrtas_write processes all the data given to it and looks for the magic
  243. * character 'V'. This character allows the watchdog device to be closed
  244. * properly.
  245. */
  246. static ssize_t
  247. wdrtas_write(struct file *file, const char __user *buf,
  248. size_t len, loff_t *ppos)
  249. {
  250. int i;
  251. char c;
  252. if (!len)
  253. goto out;
  254. if (!wdrtas_nowayout) {
  255. wdrtas_expect_close = 0;
  256. /* look for 'V' */
  257. for (i = 0; i < len; i++) {
  258. if (get_user(c, buf + i))
  259. return -EFAULT;
  260. /* allow to close device */
  261. if (c == 'V')
  262. wdrtas_expect_close = WDRTAS_MAGIC_CHAR;
  263. }
  264. }
  265. wdrtas_timer_keepalive();
  266. out:
  267. return len;
  268. }
  269. /**
  270. * wdrtas_ioctl - ioctl function for the watchdog device
  271. * @inode: inode structure
  272. * @file: file structure
  273. * @cmd: command for ioctl
  274. * @arg: argument pointer
  275. *
  276. * returns 0 on success, <0 on failure
  277. *
  278. * wdrtas_ioctl implements the watchdog API ioctls
  279. */
  280. static int
  281. wdrtas_ioctl(struct inode *inode, struct file *file,
  282. unsigned int cmd, unsigned long arg)
  283. {
  284. int __user *argp = (void __user *)arg;
  285. int i;
  286. static struct watchdog_info wdinfo = {
  287. .options = WDRTAS_SUPPORTED_MASK,
  288. .firmware_version = 0,
  289. .identity = "wdrtas"
  290. };
  291. switch (cmd) {
  292. case WDIOC_GETSUPPORT:
  293. if (copy_to_user(argp, &wdinfo, sizeof(wdinfo)))
  294. return -EFAULT;
  295. return 0;
  296. case WDIOC_GETSTATUS:
  297. i = wdrtas_get_status();
  298. return put_user(i, argp);
  299. case WDIOC_GETBOOTSTATUS:
  300. i = wdrtas_get_boot_status();
  301. return put_user(i, argp);
  302. case WDIOC_GETTEMP:
  303. if (wdrtas_token_get_sensor_state == RTAS_UNKNOWN_SERVICE)
  304. return -EOPNOTSUPP;
  305. i = wdrtas_get_temperature();
  306. return put_user(i, argp);
  307. case WDIOC_SETOPTIONS:
  308. if (get_user(i, argp))
  309. return -EFAULT;
  310. if (i & WDIOS_DISABLECARD)
  311. wdrtas_timer_stop();
  312. if (i & WDIOS_ENABLECARD) {
  313. wdrtas_timer_keepalive();
  314. wdrtas_timer_start();
  315. }
  316. if (i & WDIOS_TEMPPANIC) {
  317. /* not implemented. Done by H8 */
  318. }
  319. return 0;
  320. case WDIOC_KEEPALIVE:
  321. wdrtas_timer_keepalive();
  322. return 0;
  323. case WDIOC_SETTIMEOUT:
  324. if (get_user(i, argp))
  325. return -EFAULT;
  326. if (wdrtas_set_interval(i))
  327. return -EINVAL;
  328. wdrtas_timer_keepalive();
  329. if (wdrtas_token_get_sp == RTAS_UNKNOWN_SERVICE)
  330. wdrtas_interval = i;
  331. else
  332. wdrtas_interval = wdrtas_get_interval(i);
  333. /* fallthrough */
  334. case WDIOC_GETTIMEOUT:
  335. return put_user(wdrtas_interval, argp);
  336. default:
  337. return -ENOIOCTLCMD;
  338. }
  339. }
  340. /**
  341. * wdrtas_open - open function of watchdog device
  342. * @inode: inode structure
  343. * @file: file structure
  344. *
  345. * returns 0 on success, -EBUSY if the file has been opened already, <0 on
  346. * other failures
  347. *
  348. * function called when watchdog device is opened
  349. */
  350. static int
  351. wdrtas_open(struct inode *inode, struct file *file)
  352. {
  353. /* only open once */
  354. if (atomic_inc_return(&wdrtas_miscdev_open) > 1) {
  355. atomic_dec(&wdrtas_miscdev_open);
  356. return -EBUSY;
  357. }
  358. wdrtas_timer_start();
  359. wdrtas_timer_keepalive();
  360. return nonseekable_open(inode, file);
  361. }
  362. /**
  363. * wdrtas_close - close function of watchdog device
  364. * @inode: inode structure
  365. * @file: file structure
  366. *
  367. * returns 0 on success
  368. *
  369. * close function. Always succeeds
  370. */
  371. static int
  372. wdrtas_close(struct inode *inode, struct file *file)
  373. {
  374. /* only stop watchdog, if this was announced using 'V' before */
  375. if (wdrtas_expect_close == WDRTAS_MAGIC_CHAR)
  376. wdrtas_timer_stop();
  377. else {
  378. printk(KERN_WARNING "wdrtas: got unexpected close. Watchdog "
  379. "not stopped.\n");
  380. wdrtas_timer_keepalive();
  381. }
  382. wdrtas_expect_close = 0;
  383. atomic_dec(&wdrtas_miscdev_open);
  384. return 0;
  385. }
  386. /**
  387. * wdrtas_temp_read - gives back the temperature in fahrenheit
  388. * @file: file structure
  389. * @buf: user buffer
  390. * @count: number of bytes to be read
  391. * @ppos: position in file
  392. *
  393. * returns always 1 or -EFAULT in case of user space copy failures, <0 on
  394. * other failures
  395. *
  396. * wdrtas_temp_read gives the temperature to the users by copying this
  397. * value as one byte into the user space buffer. The unit is Fahrenheit...
  398. */
  399. static ssize_t
  400. wdrtas_temp_read(struct file *file, char __user *buf,
  401. size_t count, loff_t *ppos)
  402. {
  403. int temperature = 0;
  404. temperature = wdrtas_get_temperature();
  405. if (temperature < 0)
  406. return temperature;
  407. if (copy_to_user(buf, &temperature, 1))
  408. return -EFAULT;
  409. return 1;
  410. }
  411. /**
  412. * wdrtas_temp_open - open function of temperature device
  413. * @inode: inode structure
  414. * @file: file structure
  415. *
  416. * returns 0 on success, <0 on failure
  417. *
  418. * function called when temperature device is opened
  419. */
  420. static int
  421. wdrtas_temp_open(struct inode *inode, struct file *file)
  422. {
  423. return nonseekable_open(inode, file);
  424. }
  425. /**
  426. * wdrtas_temp_close - close function of temperature device
  427. * @inode: inode structure
  428. * @file: file structure
  429. *
  430. * returns 0 on success
  431. *
  432. * close function. Always succeeds
  433. */
  434. static int
  435. wdrtas_temp_close(struct inode *inode, struct file *file)
  436. {
  437. return 0;
  438. }
  439. /**
  440. * wdrtas_reboot - reboot notifier function
  441. * @nb: notifier block structure
  442. * @code: reboot code
  443. * @ptr: unused
  444. *
  445. * returns NOTIFY_DONE
  446. *
  447. * wdrtas_reboot stops the watchdog in case of a reboot
  448. */
  449. static int
  450. wdrtas_reboot(struct notifier_block *this, unsigned long code, void *ptr)
  451. {
  452. if ( (code==SYS_DOWN) || (code==SYS_HALT) )
  453. wdrtas_timer_stop();
  454. return NOTIFY_DONE;
  455. }
  456. /*** initialization stuff */
  457. static struct file_operations wdrtas_fops = {
  458. .owner = THIS_MODULE,
  459. .llseek = no_llseek,
  460. .write = wdrtas_write,
  461. .ioctl = wdrtas_ioctl,
  462. .open = wdrtas_open,
  463. .release = wdrtas_close,
  464. };
  465. static struct miscdevice wdrtas_miscdev = {
  466. .minor = WATCHDOG_MINOR,
  467. .name = "watchdog",
  468. .fops = &wdrtas_fops,
  469. };
  470. static struct file_operations wdrtas_temp_fops = {
  471. .owner = THIS_MODULE,
  472. .llseek = no_llseek,
  473. .read = wdrtas_temp_read,
  474. .open = wdrtas_temp_open,
  475. .release = wdrtas_temp_close,
  476. };
  477. static struct miscdevice wdrtas_tempdev = {
  478. .minor = TEMP_MINOR,
  479. .name = "temperature",
  480. .fops = &wdrtas_temp_fops,
  481. };
  482. static struct notifier_block wdrtas_notifier = {
  483. .notifier_call = wdrtas_reboot,
  484. };
  485. /**
  486. * wdrtas_get_tokens - reads in RTAS tokens
  487. *
  488. * returns 0 on succes, <0 on failure
  489. *
  490. * wdrtas_get_tokens reads in the tokens for the RTAS calls used in
  491. * this watchdog driver. It tolerates, if "get-sensor-state" and
  492. * "ibm,get-system-parameter" are not available.
  493. */
  494. static int
  495. wdrtas_get_tokens(void)
  496. {
  497. wdrtas_token_get_sensor_state = rtas_token("get-sensor-state");
  498. if (wdrtas_token_get_sensor_state == RTAS_UNKNOWN_SERVICE) {
  499. printk(KERN_WARNING "wdrtas: couldn't get token for "
  500. "get-sensor-state. Trying to continue without "
  501. "temperature support.\n");
  502. }
  503. wdrtas_token_get_sp = rtas_token("ibm,get-system-parameter");
  504. if (wdrtas_token_get_sp == RTAS_UNKNOWN_SERVICE) {
  505. printk(KERN_WARNING "wdrtas: couldn't get token for "
  506. "ibm,get-system-parameter. Trying to continue with "
  507. "a default timeout value of %i seconds.\n",
  508. WDRTAS_DEFAULT_INTERVAL);
  509. }
  510. wdrtas_token_set_indicator = rtas_token("set-indicator");
  511. if (wdrtas_token_set_indicator == RTAS_UNKNOWN_SERVICE) {
  512. printk(KERN_ERR "wdrtas: couldn't get token for "
  513. "set-indicator. Terminating watchdog code.\n");
  514. return -EIO;
  515. }
  516. wdrtas_token_event_scan = rtas_token("event-scan");
  517. if (wdrtas_token_event_scan == RTAS_UNKNOWN_SERVICE) {
  518. printk(KERN_ERR "wdrtas: couldn't get token for event-scan. "
  519. "Terminating watchdog code.\n");
  520. return -EIO;
  521. }
  522. return 0;
  523. }
  524. /**
  525. * wdrtas_unregister_devs - unregisters the misc dev handlers
  526. *
  527. * wdrtas_register_devs unregisters the watchdog and temperature watchdog
  528. * misc devs
  529. */
  530. static void
  531. wdrtas_unregister_devs(void)
  532. {
  533. misc_deregister(&wdrtas_miscdev);
  534. if (wdrtas_token_get_sensor_state != RTAS_UNKNOWN_SERVICE)
  535. misc_deregister(&wdrtas_tempdev);
  536. }
  537. /**
  538. * wdrtas_register_devs - registers the misc dev handlers
  539. *
  540. * returns 0 on succes, <0 on failure
  541. *
  542. * wdrtas_register_devs registers the watchdog and temperature watchdog
  543. * misc devs
  544. */
  545. static int
  546. wdrtas_register_devs(void)
  547. {
  548. int result;
  549. result = misc_register(&wdrtas_miscdev);
  550. if (result) {
  551. printk(KERN_ERR "wdrtas: couldn't register watchdog misc "
  552. "device. Terminating watchdog code.\n");
  553. return result;
  554. }
  555. if (wdrtas_token_get_sensor_state != RTAS_UNKNOWN_SERVICE) {
  556. result = misc_register(&wdrtas_tempdev);
  557. if (result) {
  558. printk(KERN_WARNING "wdrtas: couldn't register "
  559. "watchdog temperature misc device. Continuing "
  560. "without temperature support.\n");
  561. wdrtas_token_get_sensor_state = RTAS_UNKNOWN_SERVICE;
  562. }
  563. }
  564. return 0;
  565. }
  566. /**
  567. * wdrtas_init - init function of the watchdog driver
  568. *
  569. * returns 0 on succes, <0 on failure
  570. *
  571. * registers the file handlers and the reboot notifier
  572. */
  573. static int __init
  574. wdrtas_init(void)
  575. {
  576. if (wdrtas_get_tokens())
  577. return -ENODEV;
  578. if (wdrtas_register_devs())
  579. return -ENODEV;
  580. if (register_reboot_notifier(&wdrtas_notifier)) {
  581. printk(KERN_ERR "wdrtas: could not register reboot notifier. "
  582. "Terminating watchdog code.\n");
  583. wdrtas_unregister_devs();
  584. return -ENODEV;
  585. }
  586. if (wdrtas_token_get_sp == RTAS_UNKNOWN_SERVICE)
  587. wdrtas_interval = WDRTAS_DEFAULT_INTERVAL;
  588. else
  589. wdrtas_interval = wdrtas_get_interval(WDRTAS_DEFAULT_INTERVAL);
  590. return 0;
  591. }
  592. /**
  593. * wdrtas_exit - exit function of the watchdog driver
  594. *
  595. * unregisters the file handlers and the reboot notifier
  596. */
  597. static void __exit
  598. wdrtas_exit(void)
  599. {
  600. if (!wdrtas_nowayout)
  601. wdrtas_timer_stop();
  602. wdrtas_unregister_devs();
  603. unregister_reboot_notifier(&wdrtas_notifier);
  604. }
  605. module_init(wdrtas_init);
  606. module_exit(wdrtas_exit);