···4949 * More info available at http://www.berkprod.com/ or http://www.pcwatchdog.com/5050 */51515252-#include <linux/module.h>5353-#include <linux/moduleparam.h>5454-#include <linux/types.h>5555-#include <linux/timer.h>5656-#include <linux/jiffies.h>5757-#include <linux/config.h>5858-#include <linux/wait.h>5959-#include <linux/slab.h>6060-#include <linux/ioport.h>6161-#include <linux/delay.h>6262-#include <linux/fs.h>6363-#include <linux/miscdevice.h>6464-#include <linux/watchdog.h>6565-#include <linux/notifier.h>6666-#include <linux/init.h>6767-#include <linux/spinlock.h>6868-#include <linux/reboot.h>5252+#include <linux/config.h> /* For CONFIG_WATCHDOG_NOWAYOUT/... */5353+#include <linux/module.h> /* For module specific items */5454+#include <linux/moduleparam.h> /* For new moduleparam's */5555+#include <linux/types.h> /* For standard types (like size_t) */5656+#include <linux/errno.h> /* For the -ENODEV/... values */5757+#include <linux/kernel.h> /* For printk/panic/... */5858+#include <linux/delay.h> /* For mdelay function */5959+#include <linux/timer.h> /* For timer related operations */6060+#include <linux/jiffies.h> /* For jiffies stuff */6161+#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */6262+#include <linux/watchdog.h> /* For the watchdog specific items */6363+#include <linux/notifier.h> /* For notifier support */6464+#include <linux/reboot.h> /* For reboot_notifier stuff */6565+#include <linux/init.h> /* For __init/__exit/... */6666+#include <linux/fs.h> /* For file operations */6767+#include <linux/ioport.h> /* For io-port access */6868+#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */6969#include <linux/sched.h> /* TASK_INTERRUPTIBLE, set_current_state() and friends */7070-#include <asm/uaccess.h>7171-#include <asm/io.h>7070+#include <linux/slab.h> /* For kmalloc */72717373-#define WD_VER "1.16 (06/12/2004)"7474-#define PFX "pcwd: "7272+#include <asm/uaccess.h> /* For copy_to_user/put_user/... */7373+#include <asm/io.h> /* For inb/outb/... */7474+7575+/* Module and version information */7676+#define WATCHDOG_VERSION "1.16"7777+#define WATCHDOG_DATE "03 Jan 2006"7878+#define WATCHDOG_DRIVER_NAME "ISA-PC Watchdog"7979+#define WATCHDOG_NAME "pcwd"8080+#define PFX WATCHDOG_NAME ": "8181+#define DRIVER_VERSION WATCHDOG_DRIVER_NAME " driver, v" WATCHDOG_VERSION " (" WATCHDOG_DATE ")\n"8282+#define WD_VER WATCHDOG_VERSION " (" WATCHDOG_DATE ")"75837684/*7785 * It should be noted that PCWD_REVISION_B was removed because A and B···93859486/*9587 * These are the defines that describe the control status bits for the9696- * PC Watchdog card, revision A.9797- */8888+ * PCI-PC Watchdog card.8989+*/9090+/* Port 1 : Control Status #1 for the PC Watchdog card, revision A. */9891#define WD_WDRST 0x01 /* Previously reset state */9992#define WD_T110 0x02 /* Temperature overheat sense */10093#define WD_HRTBT 0x04 /* Heartbeat sense */10194#define WD_RLY2 0x08 /* External relay triggered */10295#define WD_SRLY2 0x80 /* Software external relay triggered */103103-104104-/*105105- * These are the defines that describe the control status bits for the106106- * PC Watchdog card, revision C.107107- */9696+/* Port 1 : Control Status #1 for the PC Watchdog card, revision C. */10897#define WD_REVC_WTRP 0x01 /* Watchdog Trip status */10998#define WD_REVC_HRBT 0x02 /* Watchdog Heartbeat */11099#define WD_REVC_TTRP 0x04 /* Temperature Trip status */100100+/* Port 2 : Control Status #2 */101101+#define WD_WDIS 0x10 /* Watchdog Disabled */102102+#define WD_ENTP 0x20 /* Watchdog Enable Temperature Trip */103103+#define WD_SSEL 0x40 /* Watchdog Switch Select (1:SW1 <-> 0:SW2) */104104+#define WD_WCMD 0x80 /* Watchdog Command Mode */111105112106/* max. time we give an ISA watchdog card to process a command */113107/* 500ms for each 4 bit response (according to spec.) */114108#define ISA_COMMAND_TIMEOUT 1000115109116110/* Watchdog's internal commands */117117-#define CMD_ISA_IDLE 0x00118118-#define CMD_ISA_VERSION_INTEGER 0x01119119-#define CMD_ISA_VERSION_TENTH 0x02120120-#define CMD_ISA_VERSION_HUNDRETH 0x03121121-#define CMD_ISA_VERSION_MINOR 0x04122122-#define CMD_ISA_SWITCH_SETTINGS 0x05123123-#define CMD_ISA_DELAY_TIME_2SECS 0x0A124124-#define CMD_ISA_DELAY_TIME_4SECS 0x0B125125-#define CMD_ISA_DELAY_TIME_8SECS 0x0C111111+#define CMD_ISA_IDLE 0x00112112+#define CMD_ISA_VERSION_INTEGER 0x01113113+#define CMD_ISA_VERSION_TENTH 0x02114114+#define CMD_ISA_VERSION_HUNDRETH 0x03115115+#define CMD_ISA_VERSION_MINOR 0x04116116+#define CMD_ISA_SWITCH_SETTINGS 0x05117117+#define CMD_ISA_DELAY_TIME_2SECS 0x0A118118+#define CMD_ISA_DELAY_TIME_4SECS 0x0B119119+#define CMD_ISA_DELAY_TIME_8SECS 0x0C126120127121/*128122 * We are using an kernel timer to do the pinging of the watchdog···140130/* internal variables */141131static atomic_t open_allowed = ATOMIC_INIT(1);142132static char expect_close;143143-static struct timer_list timer;144144-static unsigned long next_heartbeat;145133static int temp_panic;146146-static int revision; /* The card's revision */147147-static int supports_temp; /* Wether or not the card has a temperature device */148148-static int command_mode; /* Wether or not the card is in command mode */149149-static int initial_status; /* The card's boot status */150150-static int current_readport; /* The cards I/O address */151151-static spinlock_t io_lock;134134+static struct { /* this is private data for each ISA-PC watchdog card */135135+ int revision; /* The card's revision */136136+ int supports_temp; /* Wether or not the card has a temperature device */137137+ int command_mode; /* Wether or not the card is in command mode */138138+ int boot_status; /* The card's boot status */139139+ int io_addr; /* The cards I/O address */140140+ spinlock_t io_lock; /* the lock for io operations */141141+ struct timer_list timer; /* The timer that pings the watchdog */142142+ unsigned long next_heartbeat; /* the next_heartbeat for the timer */143143+} pcwd_private;152144153145/* module parameters */154146#define WATCHDOG_HEARTBEAT 60 /* 60 sec default heartbeat */···173161 int port0, last_port0; /* Double read for stabilising */174162175163 /* The WCMD bit must be 1 and the command is only 4 bits in size */176176- control_status = (cmd & 0x0F) | 0x80;177177- outb_p(control_status, current_readport + 2);164164+ control_status = (cmd & 0x0F) | WD_WCMD;165165+ outb_p(control_status, pcwd_private.io_addr + 2);178166 udelay(ISA_COMMAND_TIMEOUT);179167180180- port0 = inb_p(current_readport);168168+ port0 = inb_p(pcwd_private.io_addr);181169 for (i = 0; i < 25; ++i) {182170 last_port0 = port0;183183- port0 = inb_p(current_readport);171171+ port0 = inb_p(pcwd_private.io_addr);184172185173 if (port0 == last_port0)186174 break; /* Data is stable */···196184 int i, found=0, count=0;197185198186 /* Set the card into command mode */199199- spin_lock(&io_lock);187187+ spin_lock(&pcwd_private.io_lock);200188 while ((!found) && (count < 3)) {201189 i = send_isa_command(CMD_ISA_IDLE);202190···204192 found = 1;205193 else if (i == 0xF3) {206194 /* Card does not like what we've done to it */207207- outb_p(0x00, current_readport + 2);195195+ outb_p(0x00, pcwd_private.io_addr + 2);208196 udelay(1200); /* Spec says wait 1ms */209209- outb_p(0x00, current_readport + 2);197197+ outb_p(0x00, pcwd_private.io_addr + 2);210198 udelay(ISA_COMMAND_TIMEOUT);211199 }212200 count++;213201 }214214- spin_unlock(&io_lock);215215- command_mode = found;202202+ spin_unlock(&pcwd_private.io_lock);203203+ pcwd_private.command_mode = found;216204217205 return(found);218206}···220208static void unset_command_mode(void)221209{222210 /* Set the card into normal mode */223223- spin_lock(&io_lock);224224- outb_p(0x00, current_readport + 2);211211+ spin_lock(&pcwd_private.io_lock);212212+ outb_p(0x00, pcwd_private.io_addr + 2);225213 udelay(ISA_COMMAND_TIMEOUT);226226- spin_unlock(&io_lock);214214+ spin_unlock(&pcwd_private.io_lock);227215228228- command_mode = 0;216216+ pcwd_private.command_mode = 0;217217+}218218+219219+static inline void pcwd_check_temperature_support(void)220220+{221221+ if (inb(pcwd_private.io_addr) != 0xF0)222222+ pcwd_private.supports_temp = 1;223223+}224224+225225+static inline char *get_firmware(void)226226+{227227+ int one, ten, hund, minor;228228+ char *ret;229229+230230+ ret = kmalloc(6, GFP_KERNEL);231231+ if(ret == NULL)232232+ return NULL;233233+234234+ if (set_command_mode()) {235235+ one = send_isa_command(CMD_ISA_VERSION_INTEGER);236236+ ten = send_isa_command(CMD_ISA_VERSION_TENTH);237237+ hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH);238238+ minor = send_isa_command(CMD_ISA_VERSION_MINOR);239239+ sprintf(ret, "%c.%c%c%c", one, ten, hund, minor);240240+ }241241+ else242242+ sprintf(ret, "ERROR");243243+244244+ unset_command_mode();245245+ return(ret);246246+}247247+248248+static inline int pcwd_get_option_switches(void)249249+{250250+ int option_switches=0;251251+252252+ if (set_command_mode()) {253253+ /* Get switch settings */254254+ option_switches = send_isa_command(CMD_ISA_SWITCH_SETTINGS);255255+ }256256+257257+ unset_command_mode();258258+ return(option_switches);259259+}260260+261261+static void pcwd_show_card_info(void)262262+{263263+ char *firmware;264264+ int option_switches;265265+266266+ /* Get some extra info from the hardware (in command/debug/diag mode) */267267+ if (pcwd_private.revision == PCWD_REVISION_A)268268+ printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr);269269+ else if (pcwd_private.revision == PCWD_REVISION_C) {270270+ firmware = get_firmware();271271+ printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",272272+ pcwd_private.io_addr, firmware);273273+ kfree(firmware);274274+ option_switches = pcwd_get_option_switches();275275+ printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",276276+ option_switches,277277+ ((option_switches & 0x10) ? "ON" : "OFF"),278278+ ((option_switches & 0x08) ? "ON" : "OFF"));279279+280280+ /* Reprogram internal heartbeat to 2 seconds */281281+ if (set_command_mode()) {282282+ send_isa_command(CMD_ISA_DELAY_TIME_2SECS);283283+ unset_command_mode();284284+ }285285+ }286286+287287+ if (pcwd_private.supports_temp)288288+ printk(KERN_INFO PFX "Temperature Option Detected\n");289289+290290+ if (pcwd_private.boot_status & WDIOF_CARDRESET)291291+ printk(KERN_INFO PFX "Previous reboot was caused by the card\n");292292+293293+ if (pcwd_private.boot_status & WDIOF_OVERHEAT) {294294+ printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");295295+ printk(KERN_EMERG PFX "CPU Overheat\n");296296+ }297297+298298+ if (pcwd_private.boot_status == 0)299299+ printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");229300}230301231302static void pcwd_timer_ping(unsigned long data)···317222318223 /* If we got a heartbeat pulse within the WDT_INTERVAL319224 * we agree to ping the WDT */320320- if(time_before(jiffies, next_heartbeat)) {225225+ if(time_before(jiffies, pcwd_private.next_heartbeat)) {321226 /* Ping the watchdog */322322- spin_lock(&io_lock);323323- if (revision == PCWD_REVISION_A) {227227+ spin_lock(&pcwd_private.io_lock);228228+ if (pcwd_private.revision == PCWD_REVISION_A) {324229 /* Rev A cards are reset by setting the WD_WDRST bit in register 1 */325325- wdrst_stat = inb_p(current_readport);230230+ wdrst_stat = inb_p(pcwd_private.io_addr);326231 wdrst_stat &= 0x0F;327232 wdrst_stat |= WD_WDRST;328233329329- outb_p(wdrst_stat, current_readport + 1);234234+ outb_p(wdrst_stat, pcwd_private.io_addr + 1);330235 } else {331236 /* Re-trigger watchdog by writing to port 0 */332332- outb_p(0x00, current_readport);237237+ outb_p(0x00, pcwd_private.io_addr);333238 }334239335240 /* Re-set the timer interval */336336- mod_timer(&timer, jiffies + WDT_INTERVAL);241241+ mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL);337242338338- spin_unlock(&io_lock);243243+ spin_unlock(&pcwd_private.io_lock);339244 } else {340245 printk(KERN_WARNING PFX "Heartbeat lost! Will not ping the watchdog\n");341246 }···345250{346251 int stat_reg;347252348348- next_heartbeat = jiffies + (heartbeat * HZ);253253+ pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ);349254350255 /* Start the timer */351351- mod_timer(&timer, jiffies + WDT_INTERVAL);256256+ mod_timer(&pcwd_private.timer, jiffies + WDT_INTERVAL);352257353258 /* Enable the port */354354- if (revision == PCWD_REVISION_C) {355355- spin_lock(&io_lock);356356- outb_p(0x00, current_readport + 3);259259+ if (pcwd_private.revision == PCWD_REVISION_C) {260260+ spin_lock(&pcwd_private.io_lock);261261+ outb_p(0x00, pcwd_private.io_addr + 3);357262 udelay(ISA_COMMAND_TIMEOUT);358358- stat_reg = inb_p(current_readport + 2);359359- spin_unlock(&io_lock);360360- if (stat_reg & 0x10) {263263+ stat_reg = inb_p(pcwd_private.io_addr + 2);264264+ spin_unlock(&pcwd_private.io_lock);265265+ if (stat_reg & WD_WDIS) {361266 printk(KERN_INFO PFX "Could not start watchdog\n");362267 return -EIO;363268 }···370275 int stat_reg;371276372277 /* Stop the timer */373373- del_timer(&timer);278278+ del_timer(&pcwd_private.timer);374279375280 /* Disable the board */376376- if (revision == PCWD_REVISION_C) {377377- spin_lock(&io_lock);378378- outb_p(0xA5, current_readport + 3);281281+ if (pcwd_private.revision == PCWD_REVISION_C) {282282+ spin_lock(&pcwd_private.io_lock);283283+ outb_p(0xA5, pcwd_private.io_addr + 3);379284 udelay(ISA_COMMAND_TIMEOUT);380380- outb_p(0xA5, current_readport + 3);285285+ outb_p(0xA5, pcwd_private.io_addr + 3);381286 udelay(ISA_COMMAND_TIMEOUT);382382- stat_reg = inb_p(current_readport + 2);383383- spin_unlock(&io_lock);384384- if ((stat_reg & 0x10) == 0) {287287+ stat_reg = inb_p(pcwd_private.io_addr + 2);288288+ spin_unlock(&pcwd_private.io_lock);289289+ if ((stat_reg & WD_WDIS) == 0) {385290 printk(KERN_INFO PFX "Could not stop watchdog\n");386291 return -EIO;387292 }···392297static int pcwd_keepalive(void)393298{394299 /* user land ping */395395- next_heartbeat = jiffies + (heartbeat * HZ);300300+ pcwd_private.next_heartbeat = jiffies + (heartbeat * HZ);396301 return 0;397302}398303···410315 int card_status;411316412317 *status=0;413413- spin_lock(&io_lock);414414- if (revision == PCWD_REVISION_A)318318+ spin_lock(&pcwd_private.io_lock);319319+ if (pcwd_private.revision == PCWD_REVISION_A)415320 /* Rev A cards return status information from416321 * the base register, which is used for the417322 * temperature in other cards. */418418- card_status = inb(current_readport);323323+ card_status = inb(pcwd_private.io_addr);419324 else {420325 /* Rev C cards return card status in the base421326 * address + 1 register. And use different bits422327 * to indicate a card initiated reset, and an423328 * over-temperature condition. And the reboot424329 * status can be reset. */425425- card_status = inb(current_readport + 1);330330+ card_status = inb(pcwd_private.io_addr + 1);426331 }427427- spin_unlock(&io_lock);332332+ spin_unlock(&pcwd_private.io_lock);428333429429- if (revision == PCWD_REVISION_A) {334334+ if (pcwd_private.revision == PCWD_REVISION_A) {430335 if (card_status & WD_WDRST)431336 *status |= WDIOF_CARDRESET;432337···455360456361static int pcwd_clear_status(void)457362{458458- if (revision == PCWD_REVISION_C) {459459- spin_lock(&io_lock);460460- outb_p(0x00, current_readport + 1); /* clear reset status */461461- spin_unlock(&io_lock);363363+ if (pcwd_private.revision == PCWD_REVISION_C) {364364+ spin_lock(&pcwd_private.io_lock);365365+ outb_p(0x00, pcwd_private.io_addr + 1); /* clear reset status */366366+ spin_unlock(&pcwd_private.io_lock);462367 }463368 return 0;464369}···466371static int pcwd_get_temperature(int *temperature)467372{468373 /* check that port 0 gives temperature info and no command results */469469- if (command_mode)374374+ if (pcwd_private.command_mode)470375 return -1;471376472377 *temperature = 0;473473- if (!supports_temp)378378+ if (!pcwd_private.supports_temp)474379 return -ENODEV;475380476381 /*477382 * Convert celsius to fahrenheit, since this was478383 * the decided 'standard' for this return value.479384 */480480- spin_lock(&io_lock);481481- *temperature = ((inb(current_readport)) * 9 / 5) + 32;482482- spin_unlock(&io_lock);385385+ spin_lock(&pcwd_private.io_lock);386386+ *temperature = ((inb(pcwd_private.io_addr)) * 9 / 5) + 32;387387+ spin_unlock(&pcwd_private.io_lock);483388484389 return 0;485390}···520425 return put_user(status, argp);521426522427 case WDIOC_GETBOOTSTATUS:523523- return put_user(initial_status, argp);428428+ return put_user(pcwd_private.boot_status, argp);524429525430 case WDIOC_GETTEMP:526431 if (pcwd_get_temperature(&temperature))···529434 return put_user(temperature, argp);530435531436 case WDIOC_SETOPTIONS:532532- if (revision == PCWD_REVISION_C)437437+ if (pcwd_private.revision == PCWD_REVISION_C)533438 {534439 if(copy_from_user(&rv, argp, sizeof(int)))535440 return -EFAULT;···645550646551static int pcwd_temp_open(struct inode *inode, struct file *file)647552{648648- if (!supports_temp)553553+ if (!pcwd_private.supports_temp)649554 return -ENODEV;650555651556 return nonseekable_open(inode, file);···711616 * Init & exit routines712617 */713618714714-static inline void get_support(void)715715-{716716- if (inb(current_readport) != 0xF0)717717- supports_temp = 1;718718-}719719-720619static inline int get_revision(void)721620{722621 int r = PCWD_REVISION_C;723622724724- spin_lock(&io_lock);623623+ spin_lock(&pcwd_private.io_lock);725624 /* REV A cards use only 2 io ports; test726625 * presumes a floating bus reads as 0xff. */727727- if ((inb(current_readport + 2) == 0xFF) ||728728- (inb(current_readport + 3) == 0xFF))626626+ if ((inb(pcwd_private.io_addr + 2) == 0xFF) ||627627+ (inb(pcwd_private.io_addr + 3) == 0xFF))729628 r=PCWD_REVISION_A;730730- spin_unlock(&io_lock);629629+ spin_unlock(&pcwd_private.io_lock);731630732631 return r;733733-}734734-735735-static inline char *get_firmware(void)736736-{737737- int one, ten, hund, minor;738738- char *ret;739739-740740- ret = kmalloc(6, GFP_KERNEL);741741- if(ret == NULL)742742- return NULL;743743-744744- if (set_command_mode()) {745745- one = send_isa_command(CMD_ISA_VERSION_INTEGER);746746- ten = send_isa_command(CMD_ISA_VERSION_TENTH);747747- hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH);748748- minor = send_isa_command(CMD_ISA_VERSION_MINOR);749749- sprintf(ret, "%c.%c%c%c", one, ten, hund, minor);750750- }751751- else752752- sprintf(ret, "ERROR");753753-754754- unset_command_mode();755755- return(ret);756756-}757757-758758-static inline int get_option_switches(void)759759-{760760- int rv=0;761761-762762- if (set_command_mode()) {763763- /* Get switch settings */764764- rv = send_isa_command(CMD_ISA_SWITCH_SETTINGS);765765- }766766-767767- unset_command_mode();768768- return(rv);769632}770633771634static int __devinit pcwatchdog_init(int base_addr)772635{773636 int ret;774774- char *firmware;775775- int option_switches;776637777638 cards_found++;778639 if (cards_found == 1)···743692 printk(KERN_ERR PFX "No I/O-Address for card detected\n");744693 return -ENODEV;745694 }746746- current_readport = base_addr;695695+ pcwd_private.io_addr = base_addr;747696748697 /* Check card's revision */749749- revision = get_revision();698698+ pcwd_private.revision = get_revision();750699751751- if (!request_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) {700700+ if (!request_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4, "PCWD")) {752701 printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",753753- current_readport);754754- current_readport = 0x0000;702702+ pcwd_private.io_addr);703703+ pcwd_private.io_addr = 0x0000;755704 return -EIO;756705 }757706758707 /* Initial variables */759759- supports_temp = 0;708708+ pcwd_private.supports_temp = 0;760709 temp_panic = 0;761761- initial_status = 0x0000;710710+ pcwd_private.boot_status = 0x0000;762711763712 /* get the boot_status */764764- pcwd_get_status(&initial_status);713713+ pcwd_get_status(&pcwd_private.boot_status);765714766715 /* clear the "card caused reboot" flag */767716 pcwd_clear_status();768717769769- init_timer(&timer);770770- timer.function = pcwd_timer_ping;771771- timer.data = 0;718718+ init_timer(&pcwd_private.timer);719719+ pcwd_private.timer.function = pcwd_timer_ping;720720+ pcwd_private.timer.data = 0;772721773722 /* Disable the board */774723 pcwd_stop();775724776725 /* Check whether or not the card supports the temperature device */777777- get_support();726726+ pcwd_check_temperature_support();778727779779- /* Get some extra info from the hardware (in command/debug/diag mode) */780780- if (revision == PCWD_REVISION_A)781781- printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", current_readport);782782- else if (revision == PCWD_REVISION_C) {783783- firmware = get_firmware();784784- printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n",785785- current_readport, firmware);786786- kfree(firmware);787787- option_switches = get_option_switches();788788- printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n",789789- option_switches,790790- ((option_switches & 0x10) ? "ON" : "OFF"),791791- ((option_switches & 0x08) ? "ON" : "OFF"));792792-793793- /* Reprogram internal heartbeat to 2 seconds */794794- if (set_command_mode()) {795795- send_isa_command(CMD_ISA_DELAY_TIME_2SECS);796796- unset_command_mode();797797- }798798- } else {799799- /* Should NEVER happen, unless get_revision() fails. */800800- printk(KERN_INFO PFX "Unable to get revision\n");801801- release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4);802802- current_readport = 0x0000;803803- return -1;804804- }805805-806806- if (supports_temp)807807- printk(KERN_INFO PFX "Temperature Option Detected\n");808808-809809- if (initial_status & WDIOF_CARDRESET)810810- printk(KERN_INFO PFX "Previous reboot was caused by the card\n");811811-812812- if (initial_status & WDIOF_OVERHEAT) {813813- printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n");814814- printk(KERN_EMERG PFX "CPU Overheat\n");815815- }816816-817817- if (initial_status == 0)818818- printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n");728728+ /* Show info about the card itself */729729+ pcwd_show_card_info();819730820731 /* Check that the heartbeat value is within it's range ; if not reset to the default */821821- if (pcwd_set_heartbeat(heartbeat)) {822822- pcwd_set_heartbeat(WATCHDOG_HEARTBEAT);823823- printk(KERN_INFO PFX "heartbeat value must be 2<=heartbeat<=7200, using %d\n",824824- WATCHDOG_HEARTBEAT);732732+ if (pcwd_set_heartbeat(heartbeat)) {733733+ pcwd_set_heartbeat(WATCHDOG_HEARTBEAT);734734+ printk(KERN_INFO PFX "heartbeat value must be 2<=heartbeat<=7200, using %d\n",735735+ WATCHDOG_HEARTBEAT);825736 }826737827738 ret = register_reboot_notifier(&pcwd_notifier);828739 if (ret) {829740 printk(KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",830741 ret);831831- release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4);832832- current_readport = 0x0000;742742+ release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);743743+ pcwd_private.io_addr = 0x0000;833744 return ret;834745 }835746836836- if (supports_temp) {747747+ if (pcwd_private.supports_temp) {837748 ret = misc_register(&temp_miscdev);838749 if (ret) {839750 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",840751 TEMP_MINOR, ret);841752 unregister_reboot_notifier(&pcwd_notifier);842842- release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4);843843- current_readport = 0x0000;753753+ release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);754754+ pcwd_private.io_addr = 0x0000;844755 return ret;845756 }846757 }···811798 if (ret) {812799 printk(KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",813800 WATCHDOG_MINOR, ret);814814- if (supports_temp)801801+ if (pcwd_private.supports_temp)815802 misc_deregister(&temp_miscdev);816803 unregister_reboot_notifier(&pcwd_notifier);817817- release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4);818818- current_readport = 0x0000;804804+ release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);805805+ pcwd_private.io_addr = 0x0000;819806 return ret;820807 }821808···833820834821 /* Deregister */835822 misc_deregister(&pcwd_miscdev);836836- if (supports_temp)823823+ if (pcwd_private.supports_temp)837824 misc_deregister(&temp_miscdev);838825 unregister_reboot_notifier(&pcwd_notifier);839839- release_region(current_readport, (revision == PCWD_REVISION_A) ? 2 : 4);840840- current_readport = 0x0000;826826+ release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4);827827+ pcwd_private.io_addr = 0x0000;828828+ cards_found--;841829}842830843831/*···901887{902888 int i, found = 0;903889904904- spin_lock_init(&io_lock);890890+ spin_lock_init(&pcwd_private.io_lock);905891906892 for (i = 0; pcwd_ioports[i] != 0; i++) {907893 if (pcwd_checkcard(pcwd_ioports[i])) {···920906921907static void __exit pcwd_cleanup_module(void)922908{923923- if (current_readport)909909+ if (pcwd_private.io_addr)924910 pcwatchdog_exit();925911 return;926912}
+7-5
drivers/char/watchdog/sa1100_wdt.c
···9393{9494 int ret = -ENOIOCTLCMD;9595 int time;9696+ void __user *argp = (void __user *)arg;9797+ int __user *p = argp;96989799 switch (cmd) {98100 case WDIOC_GETSUPPORT:9999- ret = copy_to_user((struct watchdog_info __user *)arg, &ident,101101+ ret = copy_to_user(argp, &ident,100102 sizeof(ident)) ? -EFAULT : 0;101103 break;102104103105 case WDIOC_GETSTATUS:104104- ret = put_user(0, (int __user *)arg);106106+ ret = put_user(0, p);105107 break;106108107109 case WDIOC_GETBOOTSTATUS:108108- ret = put_user(boot_status, (int __user *)arg);110110+ ret = put_user(boot_status, p);109111 break;110112111113 case WDIOC_SETTIMEOUT:112112- ret = get_user(time, (int __user *)arg);114114+ ret = get_user(time, p);113115 if (ret)114116 break;115117···125123 /*fall through*/126124127125 case WDIOC_GETTIMEOUT:128128- ret = put_user(pre_margin / OSCR_FREQ, (int __user *)arg);126126+ ret = put_user(pre_margin / OSCR_FREQ, p);129127 break;130128131129 case WDIOC_KEEPALIVE: