wdt_pci.c 17 KB

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