wdt_pci.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. /*
  2. * Industrial Computer Source PCI-WDT500/501 driver
  3. *
  4. * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
  5. * All Rights Reserved.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. *
  12. * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
  13. * warranty for any of this software. This material is provided
  14. * "AS-IS" and at no charge.
  15. *
  16. * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
  17. *
  18. * Release 0.10.
  19. *
  20. * Fixes
  21. * Dave Gregorich : Modularisation and minor bugs
  22. * Alan Cox : Added the watchdog ioctl() stuff
  23. * Alan Cox : Fixed the reboot problem (as noted by
  24. * Matt Crocker).
  25. * Alan Cox : Added wdt= boot option
  26. * Alan Cox : Cleaned up copy/user stuff
  27. * Tim Hockin : Added insmod parameters, comment cleanup
  28. * Parameterized timeout
  29. * JP Nollmann : Added support for PCI wdt501p
  30. * Alan Cox : Split ISA and PCI cards into two drivers
  31. * Jeff Garzik : PCI cleanups
  32. * Tigran Aivazian : Restructured wdtpci_init_one() to handle
  33. * failures
  34. * Joel Becker : Added WDIOC_GET/SETTIMEOUT
  35. * Zwane Mwaikambo : Magic char closing, locking changes,
  36. * cleanups
  37. * Matt Domsch : nowayout module option
  38. */
  39. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  40. #include <linux/interrupt.h>
  41. #include <linux/module.h>
  42. #include <linux/moduleparam.h>
  43. #include <linux/types.h>
  44. #include <linux/miscdevice.h>
  45. #include <linux/watchdog.h>
  46. #include <linux/ioport.h>
  47. #include <linux/delay.h>
  48. #include <linux/notifier.h>
  49. #include <linux/reboot.h>
  50. #include <linux/fs.h>
  51. #include <linux/pci.h>
  52. #include <linux/io.h>
  53. #include <linux/uaccess.h>
  54. #define WDT_IS_PCI
  55. #include "wd501p.h"
  56. /* We can only use 1 card due to the /dev/watchdog restriction */
  57. static int dev_count;
  58. static unsigned long open_lock;
  59. static DEFINE_SPINLOCK(wdtpci_lock);
  60. static char expect_close;
  61. static resource_size_t io;
  62. static int irq;
  63. /* Default timeout */
  64. #define WD_TIMO 60 /* Default heartbeat = 60 seconds */
  65. static int heartbeat = WD_TIMO;
  66. static int wd_heartbeat;
  67. module_param(heartbeat, int, 0);
  68. MODULE_PARM_DESC(heartbeat,
  69. "Watchdog heartbeat in seconds. (0<heartbeat<65536, default="
  70. __MODULE_STRING(WD_TIMO) ")");
  71. static bool nowayout = WATCHDOG_NOWAYOUT;
  72. module_param(nowayout, bool, 0);
  73. MODULE_PARM_DESC(nowayout,
  74. "Watchdog cannot be stopped once started (default="
  75. __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
  76. /* Support for the Fan Tachometer on the PCI-WDT501 */
  77. static int tachometer;
  78. module_param(tachometer, int, 0);
  79. MODULE_PARM_DESC(tachometer,
  80. "PCI-WDT501 Fan Tachometer support (0=disable, default=0)");
  81. static int type = 500;
  82. module_param(type, int, 0);
  83. MODULE_PARM_DESC(type,
  84. "PCI-WDT501 Card type (500 or 501 , default=500)");
  85. /*
  86. * Programming support
  87. */
  88. static void wdtpci_ctr_mode(int ctr, int mode)
  89. {
  90. ctr <<= 6;
  91. ctr |= 0x30;
  92. ctr |= (mode << 1);
  93. outb(ctr, WDT_CR);
  94. udelay(8);
  95. }
  96. static void wdtpci_ctr_load(int ctr, int val)
  97. {
  98. outb(val & 0xFF, WDT_COUNT0 + ctr);
  99. udelay(8);
  100. outb(val >> 8, WDT_COUNT0 + ctr);
  101. udelay(8);
  102. }
  103. /**
  104. * wdtpci_start:
  105. *
  106. * Start the watchdog driver.
  107. */
  108. static int wdtpci_start(void)
  109. {
  110. unsigned long flags;
  111. spin_lock_irqsave(&wdtpci_lock, flags);
  112. /*
  113. * "pet" the watchdog, as Access says.
  114. * This resets the clock outputs.
  115. */
  116. inb(WDT_DC); /* Disable watchdog */
  117. udelay(8);
  118. wdtpci_ctr_mode(2, 0); /* Program CTR2 for Mode 0:
  119. Pulse on Terminal Count */
  120. outb(0, WDT_DC); /* Enable watchdog */
  121. udelay(8);
  122. inb(WDT_DC); /* Disable watchdog */
  123. udelay(8);
  124. outb(0, WDT_CLOCK); /* 2.0833MHz clock */
  125. udelay(8);
  126. inb(WDT_BUZZER); /* disable */
  127. udelay(8);
  128. inb(WDT_OPTONOTRST); /* disable */
  129. udelay(8);
  130. inb(WDT_OPTORST); /* disable */
  131. udelay(8);
  132. inb(WDT_PROGOUT); /* disable */
  133. udelay(8);
  134. wdtpci_ctr_mode(0, 3); /* Program CTR0 for Mode 3:
  135. Square Wave Generator */
  136. wdtpci_ctr_mode(1, 2); /* Program CTR1 for Mode 2:
  137. Rate Generator */
  138. wdtpci_ctr_mode(2, 1); /* Program CTR2 for Mode 1:
  139. Retriggerable One-Shot */
  140. wdtpci_ctr_load(0, 20833); /* count at 100Hz */
  141. wdtpci_ctr_load(1, wd_heartbeat);/* Heartbeat */
  142. /* DO NOT LOAD CTR2 on PCI card! -- JPN */
  143. outb(0, WDT_DC); /* Enable watchdog */
  144. udelay(8);
  145. spin_unlock_irqrestore(&wdtpci_lock, flags);
  146. return 0;
  147. }
  148. /**
  149. * wdtpci_stop:
  150. *
  151. * Stop the watchdog driver.
  152. */
  153. static int wdtpci_stop(void)
  154. {
  155. unsigned long flags;
  156. /* Turn the card off */
  157. spin_lock_irqsave(&wdtpci_lock, flags);
  158. inb(WDT_DC); /* Disable watchdog */
  159. udelay(8);
  160. wdtpci_ctr_load(2, 0); /* 0 length reset pulses now */
  161. spin_unlock_irqrestore(&wdtpci_lock, flags);
  162. return 0;
  163. }
  164. /**
  165. * wdtpci_ping:
  166. *
  167. * Reload counter one with the watchdog heartbeat. We don't bother
  168. * reloading the cascade counter.
  169. */
  170. static int wdtpci_ping(void)
  171. {
  172. unsigned long flags;
  173. spin_lock_irqsave(&wdtpci_lock, flags);
  174. /* Write a watchdog value */
  175. inb(WDT_DC); /* Disable watchdog */
  176. udelay(8);
  177. wdtpci_ctr_mode(1, 2); /* Re-Program CTR1 for Mode 2:
  178. Rate Generator */
  179. wdtpci_ctr_load(1, wd_heartbeat);/* Heartbeat */
  180. outb(0, WDT_DC); /* Enable watchdog */
  181. udelay(8);
  182. spin_unlock_irqrestore(&wdtpci_lock, flags);
  183. return 0;
  184. }
  185. /**
  186. * wdtpci_set_heartbeat:
  187. * @t: the new heartbeat value that needs to be set.
  188. *
  189. * Set a new heartbeat value for the watchdog device. If the heartbeat
  190. * value is incorrect we keep the old value and return -EINVAL.
  191. * If successful we return 0.
  192. */
  193. static int wdtpci_set_heartbeat(int t)
  194. {
  195. /* Arbitrary, can't find the card's limits */
  196. if (t < 1 || t > 65535)
  197. return -EINVAL;
  198. heartbeat = t;
  199. wd_heartbeat = t * 100;
  200. return 0;
  201. }
  202. /**
  203. * wdtpci_get_status:
  204. * @status: the new status.
  205. *
  206. * Extract the status information from a WDT watchdog device. There are
  207. * several board variants so we have to know which bits are valid. Some
  208. * bits default to one and some to zero in order to be maximally painful.
  209. *
  210. * we then map the bits onto the status ioctl flags.
  211. */
  212. static int wdtpci_get_status(int *status)
  213. {
  214. unsigned char new_status;
  215. unsigned long flags;
  216. spin_lock_irqsave(&wdtpci_lock, flags);
  217. new_status = inb(WDT_SR);
  218. spin_unlock_irqrestore(&wdtpci_lock, flags);
  219. *status = 0;
  220. if (new_status & WDC_SR_ISOI0)
  221. *status |= WDIOF_EXTERN1;
  222. if (new_status & WDC_SR_ISII1)
  223. *status |= WDIOF_EXTERN2;
  224. if (type == 501) {
  225. if (!(new_status & WDC_SR_TGOOD))
  226. *status |= WDIOF_OVERHEAT;
  227. if (!(new_status & WDC_SR_PSUOVER))
  228. *status |= WDIOF_POWEROVER;
  229. if (!(new_status & WDC_SR_PSUUNDR))
  230. *status |= WDIOF_POWERUNDER;
  231. if (tachometer) {
  232. if (!(new_status & WDC_SR_FANGOOD))
  233. *status |= WDIOF_FANFAULT;
  234. }
  235. }
  236. return 0;
  237. }
  238. /**
  239. * wdtpci_get_temperature:
  240. *
  241. * Reports the temperature in degrees Fahrenheit. The API is in
  242. * farenheit. It was designed by an imperial measurement luddite.
  243. */
  244. static int wdtpci_get_temperature(int *temperature)
  245. {
  246. unsigned short c;
  247. unsigned long flags;
  248. spin_lock_irqsave(&wdtpci_lock, flags);
  249. c = inb(WDT_RT);
  250. udelay(8);
  251. spin_unlock_irqrestore(&wdtpci_lock, flags);
  252. *temperature = (c * 11 / 15) + 7;
  253. return 0;
  254. }
  255. /**
  256. * wdtpci_interrupt:
  257. * @irq: Interrupt number
  258. * @dev_id: Unused as we don't allow multiple devices.
  259. *
  260. * Handle an interrupt from the board. These are raised when the status
  261. * map changes in what the board considers an interesting way. That means
  262. * a failure condition occurring.
  263. */
  264. static irqreturn_t wdtpci_interrupt(int irq, void *dev_id)
  265. {
  266. /*
  267. * Read the status register see what is up and
  268. * then printk it.
  269. */
  270. unsigned char status;
  271. spin_lock(&wdtpci_lock);
  272. status = inb(WDT_SR);
  273. udelay(8);
  274. pr_crit("status %d\n", status);
  275. if (type == 501) {
  276. if (!(status & WDC_SR_TGOOD)) {
  277. pr_crit("Overheat alarm (%d)\n", inb(WDT_RT));
  278. udelay(8);
  279. }
  280. if (!(status & WDC_SR_PSUOVER))
  281. pr_crit("PSU over voltage\n");
  282. if (!(status & WDC_SR_PSUUNDR))
  283. pr_crit("PSU under voltage\n");
  284. if (tachometer) {
  285. if (!(status & WDC_SR_FANGOOD))
  286. pr_crit("Possible fan fault\n");
  287. }
  288. }
  289. if (!(status & WDC_SR_WCCR)) {
  290. #ifdef SOFTWARE_REBOOT
  291. #ifdef ONLY_TESTING
  292. pr_crit("Would Reboot\n");
  293. #else
  294. pr_crit("Initiating system reboot\n");
  295. emergency_restart(NULL);
  296. #endif
  297. #else
  298. pr_crit("Reset in 5ms\n");
  299. #endif
  300. }
  301. spin_unlock(&wdtpci_lock);
  302. return IRQ_HANDLED;
  303. }
  304. /**
  305. * wdtpci_write:
  306. * @file: file handle to the watchdog
  307. * @buf: buffer to write (unused as data does not matter here
  308. * @count: count of bytes
  309. * @ppos: pointer to the position to write. No seeks allowed
  310. *
  311. * A write to a watchdog device is defined as a keepalive signal. Any
  312. * write of data will do, as we we don't define content meaning.
  313. */
  314. static ssize_t wdtpci_write(struct file *file, const char __user *buf,
  315. size_t count, loff_t *ppos)
  316. {
  317. if (count) {
  318. if (!nowayout) {
  319. size_t i;
  320. /* In case it was set long ago */
  321. expect_close = 0;
  322. for (i = 0; i != count; i++) {
  323. char c;
  324. if (get_user(c, buf + i))
  325. return -EFAULT;
  326. if (c == 'V')
  327. expect_close = 42;
  328. }
  329. }
  330. wdtpci_ping();
  331. }
  332. return count;
  333. }
  334. /**
  335. * wdtpci_ioctl:
  336. * @file: file handle to the device
  337. * @cmd: watchdog command
  338. * @arg: argument pointer
  339. *
  340. * The watchdog API defines a common set of functions for all watchdogs
  341. * according to their available features. We only actually usefully support
  342. * querying capabilities and current status.
  343. */
  344. static long wdtpci_ioctl(struct file *file, unsigned int cmd,
  345. unsigned long arg)
  346. {
  347. void __user *argp = (void __user *)arg;
  348. int __user *p = argp;
  349. int new_heartbeat;
  350. int status;
  351. struct watchdog_info ident = {
  352. .options = WDIOF_SETTIMEOUT|
  353. WDIOF_MAGICCLOSE|
  354. WDIOF_KEEPALIVEPING,
  355. .firmware_version = 1,
  356. .identity = "PCI-WDT500/501",
  357. };
  358. /* Add options according to the card we have */
  359. ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
  360. if (type == 501) {
  361. ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|
  362. WDIOF_POWEROVER);
  363. if (tachometer)
  364. ident.options |= WDIOF_FANFAULT;
  365. }
  366. switch (cmd) {
  367. case WDIOC_GETSUPPORT:
  368. return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
  369. case WDIOC_GETSTATUS:
  370. wdtpci_get_status(&status);
  371. return put_user(status, p);
  372. case WDIOC_GETBOOTSTATUS:
  373. return put_user(0, p);
  374. case WDIOC_KEEPALIVE:
  375. wdtpci_ping();
  376. return 0;
  377. case WDIOC_SETTIMEOUT:
  378. if (get_user(new_heartbeat, p))
  379. return -EFAULT;
  380. if (wdtpci_set_heartbeat(new_heartbeat))
  381. return -EINVAL;
  382. wdtpci_ping();
  383. /* Fall */
  384. case WDIOC_GETTIMEOUT:
  385. return put_user(heartbeat, p);
  386. default:
  387. return -ENOTTY;
  388. }
  389. }
  390. /**
  391. * wdtpci_open:
  392. * @inode: inode of device
  393. * @file: file handle to device
  394. *
  395. * The watchdog device has been opened. The watchdog device is single
  396. * open and on opening we load the counters. Counter zero is a 100Hz
  397. * cascade, into counter 1 which downcounts to reboot. When the counter
  398. * triggers counter 2 downcounts the length of the reset pulse which
  399. * set set to be as long as possible.
  400. */
  401. static int wdtpci_open(struct inode *inode, struct file *file)
  402. {
  403. if (test_and_set_bit(0, &open_lock))
  404. return -EBUSY;
  405. if (nowayout)
  406. __module_get(THIS_MODULE);
  407. /*
  408. * Activate
  409. */
  410. wdtpci_start();
  411. return nonseekable_open(inode, file);
  412. }
  413. /**
  414. * wdtpci_release:
  415. * @inode: inode to board
  416. * @file: file handle to board
  417. *
  418. * The watchdog has a configurable API. There is a religious dispute
  419. * between people who want their watchdog to be able to shut down and
  420. * those who want to be sure if the watchdog manager dies the machine
  421. * reboots. In the former case we disable the counters, in the latter
  422. * case you have to open it again very soon.
  423. */
  424. static int wdtpci_release(struct inode *inode, struct file *file)
  425. {
  426. if (expect_close == 42) {
  427. wdtpci_stop();
  428. } else {
  429. pr_crit("Unexpected close, not stopping timer!\n");
  430. wdtpci_ping();
  431. }
  432. expect_close = 0;
  433. clear_bit(0, &open_lock);
  434. return 0;
  435. }
  436. /**
  437. * wdtpci_temp_read:
  438. * @file: file handle to the watchdog board
  439. * @buf: buffer to write 1 byte into
  440. * @count: length of buffer
  441. * @ptr: offset (no seek allowed)
  442. *
  443. * Read reports the temperature in degrees Fahrenheit. The API is in
  444. * fahrenheit. It was designed by an imperial measurement luddite.
  445. */
  446. static ssize_t wdtpci_temp_read(struct file *file, char __user *buf,
  447. size_t count, loff_t *ptr)
  448. {
  449. int temperature;
  450. if (wdtpci_get_temperature(&temperature))
  451. return -EFAULT;
  452. if (copy_to_user(buf, &temperature, 1))
  453. return -EFAULT;
  454. return 1;
  455. }
  456. /**
  457. * wdtpci_temp_open:
  458. * @inode: inode of device
  459. * @file: file handle to device
  460. *
  461. * The temperature device has been opened.
  462. */
  463. static int wdtpci_temp_open(struct inode *inode, struct file *file)
  464. {
  465. return nonseekable_open(inode, file);
  466. }
  467. /**
  468. * wdtpci_temp_release:
  469. * @inode: inode to board
  470. * @file: file handle to board
  471. *
  472. * The temperature device has been closed.
  473. */
  474. static int wdtpci_temp_release(struct inode *inode, struct file *file)
  475. {
  476. return 0;
  477. }
  478. /**
  479. * notify_sys:
  480. * @this: our notifier block
  481. * @code: the event being reported
  482. * @unused: unused
  483. *
  484. * Our notifier is called on system shutdowns. We want to turn the card
  485. * off at reboot otherwise the machine will reboot again during memory
  486. * test or worse yet during the following fsck. This would suck, in fact
  487. * trust me - if it happens it does suck.
  488. */
  489. static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
  490. void *unused)
  491. {
  492. if (code == SYS_DOWN || code == SYS_HALT)
  493. wdtpci_stop();
  494. return NOTIFY_DONE;
  495. }
  496. /*
  497. * Kernel Interfaces
  498. */
  499. static const struct file_operations wdtpci_fops = {
  500. .owner = THIS_MODULE,
  501. .llseek = no_llseek,
  502. .write = wdtpci_write,
  503. .unlocked_ioctl = wdtpci_ioctl,
  504. .open = wdtpci_open,
  505. .release = wdtpci_release,
  506. };
  507. static struct miscdevice wdtpci_miscdev = {
  508. .minor = WATCHDOG_MINOR,
  509. .name = "watchdog",
  510. .fops = &wdtpci_fops,
  511. };
  512. static const struct file_operations wdtpci_temp_fops = {
  513. .owner = THIS_MODULE,
  514. .llseek = no_llseek,
  515. .read = wdtpci_temp_read,
  516. .open = wdtpci_temp_open,
  517. .release = wdtpci_temp_release,
  518. };
  519. static struct miscdevice temp_miscdev = {
  520. .minor = TEMP_MINOR,
  521. .name = "temperature",
  522. .fops = &wdtpci_temp_fops,
  523. };
  524. /*
  525. * The WDT card needs to learn about soft shutdowns in order to
  526. * turn the timebomb registers off.
  527. */
  528. static struct notifier_block wdtpci_notifier = {
  529. .notifier_call = wdtpci_notify_sys,
  530. };
  531. static int wdtpci_init_one(struct pci_dev *dev,
  532. const struct pci_device_id *ent)
  533. {
  534. int ret = -EIO;
  535. dev_count++;
  536. if (dev_count > 1) {
  537. pr_err("This driver only supports one device\n");
  538. return -ENODEV;
  539. }
  540. if (type != 500 && type != 501) {
  541. pr_err("unknown card type '%d'\n", type);
  542. return -ENODEV;
  543. }
  544. if (pci_enable_device(dev)) {
  545. pr_err("Not possible to enable PCI Device\n");
  546. return -ENODEV;
  547. }
  548. if (pci_resource_start(dev, 2) == 0x0000) {
  549. pr_err("No I/O-Address for card detected\n");
  550. ret = -ENODEV;
  551. goto out_pci;
  552. }
  553. if (pci_request_region(dev, 2, "wdt_pci")) {
  554. pr_err("I/O address 0x%llx already in use\n",
  555. (unsigned long long)pci_resource_start(dev, 2));
  556. goto out_pci;
  557. }
  558. irq = dev->irq;
  559. io = pci_resource_start(dev, 2);
  560. if (request_irq(irq, wdtpci_interrupt, IRQF_SHARED,
  561. "wdt_pci", &wdtpci_miscdev)) {
  562. pr_err("IRQ %d is not free\n", irq);
  563. goto out_reg;
  564. }
  565. pr_info("PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%llx (Interrupt %d)\n",
  566. (unsigned long long)io, irq);
  567. /* Check that the heartbeat value is within its range;
  568. if not reset to the default */
  569. if (wdtpci_set_heartbeat(heartbeat)) {
  570. wdtpci_set_heartbeat(WD_TIMO);
  571. pr_info("heartbeat value must be 0 < heartbeat < 65536, using %d\n",
  572. WD_TIMO);
  573. }
  574. ret = register_reboot_notifier(&wdtpci_notifier);
  575. if (ret) {
  576. pr_err("cannot register reboot notifier (err=%d)\n", ret);
  577. goto out_irq;
  578. }
  579. if (type == 501) {
  580. ret = misc_register(&temp_miscdev);
  581. if (ret) {
  582. pr_err("cannot register miscdev on minor=%d (err=%d)\n",
  583. TEMP_MINOR, ret);
  584. goto out_rbt;
  585. }
  586. }
  587. ret = misc_register(&wdtpci_miscdev);
  588. if (ret) {
  589. pr_err("cannot register miscdev on minor=%d (err=%d)\n",
  590. WATCHDOG_MINOR, ret);
  591. goto out_misc;
  592. }
  593. pr_info("initialized. heartbeat=%d sec (nowayout=%d)\n",
  594. heartbeat, nowayout);
  595. if (type == 501)
  596. pr_info("Fan Tachometer is %s\n",
  597. tachometer ? "Enabled" : "Disabled");
  598. ret = 0;
  599. out:
  600. return ret;
  601. out_misc:
  602. if (type == 501)
  603. misc_deregister(&temp_miscdev);
  604. out_rbt:
  605. unregister_reboot_notifier(&wdtpci_notifier);
  606. out_irq:
  607. free_irq(irq, &wdtpci_miscdev);
  608. out_reg:
  609. pci_release_region(dev, 2);
  610. out_pci:
  611. pci_disable_device(dev);
  612. goto out;
  613. }
  614. static void wdtpci_remove_one(struct pci_dev *pdev)
  615. {
  616. /* here we assume only one device will ever have
  617. * been picked up and registered by probe function */
  618. misc_deregister(&wdtpci_miscdev);
  619. if (type == 501)
  620. misc_deregister(&temp_miscdev);
  621. unregister_reboot_notifier(&wdtpci_notifier);
  622. free_irq(irq, &wdtpci_miscdev);
  623. pci_release_region(pdev, 2);
  624. pci_disable_device(pdev);
  625. dev_count--;
  626. }
  627. static const struct pci_device_id wdtpci_pci_tbl[] = {
  628. {
  629. .vendor = PCI_VENDOR_ID_ACCESSIO,
  630. .device = PCI_DEVICE_ID_ACCESSIO_WDG_CSM,
  631. .subvendor = PCI_ANY_ID,
  632. .subdevice = PCI_ANY_ID,
  633. },
  634. { 0, }, /* terminate list */
  635. };
  636. MODULE_DEVICE_TABLE(pci, wdtpci_pci_tbl);
  637. static struct pci_driver wdtpci_driver = {
  638. .name = "wdt_pci",
  639. .id_table = wdtpci_pci_tbl,
  640. .probe = wdtpci_init_one,
  641. .remove = wdtpci_remove_one,
  642. };
  643. module_pci_driver(wdtpci_driver);
  644. MODULE_AUTHOR("JP Nollmann, Alan Cox");
  645. MODULE_DESCRIPTION("Driver for the ICS PCI-WDT500/501 watchdog cards");
  646. MODULE_LICENSE("GPL");