Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux...
[pandora-kernel.git] / drivers / char / watchdog / wdt_pci.c
1 /*
2  *      Industrial Computer Source PCI-WDT500/501 driver
3  *
4  *      (c) Copyright 1996-1997 Alan Cox <alan@redhat.com>, All Rights Reserved.
5  *                              http://www.redhat.com
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 failures
33  *              Joel Becker     :       Added WDIOC_GET/SETTIMEOUT
34  *              Zwane Mwaikambo :       Magic char closing, locking changes, cleanups
35  *              Matt Domsch     :       nowayout module option
36  */
37
38 #include <linux/interrupt.h>
39 #include <linux/module.h>
40 #include <linux/moduleparam.h>
41 #include <linux/types.h>
42 #include <linux/miscdevice.h>
43 #include <linux/watchdog.h>
44 #include <linux/ioport.h>
45 #include <linux/notifier.h>
46 #include <linux/reboot.h>
47 #include <linux/init.h>
48 #include <linux/fs.h>
49 #include <linux/pci.h>
50
51 #include <asm/io.h>
52 #include <asm/uaccess.h>
53 #include <asm/system.h>
54
55 #define WDT_IS_PCI
56 #include "wd501p.h"
57
58 #define PFX "wdt_pci: "
59
60 /*
61  * Until Access I/O gets their application for a PCI vendor ID approved,
62  * I don't think that it's appropriate to move these constants into the
63  * regular pci_ids.h file. -- JPN 2000/01/18
64  */
65
66 #ifndef PCI_VENDOR_ID_ACCESSIO
67 #define PCI_VENDOR_ID_ACCESSIO 0x494f
68 #endif
69 #ifndef PCI_DEVICE_ID_WDG_CSM
70 #define PCI_DEVICE_ID_WDG_CSM 0x22c0
71 #endif
72
73 /* We can only use 1 card due to the /dev/watchdog restriction */
74 static int dev_count;
75
76 static struct semaphore open_sem;
77 static spinlock_t wdtpci_lock;
78 static char expect_close;
79
80 static int io;
81 static int irq;
82
83 /* Default timeout */
84 #define WD_TIMO 60                      /* Default heartbeat = 60 seconds */
85
86 static int heartbeat = WD_TIMO;
87 static int wd_heartbeat;
88 module_param(heartbeat, int, 0);
89 MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds. (0<heartbeat<65536, default=" __MODULE_STRING(WD_TIMO) ")");
90
91 static int nowayout = WATCHDOG_NOWAYOUT;
92 module_param(nowayout, int, 0);
93 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)");
94
95 #ifdef CONFIG_WDT_501_PCI
96 /* Support for the Fan Tachometer on the PCI-WDT501 */
97 static int tachometer;
98
99 module_param(tachometer, int, 0);
100 MODULE_PARM_DESC(tachometer, "PCI-WDT501 Fan Tachometer support (0=disable, default=0)");
101 #endif /* CONFIG_WDT_501_PCI */
102
103 /*
104  *      Programming support
105  */
106
107 static void wdtpci_ctr_mode(int ctr, int mode)
108 {
109         ctr<<=6;
110         ctr|=0x30;
111         ctr|=(mode<<1);
112         outb_p(ctr, WDT_CR);
113 }
114
115 static void wdtpci_ctr_load(int ctr, int val)
116 {
117         outb_p(val&0xFF, WDT_COUNT0+ctr);
118         outb_p(val>>8, WDT_COUNT0+ctr);
119 }
120
121 /**
122  *      wdtpci_start:
123  *
124  *      Start the watchdog driver.
125  */
126
127 static int wdtpci_start(void)
128 {
129         unsigned long flags;
130
131         spin_lock_irqsave(&wdtpci_lock, flags);
132
133         /*
134          * "pet" the watchdog, as Access says.
135          * This resets the clock outputs.
136          */
137         inb_p(WDT_DC);                  /* Disable watchdog */
138         wdtpci_ctr_mode(2,0);           /* Program CTR2 for Mode 0: Pulse on Terminal Count */
139         outb_p(0, WDT_DC);              /* Enable watchdog */
140
141         inb_p(WDT_DC);                  /* Disable watchdog */
142         outb_p(0, WDT_CLOCK);           /* 2.0833MHz clock */
143         inb_p(WDT_BUZZER);              /* disable */
144         inb_p(WDT_OPTONOTRST);          /* disable */
145         inb_p(WDT_OPTORST);             /* disable */
146         inb_p(WDT_PROGOUT);             /* disable */
147         wdtpci_ctr_mode(0,3);           /* Program CTR0 for Mode 3: Square Wave Generator */
148         wdtpci_ctr_mode(1,2);           /* Program CTR1 for Mode 2: Rate Generator */
149         wdtpci_ctr_mode(2,1);           /* Program CTR2 for Mode 1: Retriggerable One-Shot */
150         wdtpci_ctr_load(0,20833);       /* count at 100Hz */
151         wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */
152         /* DO NOT LOAD CTR2 on PCI card! -- JPN */
153         outb_p(0, WDT_DC);              /* Enable watchdog */
154
155         spin_unlock_irqrestore(&wdtpci_lock, flags);
156         return 0;
157 }
158
159 /**
160  *      wdtpci_stop:
161  *
162  *      Stop the watchdog driver.
163  */
164
165 static int wdtpci_stop (void)
166 {
167         unsigned long flags;
168
169         /* Turn the card off */
170         spin_lock_irqsave(&wdtpci_lock, flags);
171         inb_p(WDT_DC);                  /* Disable watchdog */
172         wdtpci_ctr_load(2,0);           /* 0 length reset pulses now */
173         spin_unlock_irqrestore(&wdtpci_lock, flags);
174         return 0;
175 }
176
177 /**
178  *      wdtpci_ping:
179  *
180  *      Reload counter one with the watchdog heartbeat. We don't bother reloading
181  *      the cascade counter.
182  */
183
184 static int wdtpci_ping(void)
185 {
186         unsigned long flags;
187
188         /* Write a watchdog value */
189         spin_lock_irqsave(&wdtpci_lock, flags);
190         inb_p(WDT_DC);                  /* Disable watchdog */
191         wdtpci_ctr_mode(1,2);           /* Re-Program CTR1 for Mode 2: Rate Generator */
192         wdtpci_ctr_load(1,wd_heartbeat);/* Heartbeat */
193         outb_p(0, WDT_DC);              /* Enable watchdog */
194         spin_unlock_irqrestore(&wdtpci_lock, flags);
195         return 0;
196 }
197
198 /**
199  *      wdtpci_set_heartbeat:
200  *      @t:             the new heartbeat value that needs to be set.
201  *
202  *      Set a new heartbeat value for the watchdog device. If the heartbeat value is
203  *      incorrect we keep the old value and return -EINVAL. If successfull we
204  *      return 0.
205  */
206 static int wdtpci_set_heartbeat(int t)
207 {
208         /* Arbitrary, can't find the card's limits */
209         if ((t < 1) || (t > 65535))
210                 return -EINVAL;
211
212         heartbeat = t;
213         wd_heartbeat = t * 100;
214         return 0;
215 }
216
217 /**
218  *      wdtpci_get_status:
219  *      @status:                the new status.
220  *
221  *      Extract the status information from a WDT watchdog device. There are
222  *      several board variants so we have to know which bits are valid. Some
223  *      bits default to one and some to zero in order to be maximally painful.
224  *
225  *      we then map the bits onto the status ioctl flags.
226  */
227
228 static int wdtpci_get_status(int *status)
229 {
230         unsigned char new_status=inb_p(WDT_SR);
231
232         *status=0;
233         if (new_status & WDC_SR_ISOI0)
234                 *status |= WDIOF_EXTERN1;
235         if (new_status & WDC_SR_ISII1)
236                 *status |= WDIOF_EXTERN2;
237 #ifdef CONFIG_WDT_501_PCI
238         if (!(new_status & WDC_SR_TGOOD))
239                 *status |= WDIOF_OVERHEAT;
240         if (!(new_status & WDC_SR_PSUOVER))
241                 *status |= WDIOF_POWEROVER;
242         if (!(new_status & WDC_SR_PSUUNDR))
243                 *status |= WDIOF_POWERUNDER;
244         if (tachometer) {
245                 if (!(new_status & WDC_SR_FANGOOD))
246                         *status |= WDIOF_FANFAULT;
247         }
248 #endif /* CONFIG_WDT_501_PCI */
249         return 0;
250 }
251
252 #ifdef CONFIG_WDT_501_PCI
253 /**
254  *      wdtpci_get_temperature:
255  *
256  *      Reports the temperature in degrees Fahrenheit. The API is in
257  *      farenheit. It was designed by an imperial measurement luddite.
258  */
259
260 static int wdtpci_get_temperature(int *temperature)
261 {
262         unsigned short c=inb_p(WDT_RT);
263
264         *temperature = (c * 11 / 15) + 7;
265         return 0;
266 }
267 #endif /* CONFIG_WDT_501_PCI */
268
269 /**
270  *      wdtpci_interrupt:
271  *      @irq:           Interrupt number
272  *      @dev_id:        Unused as we don't allow multiple devices.
273  *      @regs:          Unused.
274  *
275  *      Handle an interrupt from the board. These are raised when the status
276  *      map changes in what the board considers an interesting way. That means
277  *      a failure condition occurring.
278  */
279
280 static irqreturn_t wdtpci_interrupt(int irq, void *dev_id, struct pt_regs *regs)
281 {
282         /*
283          *      Read the status register see what is up and
284          *      then printk it.
285          */
286         unsigned char status=inb_p(WDT_SR);
287
288         printk(KERN_CRIT PFX "status %d\n", status);
289
290 #ifdef CONFIG_WDT_501_PCI
291         if (!(status & WDC_SR_TGOOD))
292                 printk(KERN_CRIT PFX "Overheat alarm.(%d)\n",inb_p(WDT_RT));
293         if (!(status & WDC_SR_PSUOVER))
294                 printk(KERN_CRIT PFX "PSU over voltage.\n");
295         if (!(status & WDC_SR_PSUUNDR))
296                 printk(KERN_CRIT PFX "PSU under voltage.\n");
297         if (tachometer) {
298                 if (!(status & WDC_SR_FANGOOD))
299                         printk(KERN_CRIT PFX "Possible fan fault.\n");
300         }
301 #endif /* CONFIG_WDT_501_PCI */
302         if (!(status&WDC_SR_WCCR))
303 #ifdef SOFTWARE_REBOOT
304 #ifdef ONLY_TESTING
305                 printk(KERN_CRIT PFX "Would Reboot.\n");
306 #else
307                 printk(KERN_CRIT PFX "Initiating system reboot.\n");
308                 emergency_restart(NULL);
309 #endif
310 #else
311                 printk(KERN_CRIT PFX "Reset in 5ms.\n");
312 #endif
313         return IRQ_HANDLED;
314 }
315
316
317 /**
318  *      wdtpci_write:
319  *      @file: file handle to the watchdog
320  *      @buf: buffer to write (unused as data does not matter here
321  *      @count: count of bytes
322  *      @ppos: pointer to the position to write. No seeks allowed
323  *
324  *      A write to a watchdog device is defined as a keepalive signal. Any
325  *      write of data will do, as we we don't define content meaning.
326  */
327
328 static ssize_t wdtpci_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
329 {
330         if (count) {
331                 if (!nowayout) {
332                         size_t i;
333
334                         expect_close = 0;
335
336                         for (i = 0; i != count; i++) {
337                                 char c;
338                                 if(get_user(c, buf+i))
339                                         return -EFAULT;
340                                 if (c == 'V')
341                                         expect_close = 42;
342                         }
343                 }
344                 wdtpci_ping();
345         }
346
347         return count;
348 }
349
350 /**
351  *      wdtpci_ioctl:
352  *      @inode: inode of the device
353  *      @file: file handle to the device
354  *      @cmd: watchdog command
355  *      @arg: argument pointer
356  *
357  *      The watchdog API defines a common set of functions for all watchdogs
358  *      according to their available features. We only actually usefully support
359  *      querying capabilities and current status.
360  */
361
362 static int wdtpci_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
363         unsigned long arg)
364 {
365         int new_heartbeat;
366         int status;
367         void __user *argp = (void __user *)arg;
368         int __user *p = argp;
369
370         static struct watchdog_info ident = {
371                 .options =              WDIOF_SETTIMEOUT|
372                                         WDIOF_MAGICCLOSE|
373                                         WDIOF_KEEPALIVEPING,
374                 .firmware_version =     1,
375                 .identity =             "PCI-WDT500/501",
376         };
377
378         /* Add options according to the card we have */
379         ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
380 #ifdef CONFIG_WDT_501_PCI
381         ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER);
382         if (tachometer)
383                 ident.options |= WDIOF_FANFAULT;
384 #endif /* CONFIG_WDT_501_PCI */
385
386         switch(cmd)
387         {
388                 default:
389                         return -ENOIOCTLCMD;
390                 case WDIOC_GETSUPPORT:
391                         return copy_to_user(argp, &ident, sizeof(ident))?-EFAULT:0;
392
393                 case WDIOC_GETSTATUS:
394                         wdtpci_get_status(&status);
395                         return put_user(status, p);
396                 case WDIOC_GETBOOTSTATUS:
397                         return put_user(0, p);
398                 case WDIOC_KEEPALIVE:
399                         wdtpci_ping();
400                         return 0;
401                 case WDIOC_SETTIMEOUT:
402                         if (get_user(new_heartbeat, p))
403                                 return -EFAULT;
404
405                         if (wdtpci_set_heartbeat(new_heartbeat))
406                                 return -EINVAL;
407
408                         wdtpci_ping();
409                         /* Fall */
410                 case WDIOC_GETTIMEOUT:
411                         return put_user(heartbeat, p);
412         }
413 }
414
415 /**
416  *      wdtpci_open:
417  *      @inode: inode of device
418  *      @file: file handle to device
419  *
420  *      The watchdog device has been opened. The watchdog device is single
421  *      open and on opening we load the counters. Counter zero is a 100Hz
422  *      cascade, into counter 1 which downcounts to reboot. When the counter
423  *      triggers counter 2 downcounts the length of the reset pulse which
424  *      set set to be as long as possible.
425  */
426
427 static int wdtpci_open(struct inode *inode, struct file *file)
428 {
429         if (down_trylock(&open_sem))
430                 return -EBUSY;
431
432         if (nowayout) {
433                 __module_get(THIS_MODULE);
434         }
435         /*
436          *      Activate
437          */
438         wdtpci_start();
439         return nonseekable_open(inode, file);
440 }
441
442 /**
443  *      wdtpci_release:
444  *      @inode: inode to board
445  *      @file: file handle to board
446  *
447  *      The watchdog has a configurable API. There is a religious dispute
448  *      between people who want their watchdog to be able to shut down and
449  *      those who want to be sure if the watchdog manager dies the machine
450  *      reboots. In the former case we disable the counters, in the latter
451  *      case you have to open it again very soon.
452  */
453
454 static int wdtpci_release(struct inode *inode, struct file *file)
455 {
456         if (expect_close == 42) {
457                 wdtpci_stop();
458         } else {
459                 printk(KERN_CRIT PFX "Unexpected close, not stopping timer!");
460                 wdtpci_ping();
461         }
462         expect_close = 0;
463         up(&open_sem);
464         return 0;
465 }
466
467 #ifdef CONFIG_WDT_501_PCI
468 /**
469  *      wdtpci_temp_read:
470  *      @file: file handle to the watchdog board
471  *      @buf: buffer to write 1 byte into
472  *      @count: length of buffer
473  *      @ptr: offset (no seek allowed)
474  *
475  *      Read reports the temperature in degrees Fahrenheit. The API is in
476  *      fahrenheit. It was designed by an imperial measurement luddite.
477  */
478
479 static ssize_t wdtpci_temp_read(struct file *file, char __user *buf, size_t count, loff_t *ptr)
480 {
481         int temperature;
482
483         if (wdtpci_get_temperature(&temperature))
484                 return -EFAULT;
485
486         if (copy_to_user (buf, &temperature, 1))
487                 return -EFAULT;
488
489         return 1;
490 }
491
492 /**
493  *      wdtpci_temp_open:
494  *      @inode: inode of device
495  *      @file: file handle to device
496  *
497  *      The temperature device has been opened.
498  */
499
500 static int wdtpci_temp_open(struct inode *inode, struct file *file)
501 {
502         return nonseekable_open(inode, file);
503 }
504
505 /**
506  *      wdtpci_temp_release:
507  *      @inode: inode to board
508  *      @file: file handle to board
509  *
510  *      The temperature device has been closed.
511  */
512
513 static int wdtpci_temp_release(struct inode *inode, struct file *file)
514 {
515         return 0;
516 }
517 #endif /* CONFIG_WDT_501_PCI */
518
519 /**
520  *      notify_sys:
521  *      @this: our notifier block
522  *      @code: the event being reported
523  *      @unused: unused
524  *
525  *      Our notifier is called on system shutdowns. We want to turn the card
526  *      off at reboot otherwise the machine will reboot again during memory
527  *      test or worse yet during the following fsck. This would suck, in fact
528  *      trust me - if it happens it does suck.
529  */
530
531 static int wdtpci_notify_sys(struct notifier_block *this, unsigned long code,
532         void *unused)
533 {
534         if (code==SYS_DOWN || code==SYS_HALT) {
535                 /* Turn the card off */
536                 wdtpci_stop();
537         }
538         return NOTIFY_DONE;
539 }
540
541 /*
542  *      Kernel Interfaces
543  */
544
545
546 static const struct file_operations wdtpci_fops = {
547         .owner          = THIS_MODULE,
548         .llseek         = no_llseek,
549         .write          = wdtpci_write,
550         .ioctl          = wdtpci_ioctl,
551         .open           = wdtpci_open,
552         .release        = wdtpci_release,
553 };
554
555 static struct miscdevice wdtpci_miscdev = {
556         .minor  = WATCHDOG_MINOR,
557         .name   = "watchdog",
558         .fops   = &wdtpci_fops,
559 };
560
561 #ifdef CONFIG_WDT_501_PCI
562 static const struct file_operations wdtpci_temp_fops = {
563         .owner          = THIS_MODULE,
564         .llseek         = no_llseek,
565         .read           = wdtpci_temp_read,
566         .open           = wdtpci_temp_open,
567         .release        = wdtpci_temp_release,
568 };
569
570 static struct miscdevice temp_miscdev = {
571         .minor  = TEMP_MINOR,
572         .name   = "temperature",
573         .fops   = &wdtpci_temp_fops,
574 };
575 #endif /* CONFIG_WDT_501_PCI */
576
577 /*
578  *      The WDT card needs to learn about soft shutdowns in order to
579  *      turn the timebomb registers off.
580  */
581
582 static struct notifier_block wdtpci_notifier = {
583         .notifier_call = wdtpci_notify_sys,
584 };
585
586
587 static int __devinit wdtpci_init_one (struct pci_dev *dev,
588                                    const struct pci_device_id *ent)
589 {
590         int ret = -EIO;
591
592         dev_count++;
593         if (dev_count > 1) {
594                 printk (KERN_ERR PFX "this driver only supports 1 device\n");
595                 return -ENODEV;
596         }
597
598         if (pci_enable_device (dev)) {
599                 printk (KERN_ERR PFX "Not possible to enable PCI Device\n");
600                 return -ENODEV;
601         }
602
603         if (pci_resource_start (dev, 2) == 0x0000) {
604                 printk (KERN_ERR PFX "No I/O-Address for card detected\n");
605                 ret = -ENODEV;
606                 goto out_pci;
607         }
608
609         sema_init(&open_sem, 1);
610         spin_lock_init(&wdtpci_lock);
611
612         irq = dev->irq;
613         io = pci_resource_start (dev, 2);
614
615         if (request_region (io, 16, "wdt_pci") == NULL) {
616                 printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", io);
617                 goto out_pci;
618         }
619
620         if (request_irq (irq, wdtpci_interrupt, IRQF_DISABLED | IRQF_SHARED,
621                          "wdt_pci", &wdtpci_miscdev)) {
622                 printk (KERN_ERR PFX "IRQ %d is not free\n", irq);
623                 goto out_reg;
624         }
625
626         printk ("PCI-WDT500/501 (PCI-WDG-CSM) driver 0.10 at 0x%04x (Interrupt %d)\n",
627                 io, irq);
628
629         /* Check that the heartbeat value is within it's range ; if not reset to the default */
630         if (wdtpci_set_heartbeat(heartbeat)) {
631                 wdtpci_set_heartbeat(WD_TIMO);
632                 printk(KERN_INFO PFX "heartbeat value must be 0<heartbeat<65536, using %d\n",
633                         WD_TIMO);
634         }
635
636         ret = register_reboot_notifier (&wdtpci_notifier);
637         if (ret) {
638                 printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n", ret);
639                 goto out_irq;
640         }
641
642 #ifdef CONFIG_WDT_501_PCI
643         ret = misc_register (&temp_miscdev);
644         if (ret) {
645                 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
646                         TEMP_MINOR, ret);
647                 goto out_rbt;
648         }
649 #endif /* CONFIG_WDT_501_PCI */
650
651         ret = misc_register (&wdtpci_miscdev);
652         if (ret) {
653                 printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
654                         WATCHDOG_MINOR, ret);
655                 goto out_misc;
656         }
657
658         printk(KERN_INFO PFX "initialized. heartbeat=%d sec (nowayout=%d)\n",
659                 heartbeat, nowayout);
660 #ifdef CONFIG_WDT_501_PCI
661         printk(KERN_INFO "wdt: Fan Tachometer is %s\n", (tachometer ? "Enabled" : "Disabled"));
662 #endif /* CONFIG_WDT_501_PCI */
663
664         ret = 0;
665 out:
666         return ret;
667
668 out_misc:
669 #ifdef CONFIG_WDT_501_PCI
670         misc_deregister(&temp_miscdev);
671 out_rbt:
672 #endif /* CONFIG_WDT_501_PCI */
673         unregister_reboot_notifier(&wdtpci_notifier);
674 out_irq:
675         free_irq(irq, &wdtpci_miscdev);
676 out_reg:
677         release_region (io, 16);
678 out_pci:
679         pci_disable_device(dev);
680         goto out;
681 }
682
683
684 static void __devexit wdtpci_remove_one (struct pci_dev *pdev)
685 {
686         /* here we assume only one device will ever have
687          * been picked up and registered by probe function */
688         misc_deregister(&wdtpci_miscdev);
689 #ifdef CONFIG_WDT_501_PCI
690         misc_deregister(&temp_miscdev);
691 #endif /* CONFIG_WDT_501_PCI */
692         unregister_reboot_notifier(&wdtpci_notifier);
693         free_irq(irq, &wdtpci_miscdev);
694         release_region(io, 16);
695         pci_disable_device(pdev);
696         dev_count--;
697 }
698
699
700 static struct pci_device_id wdtpci_pci_tbl[] = {
701         {
702                 .vendor    = PCI_VENDOR_ID_ACCESSIO,
703                 .device    = PCI_DEVICE_ID_WDG_CSM,
704                 .subvendor = PCI_ANY_ID,
705                 .subdevice = PCI_ANY_ID,
706         },
707         { 0, }, /* terminate list */
708 };
709 MODULE_DEVICE_TABLE(pci, wdtpci_pci_tbl);
710
711
712 static struct pci_driver wdtpci_driver = {
713         .name           = "wdt_pci",
714         .id_table       = wdtpci_pci_tbl,
715         .probe          = wdtpci_init_one,
716         .remove         = __devexit_p(wdtpci_remove_one),
717 };
718
719
720 /**
721  *      wdtpci_cleanup:
722  *
723  *      Unload the watchdog. You cannot do this with any file handles open.
724  *      If your watchdog is set to continue ticking on close and you unload
725  *      it, well it keeps ticking. We won't get the interrupt but the board
726  *      will not touch PC memory so all is fine. You just have to load a new
727  *      module in xx seconds or reboot.
728  */
729
730 static void __exit wdtpci_cleanup(void)
731 {
732         pci_unregister_driver (&wdtpci_driver);
733 }
734
735
736 /**
737  *      wdtpci_init:
738  *
739  *      Set up the WDT watchdog board. All we have to do is grab the
740  *      resources we require and bitch if anyone beat us to them.
741  *      The open() function will actually kick the board off.
742  */
743
744 static int __init wdtpci_init(void)
745 {
746         return pci_register_driver (&wdtpci_driver);
747 }
748
749
750 module_init(wdtpci_init);
751 module_exit(wdtpci_cleanup);
752
753 MODULE_AUTHOR("JP Nollmann, Alan Cox");
754 MODULE_DESCRIPTION("Driver for the ICS PCI-WDT500/501 watchdog cards");
755 MODULE_LICENSE("GPL");
756 MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
757 MODULE_ALIAS_MISCDEV(TEMP_MINOR);