[WATCHDOG] wdt.c: remove #ifdef CONFIG_WDT_501
Change the wdt.c watchdog driver so that the code is the same for both the WDT500 as the WDT501-P card. The selection of the card is now being done via the module parameter: 'type' instead of the config option CONFIG_WDT_501. Signed-off-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
278aefc51b
commit
04bedfa542
|
@ -940,21 +940,6 @@ config WDT
|
||||||
To compile this driver as a module, choose M here: the
|
To compile this driver as a module, choose M here: the
|
||||||
module will be called wdt.
|
module will be called wdt.
|
||||||
|
|
||||||
config WDT_501
|
|
||||||
bool "WDT501 features"
|
|
||||||
depends on WDT
|
|
||||||
help
|
|
||||||
Saying Y here and creating a character special file /dev/temperature
|
|
||||||
with major number 10 and minor number 131 ("man mknod") will give
|
|
||||||
you a thermometer inside your computer: reading from
|
|
||||||
/dev/temperature yields one byte, the temperature in degrees
|
|
||||||
Fahrenheit. This works only if you have a WDT501P watchdog board
|
|
||||||
installed.
|
|
||||||
|
|
||||||
If you want to enable the Fan Tachometer on the WDT501P, then you
|
|
||||||
can do this via the tachometer parameter. Only do this if you have a
|
|
||||||
fan tachometer actually set up.
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# PCI-based Watchdog Cards
|
# PCI-based Watchdog Cards
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Industrial Computer Source WDT500/501 driver
|
* Industrial Computer Source WDT501 driver
|
||||||
*
|
*
|
||||||
* (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
|
* (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
|
||||||
* All Rights Reserved.
|
* All Rights Reserved.
|
||||||
|
@ -82,14 +82,16 @@ MODULE_PARM_DESC(io, "WDT io port (default=0x240)");
|
||||||
module_param(irq, int, 0);
|
module_param(irq, int, 0);
|
||||||
MODULE_PARM_DESC(irq, "WDT irq (default=11)");
|
MODULE_PARM_DESC(irq, "WDT irq (default=11)");
|
||||||
|
|
||||||
#ifdef CONFIG_WDT_501
|
|
||||||
/* Support for the Fan Tachometer on the WDT501-P */
|
/* Support for the Fan Tachometer on the WDT501-P */
|
||||||
static int tachometer;
|
static int tachometer;
|
||||||
|
|
||||||
module_param(tachometer, int, 0);
|
module_param(tachometer, int, 0);
|
||||||
MODULE_PARM_DESC(tachometer,
|
MODULE_PARM_DESC(tachometer,
|
||||||
"WDT501-P Fan Tachometer support (0=disable, default=0)");
|
"WDT501-P Fan Tachometer support (0=disable, default=0)");
|
||||||
#endif /* CONFIG_WDT_501 */
|
|
||||||
|
static int type = 500;
|
||||||
|
module_param(type, int, 0);
|
||||||
|
MODULE_PARM_DESC(type,
|
||||||
|
"WDT501-P Card type (500 or 501 , default=500)");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Programming support
|
* Programming support
|
||||||
|
@ -158,7 +160,7 @@ static int wdt_stop(void)
|
||||||
* reloading the cascade counter.
|
* reloading the cascade counter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int wdt_ping(void)
|
static void wdt_ping(void)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
spin_lock_irqsave(&wdt_lock, flags);
|
spin_lock_irqsave(&wdt_lock, flags);
|
||||||
|
@ -169,7 +171,6 @@ static int wdt_ping(void)
|
||||||
wdt_ctr_load(1, wd_heartbeat); /* Heartbeat */
|
wdt_ctr_load(1, wd_heartbeat); /* Heartbeat */
|
||||||
outb_p(0, WDT_DC); /* Enable watchdog */
|
outb_p(0, WDT_DC); /* Enable watchdog */
|
||||||
spin_unlock_irqrestore(&wdt_lock, flags);
|
spin_unlock_irqrestore(&wdt_lock, flags);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -193,7 +194,6 @@ static int wdt_set_heartbeat(int t)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wdt_get_status:
|
* wdt_get_status:
|
||||||
* @status: the new status.
|
|
||||||
*
|
*
|
||||||
* Extract the status information from a WDT watchdog device. There are
|
* Extract the status information from a WDT watchdog device. There are
|
||||||
* several board variants so we have to know which bits are valid. Some
|
* several board variants so we have to know which bits are valid. Some
|
||||||
|
@ -202,36 +202,35 @@ static int wdt_set_heartbeat(int t)
|
||||||
* we then map the bits onto the status ioctl flags.
|
* we then map the bits onto the status ioctl flags.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int wdt_get_status(int *status)
|
static int wdt_get_status(void)
|
||||||
{
|
{
|
||||||
unsigned char new_status;
|
unsigned char new_status;
|
||||||
|
int status = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&wdt_lock, flags);
|
spin_lock_irqsave(&wdt_lock, flags);
|
||||||
new_status = inb_p(WDT_SR);
|
new_status = inb_p(WDT_SR);
|
||||||
spin_unlock_irqrestore(&wdt_lock, flags);
|
spin_unlock_irqrestore(&wdt_lock, flags);
|
||||||
|
|
||||||
*status = 0;
|
|
||||||
if (new_status & WDC_SR_ISOI0)
|
if (new_status & WDC_SR_ISOI0)
|
||||||
*status |= WDIOF_EXTERN1;
|
status |= WDIOF_EXTERN1;
|
||||||
if (new_status & WDC_SR_ISII1)
|
if (new_status & WDC_SR_ISII1)
|
||||||
*status |= WDIOF_EXTERN2;
|
status |= WDIOF_EXTERN2;
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501) {
|
||||||
if (!(new_status & WDC_SR_TGOOD))
|
if (!(new_status & WDC_SR_TGOOD))
|
||||||
*status |= WDIOF_OVERHEAT;
|
status |= WDIOF_OVERHEAT;
|
||||||
if (!(new_status & WDC_SR_PSUOVER))
|
if (!(new_status & WDC_SR_PSUOVER))
|
||||||
*status |= WDIOF_POWEROVER;
|
status |= WDIOF_POWEROVER;
|
||||||
if (!(new_status & WDC_SR_PSUUNDR))
|
if (!(new_status & WDC_SR_PSUUNDR))
|
||||||
*status |= WDIOF_POWERUNDER;
|
status |= WDIOF_POWERUNDER;
|
||||||
if (tachometer) {
|
if (tachometer) {
|
||||||
if (!(new_status & WDC_SR_FANGOOD))
|
if (!(new_status & WDC_SR_FANGOOD))
|
||||||
*status |= WDIOF_FANFAULT;
|
status |= WDIOF_FANFAULT;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_WDT_501 */
|
}
|
||||||
return 0;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_WDT_501
|
|
||||||
/**
|
/**
|
||||||
* wdt_get_temperature:
|
* wdt_get_temperature:
|
||||||
*
|
*
|
||||||
|
@ -239,7 +238,7 @@ static int wdt_get_status(int *status)
|
||||||
* farenheit. It was designed by an imperial measurement luddite.
|
* farenheit. It was designed by an imperial measurement luddite.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int wdt_get_temperature(int *temperature)
|
static int wdt_get_temperature(void)
|
||||||
{
|
{
|
||||||
unsigned short c;
|
unsigned short c;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
@ -247,10 +246,18 @@ static int wdt_get_temperature(int *temperature)
|
||||||
spin_lock_irqsave(&wdt_lock, flags);
|
spin_lock_irqsave(&wdt_lock, flags);
|
||||||
c = inb_p(WDT_RT);
|
c = inb_p(WDT_RT);
|
||||||
spin_unlock_irqrestore(&wdt_lock, flags);
|
spin_unlock_irqrestore(&wdt_lock, flags);
|
||||||
*temperature = (c * 11 / 15) + 7;
|
return (c * 11 / 15) + 7;
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
static void wdt_decode_501(int status)
|
||||||
|
{
|
||||||
|
if (!(status & WDC_SR_TGOOD))
|
||||||
|
printk(KERN_CRIT "Overheat alarm.(%d)\n", inb_p(WDT_RT));
|
||||||
|
if (!(status & WDC_SR_PSUOVER))
|
||||||
|
printk(KERN_CRIT "PSU over voltage.\n");
|
||||||
|
if (!(status & WDC_SR_PSUUNDR))
|
||||||
|
printk(KERN_CRIT "PSU under voltage.\n");
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_WDT_501 */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wdt_interrupt:
|
* wdt_interrupt:
|
||||||
|
@ -275,18 +282,13 @@ static irqreturn_t wdt_interrupt(int irq, void *dev_id)
|
||||||
|
|
||||||
printk(KERN_CRIT "WDT status %d\n", status);
|
printk(KERN_CRIT "WDT status %d\n", status);
|
||||||
|
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501) {
|
||||||
if (!(status & WDC_SR_TGOOD))
|
wdt_decode_501(status);
|
||||||
printk(KERN_CRIT "Overheat alarm.(%d)\n", inb_p(WDT_RT));
|
|
||||||
if (!(status & WDC_SR_PSUOVER))
|
|
||||||
printk(KERN_CRIT "PSU over voltage.\n");
|
|
||||||
if (!(status & WDC_SR_PSUUNDR))
|
|
||||||
printk(KERN_CRIT "PSU under voltage.\n");
|
|
||||||
if (tachometer) {
|
if (tachometer) {
|
||||||
if (!(status & WDC_SR_FANGOOD))
|
if (!(status & WDC_SR_FANGOOD))
|
||||||
printk(KERN_CRIT "Possible fan fault.\n");
|
printk(KERN_CRIT "Possible fan fault.\n");
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_WDT_501 */
|
}
|
||||||
if (!(status & WDC_SR_WCCR)) {
|
if (!(status & WDC_SR_WCCR)) {
|
||||||
#ifdef SOFTWARE_REBOOT
|
#ifdef SOFTWARE_REBOOT
|
||||||
#ifdef ONLY_TESTING
|
#ifdef ONLY_TESTING
|
||||||
|
@ -366,17 +368,18 @@ static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||||
|
|
||||||
/* Add options according to the card we have */
|
/* Add options according to the card we have */
|
||||||
ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
|
ident.options |= (WDIOF_EXTERN1|WDIOF_EXTERN2);
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501) {
|
||||||
ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|WDIOF_POWEROVER);
|
ident.options |= (WDIOF_OVERHEAT|WDIOF_POWERUNDER|
|
||||||
|
WDIOF_POWEROVER);
|
||||||
if (tachometer)
|
if (tachometer)
|
||||||
ident.options |= WDIOF_FANFAULT;
|
ident.options |= WDIOF_FANFAULT;
|
||||||
#endif /* CONFIG_WDT_501 */
|
}
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case WDIOC_GETSUPPORT:
|
case WDIOC_GETSUPPORT:
|
||||||
return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
|
return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;
|
||||||
case WDIOC_GETSTATUS:
|
case WDIOC_GETSTATUS:
|
||||||
wdt_get_status(&status);
|
status = wdt_get_status();
|
||||||
return put_user(status, p);
|
return put_user(status, p);
|
||||||
case WDIOC_GETBOOTSTATUS:
|
case WDIOC_GETBOOTSTATUS:
|
||||||
return put_user(0, p);
|
return put_user(0, p);
|
||||||
|
@ -446,7 +449,6 @@ static int wdt_release(struct inode *inode, struct file *file)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_WDT_501
|
|
||||||
/**
|
/**
|
||||||
* wdt_temp_read:
|
* wdt_temp_read:
|
||||||
* @file: file handle to the watchdog board
|
* @file: file handle to the watchdog board
|
||||||
|
@ -461,10 +463,7 @@ static int wdt_release(struct inode *inode, struct file *file)
|
||||||
static ssize_t wdt_temp_read(struct file *file, char __user *buf,
|
static ssize_t wdt_temp_read(struct file *file, char __user *buf,
|
||||||
size_t count, loff_t *ptr)
|
size_t count, loff_t *ptr)
|
||||||
{
|
{
|
||||||
int temperature;
|
int temperature = wdt_get_temperature();
|
||||||
|
|
||||||
if (wdt_get_temperature(&temperature))
|
|
||||||
return -EFAULT;
|
|
||||||
|
|
||||||
if (copy_to_user(buf, &temperature, 1))
|
if (copy_to_user(buf, &temperature, 1))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
@ -497,7 +496,6 @@ static int wdt_temp_release(struct inode *inode, struct file *file)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_WDT_501 */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* notify_sys:
|
* notify_sys:
|
||||||
|
@ -539,7 +537,6 @@ static struct miscdevice wdt_miscdev = {
|
||||||
.fops = &wdt_fops,
|
.fops = &wdt_fops,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_WDT_501
|
|
||||||
static const struct file_operations wdt_temp_fops = {
|
static const struct file_operations wdt_temp_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.llseek = no_llseek,
|
.llseek = no_llseek,
|
||||||
|
@ -553,7 +550,6 @@ static struct miscdevice temp_miscdev = {
|
||||||
.name = "temperature",
|
.name = "temperature",
|
||||||
.fops = &wdt_temp_fops,
|
.fops = &wdt_temp_fops,
|
||||||
};
|
};
|
||||||
#endif /* CONFIG_WDT_501 */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The WDT card needs to learn about soft shutdowns in order to
|
* The WDT card needs to learn about soft shutdowns in order to
|
||||||
|
@ -577,9 +573,8 @@ static struct notifier_block wdt_notifier = {
|
||||||
static void __exit wdt_exit(void)
|
static void __exit wdt_exit(void)
|
||||||
{
|
{
|
||||||
misc_deregister(&wdt_miscdev);
|
misc_deregister(&wdt_miscdev);
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501)
|
||||||
misc_deregister(&temp_miscdev);
|
misc_deregister(&temp_miscdev);
|
||||||
#endif /* CONFIG_WDT_501 */
|
|
||||||
unregister_reboot_notifier(&wdt_notifier);
|
unregister_reboot_notifier(&wdt_notifier);
|
||||||
free_irq(irq, NULL);
|
free_irq(irq, NULL);
|
||||||
release_region(io, 8);
|
release_region(io, 8);
|
||||||
|
@ -597,12 +592,17 @@ static int __init wdt_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (type != 500 && type != 501) {
|
||||||
|
printk(KERN_ERR "wdt: unknown card type '%d'.\n", type);
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
/* Check that the heartbeat value is within it's range;
|
/* Check that the heartbeat value is within it's range;
|
||||||
if not reset to the default */
|
if not reset to the default */
|
||||||
if (wdt_set_heartbeat(heartbeat)) {
|
if (wdt_set_heartbeat(heartbeat)) {
|
||||||
wdt_set_heartbeat(WD_TIMO);
|
wdt_set_heartbeat(WD_TIMO);
|
||||||
printk(KERN_INFO "wdt: heartbeat value must be 0 < heartbeat < 65536, using %d\n",
|
printk(KERN_INFO "wdt: heartbeat value must be "
|
||||||
WD_TIMO);
|
"0 < heartbeat < 65536, using %d\n", WD_TIMO);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!request_region(io, 8, "wdt501p")) {
|
if (!request_region(io, 8, "wdt501p")) {
|
||||||
|
@ -625,15 +625,14 @@ static int __init wdt_init(void)
|
||||||
goto outirq;
|
goto outirq;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501) {
|
||||||
ret = misc_register(&temp_miscdev);
|
ret = misc_register(&temp_miscdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printk(KERN_ERR
|
printk(KERN_ERR "wdt: cannot register miscdev "
|
||||||
"wdt: cannot register miscdev on minor=%d (err=%d)\n",
|
"on minor=%d (err=%d)\n", TEMP_MINOR, ret);
|
||||||
TEMP_MINOR, ret);
|
|
||||||
goto outrbt;
|
goto outrbt;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_WDT_501 */
|
}
|
||||||
|
|
||||||
ret = misc_register(&wdt_miscdev);
|
ret = misc_register(&wdt_miscdev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
@ -643,28 +642,25 @@ static int __init wdt_init(void)
|
||||||
goto outmisc;
|
goto outmisc;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
printk(KERN_INFO "WDT500/501-P driver 0.10 "
|
||||||
printk(KERN_INFO "WDT500/501-P driver 0.10 at 0x%04x (Interrupt %d). heartbeat=%d sec (nowayout=%d)\n",
|
"at 0x%04x (Interrupt %d). heartbeat=%d sec (nowayout=%d)\n",
|
||||||
io, irq, heartbeat, nowayout);
|
io, irq, heartbeat, nowayout);
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501)
|
||||||
printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
|
printk(KERN_INFO "wdt: Fan Tachometer is %s\n",
|
||||||
(tachometer ? "Enabled" : "Disabled"));
|
(tachometer ? "Enabled" : "Disabled"));
|
||||||
#endif /* CONFIG_WDT_501 */
|
return 0;
|
||||||
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
outmisc:
|
outmisc:
|
||||||
#ifdef CONFIG_WDT_501
|
if (type == 501)
|
||||||
misc_deregister(&temp_miscdev);
|
misc_deregister(&temp_miscdev);
|
||||||
outrbt:
|
outrbt:
|
||||||
#endif /* CONFIG_WDT_501 */
|
|
||||||
unregister_reboot_notifier(&wdt_notifier);
|
unregister_reboot_notifier(&wdt_notifier);
|
||||||
outirq:
|
outirq:
|
||||||
free_irq(irq, NULL);
|
free_irq(irq, NULL);
|
||||||
outreg:
|
outreg:
|
||||||
release_region(io, 8);
|
release_region(io, 8);
|
||||||
goto out;
|
out:
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(wdt_init);
|
module_init(wdt_init);
|
||||||
|
|
Loading…
Reference in New Issue