[WATCHDOG] pcwd.c show card info patch

Put all code for showing the card's boot info in
one sub-routine.

Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

+79 -78
+79 -78
drivers/char/watchdog/pcwd.c
··· 229 229 pcwd_private.supports_temp = 1; 230 230 } 231 231 232 + static inline char *get_firmware(void) 233 + { 234 + int one, ten, hund, minor; 235 + char *ret; 236 + 237 + ret = kmalloc(6, GFP_KERNEL); 238 + if(ret == NULL) 239 + return NULL; 240 + 241 + if (set_command_mode()) { 242 + one = send_isa_command(CMD_ISA_VERSION_INTEGER); 243 + ten = send_isa_command(CMD_ISA_VERSION_TENTH); 244 + hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH); 245 + minor = send_isa_command(CMD_ISA_VERSION_MINOR); 246 + sprintf(ret, "%c.%c%c%c", one, ten, hund, minor); 247 + } 248 + else 249 + sprintf(ret, "ERROR"); 250 + 251 + unset_command_mode(); 252 + return(ret); 253 + } 254 + 255 + static inline int pcwd_get_option_switches(void) 256 + { 257 + int option_switches=0; 258 + 259 + if (set_command_mode()) { 260 + /* Get switch settings */ 261 + option_switches = send_isa_command(CMD_ISA_SWITCH_SETTINGS); 262 + } 263 + 264 + unset_command_mode(); 265 + return(option_switches); 266 + } 267 + 268 + static void pcwd_show_card_info(void) 269 + { 270 + char *firmware; 271 + int option_switches; 272 + 273 + /* Get some extra info from the hardware (in command/debug/diag mode) */ 274 + if (pcwd_private.revision == PCWD_REVISION_A) 275 + printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr); 276 + else if (pcwd_private.revision == PCWD_REVISION_C) { 277 + firmware = get_firmware(); 278 + printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", 279 + pcwd_private.io_addr, firmware); 280 + kfree(firmware); 281 + option_switches = pcwd_get_option_switches(); 282 + printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", 283 + option_switches, 284 + ((option_switches & 0x10) ? "ON" : "OFF"), 285 + ((option_switches & 0x08) ? "ON" : "OFF")); 286 + 287 + /* Reprogram internal heartbeat to 2 seconds */ 288 + if (set_command_mode()) { 289 + send_isa_command(CMD_ISA_DELAY_TIME_2SECS); 290 + unset_command_mode(); 291 + } 292 + } 293 + 294 + if (pcwd_private.supports_temp) 295 + printk(KERN_INFO PFX "Temperature Option Detected\n"); 296 + 297 + if (pcwd_private.boot_status & WDIOF_CARDRESET) 298 + printk(KERN_INFO PFX "Previous reboot was caused by the card\n"); 299 + 300 + if (pcwd_private.boot_status & WDIOF_OVERHEAT) { 301 + printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n"); 302 + printk(KERN_EMERG PFX "CPU Overheat\n"); 303 + } 304 + 305 + if (pcwd_private.boot_status == 0) 306 + printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); 307 + } 308 + 232 309 static void pcwd_timer_ping(unsigned long data) 233 310 { 234 311 int wdrst_stat; ··· 721 644 return r; 722 645 } 723 646 724 - static inline char *get_firmware(void) 725 - { 726 - int one, ten, hund, minor; 727 - char *ret; 728 - 729 - ret = kmalloc(6, GFP_KERNEL); 730 - if(ret == NULL) 731 - return NULL; 732 - 733 - if (set_command_mode()) { 734 - one = send_isa_command(CMD_ISA_VERSION_INTEGER); 735 - ten = send_isa_command(CMD_ISA_VERSION_TENTH); 736 - hund = send_isa_command(CMD_ISA_VERSION_HUNDRETH); 737 - minor = send_isa_command(CMD_ISA_VERSION_MINOR); 738 - sprintf(ret, "%c.%c%c%c", one, ten, hund, minor); 739 - } 740 - else 741 - sprintf(ret, "ERROR"); 742 - 743 - unset_command_mode(); 744 - return(ret); 745 - } 746 - 747 - static inline int get_option_switches(void) 748 - { 749 - int rv=0; 750 - 751 - if (set_command_mode()) { 752 - /* Get switch settings */ 753 - rv = send_isa_command(CMD_ISA_SWITCH_SETTINGS); 754 - } 755 - 756 - unset_command_mode(); 757 - return(rv); 758 - } 759 - 760 647 static int __devinit pcwatchdog_init(int base_addr) 761 648 { 762 649 int ret; 763 - char *firmware; 764 - int option_switches; 765 650 766 651 cards_found++; 767 652 if (cards_found == 1) ··· 771 732 /* Check whether or not the card supports the temperature device */ 772 733 pcwd_check_temperature_support(); 773 734 774 - /* Get some extra info from the hardware (in command/debug/diag mode) */ 775 - if (pcwd_private.revision == PCWD_REVISION_A) 776 - printk(KERN_INFO PFX "ISA-PC Watchdog (REV.A) detected at port 0x%04x\n", pcwd_private.io_addr); 777 - else if (pcwd_private.revision == PCWD_REVISION_C) { 778 - firmware = get_firmware(); 779 - printk(KERN_INFO PFX "ISA-PC Watchdog (REV.C) detected at port 0x%04x (Firmware version: %s)\n", 780 - pcwd_private.io_addr, firmware); 781 - kfree(firmware); 782 - option_switches = get_option_switches(); 783 - printk(KERN_INFO PFX "Option switches (0x%02x): Temperature Reset Enable=%s, Power On Delay=%s\n", 784 - option_switches, 785 - ((option_switches & 0x10) ? "ON" : "OFF"), 786 - ((option_switches & 0x08) ? "ON" : "OFF")); 787 - 788 - /* Reprogram internal heartbeat to 2 seconds */ 789 - if (set_command_mode()) { 790 - send_isa_command(CMD_ISA_DELAY_TIME_2SECS); 791 - unset_command_mode(); 792 - } 793 - } else { 794 - /* Should NEVER happen, unless get_revision() fails. */ 795 - printk(KERN_INFO PFX "Unable to get revision\n"); 796 - release_region(pcwd_private.io_addr, (pcwd_private.revision == PCWD_REVISION_A) ? 2 : 4); 797 - pcwd_private.io_addr = 0x0000; 798 - return -1; 799 - } 800 - 801 - if (pcwd_private.supports_temp) 802 - printk(KERN_INFO PFX "Temperature Option Detected\n"); 803 - 804 - if (pcwd_private.boot_status & WDIOF_CARDRESET) 805 - printk(KERN_INFO PFX "Previous reboot was caused by the card\n"); 806 - 807 - if (pcwd_private.boot_status & WDIOF_OVERHEAT) { 808 - printk(KERN_EMERG PFX "Card senses a CPU Overheat. Panicking!\n"); 809 - printk(KERN_EMERG PFX "CPU Overheat\n"); 810 - } 811 - 812 - if (pcwd_private.boot_status == 0) 813 - printk(KERN_INFO PFX "No previous trip detected - Cold boot or reset\n"); 735 + /* Show info about the card itself */ 736 + pcwd_show_card_info(); 814 737 815 738 /* Check that the heartbeat value is within it's range ; if not reset to the default */ 816 739 if (pcwd_set_heartbeat(heartbeat)) {